0001 """distutils.command.build_ext 0002 0003 Implements the Distutils 'build_ext' command, for building extension 0004 modules (currently limited to C extensions, should accommodate C++ 0005 extensions ASAP).""" 0006 0007 # This module should be kept compatible with Python 1.5.2. 0008 0009 __revision__ = "$Id: build_ext.py,v 1.97 2004/10/14 10:02:08 anthonybaxter Exp $" 0010 0011 import sys, os, string, re 0012 from types import * 0013 from distutils.core import Command 0014 from distutils.errors import * 0015 from distutils.sysconfig import customize_compiler, get_python_version 0016 from distutils.dep_util import newer_group 0017 from distutils.extension import Extension 0018 from distutils import log 0019 0020 # An extension name is just a dot-separated list of Python NAMEs (ie. 0021 # the same as a fully-qualified module name). 0022 extension_name_re = re.compile \ 0023 (r'^[a-zA-Z_][a-zA-Z_0-9]*(\.[a-zA-Z_][a-zA-Z_0-9]*)*$') 0024 0025 0026 def show_compilers (): 0027 from distutils.ccompiler import show_compilers 0028 show_compilers() 0029 0030 0031 class build_ext (Command): 0032 0033 description = "build C/C++ extensions (compile/link to build directory)" 0034 0035 # XXX thoughts on how to deal with complex command-line options like 0036 # these, i.e. how to make it so fancy_getopt can suck them off the 0037 # command line and make it look like setup.py defined the appropriate 0038 # lists of tuples of what-have-you. 0039 # - each command needs a callback to process its command-line options 0040 # - Command.__init__() needs access to its share of the whole 0041 # command line (must ultimately come from 0042 # Distribution.parse_command_line()) 0043 # - it then calls the current command class' option-parsing 0044 # callback to deal with weird options like -D, which have to 0045 # parse the option text and churn out some custom data 0046 # structure 0047 # - that data structure (in this case, a list of 2-tuples) 0048 # will then be present in the command object by the time 0049 # we get to finalize_options() (i.e. the constructor 0050 # takes care of both command-line and client options 0051 # in between initialize_options() and finalize_options()) 0052 0053 sep_by = " (separated by '%s')" % os.pathsep 0054 user_options = [ 0055 ('build-lib=', 'b', 0056 "directory for compiled extension modules"), 0057 ('build-temp=', 't', 0058 "directory for temporary files (build by-products)"), 0059 ('inplace', 'i', 0060 "ignore build-lib and put compiled extensions into the source " + 0061 "directory alongside your pure Python modules"), 0062 ('include-dirs=', 'I', 0063 "list of directories to search for header files" + sep_by), 0064 ('define=', 'D', 0065 "C preprocessor macros to define"), 0066 ('undef=', 'U', 0067 "C preprocessor macros to undefine"), 0068 ('libraries=', 'l', 0069 "external C libraries to link with"), 0070 ('library-dirs=', 'L', 0071 "directories to search for external C libraries" + sep_by), 0072 ('rpath=', 'R', 0073 "directories to search for shared C libraries at runtime"), 0074 ('link-objects=', 'O', 0075 "extra explicit link objects to include in the link"), 0076 ('debug', 'g', 0077 "compile/link with debugging information"), 0078 ('force', 'f', 0079 "forcibly build everything (ignore file timestamps)"), 0080 ('compiler=', 'c', 0081 "specify the compiler type"), 0082 ('swig-cpp', None, 0083 "make SWIG create C++ files (default is C)"), 0084 ('swig-opts=', None, 0085 "list of SWIG command line options"), 0086 ('swig=', None, 0087 "path to the SWIG executable"), 0088 ] 0089 0090 boolean_options = ['inplace', 'debug', 'force', 'swig-cpp'] 0091 0092 help_options = [ 0093 ('help-compiler', None, 0094 "list available compilers", show_compilers), 0095 ] 0096 0097 def initialize_options (self): 0098 self.extensions = None 0099 self.build_lib = None 0100 self.build_temp = None 0101 self.inplace = 0 0102 self.package = None 0103 0104 self.include_dirs = None 0105 self.define = None 0106 self.undef = None 0107 self.libraries = None 0108 self.library_dirs = None 0109 self.rpath = None 0110 self.link_objects = None 0111 self.debug = None 0112 self.force = None 0113 self.compiler = None 0114 self.swig = None 0115 self.swig_cpp = None 0116 self.swig_opts = None 0117 0118 def finalize_options (self): 0119 from distutils import sysconfig 0120 0121 self.set_undefined_options('build', 0122 ('build_lib', 'build_lib'), 0123 ('build_temp', 'build_temp'), 0124 ('compiler', 'compiler'), 0125 ('debug', 'debug'), 0126 ('force', 'force')) 0127 0128 if self.package is None: 0129 self.package = self.distribution.ext_package 0130 0131 self.extensions = self.distribution.ext_modules 0132 0133 0134 # Make sure Python's include directories (for Python.h, pyconfig.h, 0135 # etc.) are in the include search path. 0136 py_include = sysconfig.get_python_inc() 0137 plat_py_include = sysconfig.get_python_inc(plat_specific=1) 0138 if self.include_dirs is None: 0139 self.include_dirs = self.distribution.include_dirs or [] 0140 if type(self.include_dirs) is StringType: 0141 self.include_dirs = string.split(self.include_dirs, os.pathsep) 0142 0143 # Put the Python "system" include dir at the end, so that 0144 # any local include dirs take precedence. 0145 self.include_dirs.append(py_include) 0146 if plat_py_include != py_include: 0147 self.include_dirs.append(plat_py_include) 0148 0149 if type(self.libraries) is StringType: 0150 self.libraries = [self.libraries] 0151 0152 # Life is easier if we're not forever checking for None, so 0153 # simplify these options to empty lists if unset 0154 if self.libraries is None: 0155 self.libraries = [] 0156 if self.library_dirs is None: 0157 self.library_dirs = [] 0158 elif type(self.library_dirs) is StringType: 0159 self.library_dirs = string.split(self.library_dirs, os.pathsep) 0160 0161 if self.rpath is None: 0162 self.rpath = [] 0163 elif type(self.rpath) is StringType: 0164 self.rpath = string.split(self.rpath, os.pathsep) 0165 0166 # for extensions under windows use different directories 0167 # for Release and Debug builds. 0168 # also Python's library directory must be appended to library_dirs 0169 if os.name == 'nt': 0170 self.library_dirs.append(os.path.join(sys.exec_prefix, 'libs')) 0171 if self.debug: 0172 self.build_temp = os.path.join(self.build_temp, "Debug") 0173 else: 0174 self.build_temp = os.path.join(self.build_temp, "Release") 0175 0176 # Append the source distribution include and library directories, 0177 # this allows distutils on windows to work in the source tree 0178 self.include_dirs.append(os.path.join(sys.exec_prefix, 'PC')) 0179 self.library_dirs.append(os.path.join(sys.exec_prefix, 'PCBuild')) 0180 0181 # OS/2 (EMX) doesn't support Debug vs Release builds, but has the 0182 # import libraries in its "Config" subdirectory 0183 if os.name == 'os2': 0184 self.library_dirs.append(os.path.join(sys.exec_prefix, 'Config')) 0185 0186 # for extensions under Cygwin and AtheOS Python's library directory must be 0187 # appended to library_dirs 0188 if sys.platform[:6] == 'cygwin' or sys.platform[:6] == 'atheos': 0189 if string.find(sys.executable, sys.exec_prefix) != -1: 0190 # building third party extensions 0191 self.library_dirs.append(os.path.join(sys.prefix, "lib", 0192 "python" + get_python_version(), 0193 "config")) 0194 else: 0195 # building python standard extensions 0196 self.library_dirs.append('.') 0197 0198 # The argument parsing will result in self.define being a string, but 0199 # it has to be a list of 2-tuples. All the preprocessor symbols 0200 # specified by the 'define' option will be set to '1'. Multiple 0201 # symbols can be separated with commas. 0202 0203 if self.define: 0204 defines = string.split(self.define, ',') 0205 self.define = map(lambda symbol: (symbol, '1'), defines) 0206 0207 # The option for macros to undefine is also a string from the 0208 # option parsing, but has to be a list. Multiple symbols can also 0209 # be separated with commas here. 0210 if self.undef: 0211 self.undef = string.split(self.undef, ',') 0212 0213 if self.swig_opts is None: 0214 self.swig_opts = [] 0215 else: 0216 self.swig_opts = self.swig_opts.split(' ') 0217 0218 # finalize_options () 0219 0220 0221 def run (self): 0222 0223 from distutils.ccompiler import new_compiler 0224 0225 # 'self.extensions', as supplied by setup.py, is a list of 0226 # Extension instances. See the documentation for Extension (in 0227 # distutils.extension) for details. 0228 # 0229 # For backwards compatibility with Distutils 0.8.2 and earlier, we 0230 # also allow the 'extensions' list to be a list of tuples: 0231 # (ext_name, build_info) 0232 # where build_info is a dictionary containing everything that 0233 # Extension instances do except the name, with a few things being 0234 # differently named. We convert these 2-tuples to Extension 0235 # instances as needed. 0236 0237 if not self.extensions: 0238 return 0239 0240 # If we were asked to build any C/C++ libraries, make sure that the 0241 # directory where we put them is in the library search path for 0242 # linking extensions. 0243 if self.distribution.has_c_libraries(): 0244 build_clib = self.get_finalized_command('build_clib') 0245 self.libraries.extend(build_clib.get_library_names() or []) 0246 self.library_dirs.append(build_clib.build_clib) 0247 0248 # Setup the CCompiler object that we'll use to do all the 0249 # compiling and linking 0250 self.compiler = new_compiler(compiler=self.compiler, 0251 verbose=self.verbose, 0252 dry_run=self.dry_run, 0253 force=self.force) 0254 customize_compiler(self.compiler) 0255 0256 # And make sure that any compile/link-related options (which might 0257 # come from the command-line or from the setup script) are set in 0258 # that CCompiler object -- that way, they automatically apply to 0259 # all compiling and linking done here. 0260 if self.include_dirs is not None: 0261 self.compiler.set_include_dirs(self.include_dirs) 0262 if self.define is not None: 0263 # 'define' option is a list of (name,value) tuples 0264 for (name,value) in self.define: 0265 self.compiler.define_macro(name, value) 0266 if self.undef is not None: 0267 for macro in self.undef: 0268 self.compiler.undefine_macro(macro) 0269 if self.libraries is not None: 0270 self.compiler.set_libraries(self.libraries) 0271 if self.library_dirs is not None: 0272 self.compiler.set_library_dirs(self.library_dirs) 0273 if self.rpath is not None: 0274 self.compiler.set_runtime_library_dirs(self.rpath) 0275 if self.link_objects is not None: 0276 self.compiler.set_link_objects(self.link_objects) 0277 0278 # Now actually compile and link everything. 0279 self.build_extensions() 0280 0281 # run () 0282 0283 0284 def check_extensions_list (self, extensions): 0285 """Ensure that the list of extensions (presumably provided as a 0286 command option 'extensions') is valid, i.e. it is a list of 0287 Extension objects. We also support the old-style list of 2-tuples, 0288 where the tuples are (ext_name, build_info), which are converted to 0289 Extension instances here. 0290 0291 Raise DistutilsSetupError if the structure is invalid anywhere; 0292 just returns otherwise. 0293 """ 0294 if type(extensions) is not ListType: 0295 raise DistutilsSetupError, \ 0296 "'ext_modules' option must be a list of Extension instances" 0297 0298 for i in range(len(extensions)): 0299 ext = extensions[i] 0300 if isinstance(ext, Extension): 0301 continue # OK! (assume type-checking done 0302 # by Extension constructor) 0303 0304 (ext_name, build_info) = ext 0305 log.warn(("old-style (ext_name, build_info) tuple found in " 0306 "ext_modules for extension '%s'" 0307 "-- please convert to Extension instance" % ext_name)) 0308 if type(ext) is not TupleType and len(ext) != 2: 0309 raise DistutilsSetupError, \ 0310 ("each element of 'ext_modules' option must be an " 0311 "Extension instance or 2-tuple") 0312 0313 if not (type(ext_name) is StringType and 0314 extension_name_re.match(ext_name)): 0315 raise DistutilsSetupError, \ 0316 ("first element of each tuple in 'ext_modules' " 0317 "must be the extension name (a string)") 0318 0319 if type(build_info) is not DictionaryType: 0320 raise DistutilsSetupError, \ 0321 ("second element of each tuple in 'ext_modules' " 0322 "must be a dictionary (build info)") 0323 0324 # OK, the (ext_name, build_info) dict is type-safe: convert it 0325 # to an Extension instance. 0326 ext = Extension(ext_name, build_info['sources']) 0327 0328 # Easy stuff: one-to-one mapping from dict elements to 0329 # instance attributes. 0330 for key in ('include_dirs', 0331 'library_dirs', 0332 'libraries', 0333 'extra_objects', 0334 'extra_compile_args', 0335 'extra_link_args'): 0336 val = build_info.get(key) 0337 if val is not None: 0338 setattr(ext, key, val) 0339 0340 # Medium-easy stuff: same syntax/semantics, different names. 0341 ext.runtime_library_dirs = build_info.get('rpath') 0342 if build_info.has_key('def_file'): 0343 log.warn("'def_file' element of build info dict " 0344 "no longer supported") 0345 0346 # Non-trivial stuff: 'macros' split into 'define_macros' 0347 # and 'undef_macros'. 0348 macros = build_info.get('macros') 0349 if macros: 0350 ext.define_macros = [] 0351 ext.undef_macros = [] 0352 for macro in macros: 0353 if not (type(macro) is TupleType and 0354 1 <= len(macro) <= 2): 0355 raise DistutilsSetupError, \ 0356 ("'macros' element of build info dict " 0357 "must be 1- or 2-tuple") 0358 if len(macro) == 1: 0359 ext.undef_macros.append(macro[0]) 0360 elif len(macro) == 2: 0361 ext.define_macros.append(macro) 0362 0363 extensions[i] = ext 0364 0365 # for extensions 0366 0367 # check_extensions_list () 0368 0369 0370 def get_source_files (self): 0371 self.check_extensions_list(self.extensions) 0372 filenames = [] 0373 0374 # Wouldn't it be neat if we knew the names of header files too... 0375 for ext in self.extensions: 0376 filenames.extend(ext.sources) 0377 0378 return filenames 0379 0380 0381 def get_outputs (self): 0382 0383 # Sanity check the 'extensions' list -- can't assume this is being 0384 # done in the same run as a 'build_extensions()' call (in fact, we 0385 # can probably assume that it *isn't*!). 0386 self.check_extensions_list(self.extensions) 0387 0388 # And build the list of output (built) filenames. Note that this 0389 # ignores the 'inplace' flag, and assumes everything goes in the 0390 # "build" tree. 0391 outputs = [] 0392 for ext in self.extensions: 0393 fullname = self.get_ext_fullname(ext.name) 0394 outputs.append(os.path.join(self.build_lib, 0395 self.get_ext_filename(fullname))) 0396 return outputs 0397 0398 # get_outputs () 0399 0400 def build_extensions(self): 0401 # First, sanity-check the 'extensions' list 0402 self.check_extensions_list(self.extensions) 0403 0404 for ext in self.extensions: 0405 self.build_extension(ext) 0406 0407 def build_extension(self, ext): 0408 sources = ext.sources 0409 if sources is None or type(sources) not in (ListType, TupleType): 0410 raise DistutilsSetupError, \ 0411 ("in 'ext_modules' option (extension '%s'), " + 0412 "'sources' must be present and must be " + 0413 "a list of source filenames") % ext.name 0414 sources = list(sources) 0415 0416 fullname = self.get_ext_fullname(ext.name) 0417 if self.inplace: 0418 # ignore build-lib -- put the compiled extension into 0419 # the source tree along with pure Python modules 0420 0421 modpath = string.split(fullname, '.') 0422 package = string.join(modpath[0:-1], '.') 0423 base = modpath[-1] 0424 0425 build_py = self.get_finalized_command('build_py') 0426 package_dir = build_py.get_package_dir(package) 0427 ext_filename = os.path.join(package_dir, 0428 self.get_ext_filename(base)) 0429 else: 0430 ext_filename = os.path.join(self.build_lib, 0431 self.get_ext_filename(fullname)) 0432 depends = sources + ext.depends 0433 if not (self.force or newer_group(depends, ext_filename, 'newer')): 0434 log.debug("skipping '%s' extension (up-to-date)", ext.name) 0435 return 0436 else: 0437 log.info("building '%s' extension", ext.name) 0438 0439 # First, scan the sources for SWIG definition files (.i), run 0440 # SWIG on 'em to create .c files, and modify the sources list 0441 # accordingly. 0442 sources = self.swig_sources(sources, ext) 0443 0444 # Next, compile the source code to object files. 0445 0446 # XXX not honouring 'define_macros' or 'undef_macros' -- the 0447 # CCompiler API needs to change to accommodate this, and I 0448 # want to do one thing at a time! 0449 0450 # Two possible sources for extra compiler arguments: 0451 # - 'extra_compile_args' in Extension object 0452 # - CFLAGS environment variable (not particularly 0453 # elegant, but people seem to expect it and I 0454 # guess it's useful) 0455 # The environment variable should take precedence, and 0456 # any sensible compiler will give precedence to later 0457 # command line args. Hence we combine them in order: 0458 extra_args = ext.extra_compile_args or [] 0459 0460 macros = ext.define_macros[:] 0461 for undef in ext.undef_macros: 0462 macros.append((undef,)) 0463 0464 objects = self.compiler.compile(sources, 0465 output_dir=self.build_temp, 0466 macros=macros, 0467 include_dirs=ext.include_dirs, 0468 debug=self.debug, 0469 extra_postargs=extra_args, 0470 depends=ext.depends) 0471 0472 # XXX -- this is a Vile HACK! 0473 # 0474 # The setup.py script for Python on Unix needs to be able to 0475 # get this list so it can perform all the clean up needed to 0476 # avoid keeping object files around when cleaning out a failed 0477 # build of an extension module. Since Distutils does not 0478 # track dependencies, we have to get rid of intermediates to 0479 # ensure all the intermediates will be properly re-built. 0480 # 0481 self._built_objects = objects[:] 0482 0483 # Now link the object files together into a "shared object" -- 0484 # of course, first we have to figure out all the other things 0485 # that go into the mix. 0486 if ext.extra_objects: 0487 objects.extend(ext.extra_objects) 0488 extra_args = ext.extra_link_args or [] 0489 0490 # Detect target language, if not provided 0491 language = ext.language or self.compiler.detect_language(sources) 0492 0493 self.compiler.link_shared_object( 0494 objects, ext_filename, 0495 libraries=self.get_libraries(ext), 0496 library_dirs=ext.library_dirs, 0497 runtime_library_dirs=ext.runtime_library_dirs, 0498 extra_postargs=extra_args, 0499 export_symbols=self.get_export_symbols(ext), 0500 debug=self.debug, 0501 build_temp=self.build_temp, 0502 target_lang=language) 0503 0504 0505 def swig_sources (self, sources, extension): 0506 0507 """Walk the list of source files in 'sources', looking for SWIG 0508 interface (.i) files. Run SWIG on all that are found, and 0509 return a modified 'sources' list with SWIG source files replaced 0510 by the generated C (or C++) files. 0511 """ 0512 0513 new_sources = [] 0514 swig_sources = [] 0515 swig_targets = {} 0516 0517 # XXX this drops generated C/C++ files into the source tree, which 0518 # is fine for developers who want to distribute the generated 0519 # source -- but there should be an option to put SWIG output in 0520 # the temp dir. 0521 0522 if self.swig_cpp: 0523 log.warn("--swig-cpp is deprecated - use --swig-opts=-c++") 0524 0525 if self.swig_cpp or ('-c++' in self.swig_opts): 0526 target_ext = '.cpp' 0527 else: 0528 target_ext = '.c' 0529 0530 for source in sources: 0531 (base, ext) = os.path.splitext(source) 0532 if ext == ".i": # SWIG interface file 0533 new_sources.append(base + '_wrap' + target_ext) 0534 swig_sources.append(source) 0535 swig_targets[source] = new_sources[-1] 0536 else: 0537 new_sources.append(source) 0538 0539 if not swig_sources: 0540 return new_sources 0541 0542 swig = self.swig or self.find_swig() 0543 swig_cmd = [swig, "-python"] 0544 swig_cmd.extend(self.swig_opts) 0545 if self.swig_cpp: 0546 swig_cmd.append("-c++") 0547 0548 # Do not override commandline arguments 0549 if not self.swig_opts: 0550 for o in extension.swig_opts: 0551 swig_cmd.append(o) 0552 0553 for source in swig_sources: 0554 target = swig_targets[source] 0555 log.info("swigging %s to %s", source, target) 0556 self.spawn(swig_cmd + ["-o", target, source]) 0557 0558 return new_sources 0559 0560 # swig_sources () 0561 0562 def find_swig (self): 0563 """Return the name of the SWIG executable. On Unix, this is 0564 just "swig" -- it should be in the PATH. Tries a bit harder on 0565 Windows. 0566 """ 0567 0568 if os.name == "posix": 0569 return "swig" 0570 elif os.name == "nt": 0571 0572 # Look for SWIG in its standard installation directory on 0573 # Windows (or so I presume!). If we find it there, great; 0574 # if not, act like Unix and assume it's in the PATH. 0575 for vers in ("1.3", "1.2", "1.1"): 0576 fn = os.path.join("c:\\swig%s" % vers, "swig.exe") 0577 if os.path.isfile(fn): 0578 return fn 0579 else: 0580 return "swig.exe" 0581 0582 elif os.name == "os2": 0583 # assume swig available in the PATH. 0584 return "swig.exe" 0585 0586 else: 0587 raise DistutilsPlatformError, \ 0588 ("I don't know how to find (much less run) SWIG " 0589 "on platform '%s'") % os.name 0590 0591 # find_swig () 0592 0593 # -- Name generators ----------------------------------------------- 0594 # (extension names, filenames, whatever) 0595 0596 def get_ext_fullname (self, ext_name): 0597 if self.package is None: 0598 return ext_name 0599 else: 0600 return self.package + '.' + ext_name 0601 0602 def get_ext_filename (self, ext_name): 0603 r"""Convert the name of an extension (eg. "foo.bar") into the name 0604 of the file from which it will be loaded (eg. "foo/bar.so", or 0605 "foo\bar.pyd"). 0606 """ 0607 0608 from distutils.sysconfig import get_config_var 0609 ext_path = string.split(ext_name, '.') 0610 # OS/2 has an 8 character module (extension) limit :-( 0611 if os.name == "os2": 0612 ext_path[len(ext_path) - 1] = ext_path[len(ext_path) - 1][:8] 0613 # extensions in debug_mode are named 'module_d.pyd' under windows 0614 so_ext = get_config_var('SO') 0615 if os.name == 'nt' and self.debug: 0616 return apply(os.path.join, ext_path) + '_d' + so_ext 0617 return apply(os.path.join, ext_path) + so_ext 0618 0619 def get_export_symbols (self, ext): 0620 """Return the list of symbols that a shared extension has to 0621 export. This either uses 'ext.export_symbols' or, if it's not 0622 provided, "init" + module_name. Only relevant on Windows, where 0623 the .pyd file (DLL) must export the module "init" function. 0624 """ 0625 0626 initfunc_name = "init" + string.split(ext.name,'.')[-1] 0627 if initfunc_name not in ext.export_symbols: 0628 ext.export_symbols.append(initfunc_name) 0629 return ext.export_symbols 0630 0631 def get_libraries (self, ext): 0632 """Return the list of libraries to link against when building a 0633 shared extension. On most platforms, this is just 'ext.libraries'; 0634 on Windows and OS/2, we add the Python library (eg. python20.dll). 0635 """ 0636 # The python library is always needed on Windows. For MSVC, this 0637 # is redundant, since the library is mentioned in a pragma in 0638 # pyconfig.h that MSVC groks. The other Windows compilers all seem 0639 # to need it mentioned explicitly, though, so that's what we do. 0640 # Append '_d' to the python import library on debug builds. 0641 if sys.platform == "win32": 0642 from distutils.msvccompiler import MSVCCompiler 0643 if not isinstance(self.compiler, MSVCCompiler): 0644 template = "python%d%d" 0645 if self.debug: 0646 template = template + '_d' 0647 pythonlib = (template % 0648 (sys.hexversion >> 24, (sys.hexversion >> 16) & 0xff)) 0649 # don't extend ext.libraries, it may be shared with other 0650 # extensions, it is a reference to the original list 0651 return ext.libraries + [pythonlib] 0652 else: 0653 return ext.libraries 0654 elif sys.platform == "os2emx": 0655 # EMX/GCC requires the python library explicitly, and I 0656 # believe VACPP does as well (though not confirmed) - AIM Apr01 0657 template = "python%d%d" 0658 # debug versions of the main DLL aren't supported, at least 0659 # not at this time - AIM Apr01 0660 #if self.debug: 0661 # template = template + '_d' 0662 pythonlib = (template % 0663 (sys.hexversion >> 24, (sys.hexversion >> 16) & 0xff)) 0664 # don't extend ext.libraries, it may be shared with other 0665 # extensions, it is a reference to the original list 0666 return ext.libraries + [pythonlib] 0667 elif sys.platform[:6] == "cygwin": 0668 template = "python%d.%d" 0669 pythonlib = (template % 0670 (sys.hexversion >> 24, (sys.hexversion >> 16) & 0xff)) 0671 # don't extend ext.libraries, it may be shared with other 0672 # extensions, it is a reference to the original list 0673 return ext.libraries + [pythonlib] 0674 elif sys.platform[:6] == "atheos": 0675 from distutils import sysconfig 0676 0677 template = "python%d.%d" 0678 pythonlib = (template % 0679 (sys.hexversion >> 24, (sys.hexversion >> 16) & 0xff)) 0680 # Get SHLIBS from Makefile 0681 extra = [] 0682 for lib in sysconfig.get_config_var('SHLIBS').split(): 0683 if lib.startswith('-l'): 0684 extra.append(lib[2:]) 0685 else: 0686 extra.append(lib) 0687 # don't extend ext.libraries, it may be shared with other 0688 # extensions, it is a reference to the original list 0689 return ext.libraries + [pythonlib, "m"] + extra 0690 else: 0691 return ext.libraries 0692 0693 # class build_ext 0694
Generated by PyXR 0.9.4