PyXR

c:\python24\lib \ distutils \ command \ build.py



0001 """distutils.command.build
0002 
0003 Implements the Distutils 'build' command."""
0004 
0005 # This module should be kept compatible with Python 1.5.2.
0006 
0007 __revision__ = "$Id: build.py,v 1.35 2004/08/25 11:37:43 loewis Exp $"
0008 
0009 import sys, os
0010 from distutils.core import Command
0011 from distutils.util import get_platform
0012 
0013 
0014 def show_compilers ():
0015     from distutils.ccompiler import show_compilers
0016     show_compilers()
0017 
0018 
0019 class build (Command):
0020 
0021     description = "build everything needed to install"
0022 
0023     user_options = [
0024         ('build-base=', 'b',
0025          "base directory for build library"),
0026         ('build-purelib=', None,
0027          "build directory for platform-neutral distributions"),
0028         ('build-platlib=', None,
0029          "build directory for platform-specific distributions"),
0030         ('build-lib=', None,
0031          "build directory for all distribution (defaults to either " +
0032          "build-purelib or build-platlib"),
0033         ('build-scripts=', None,
0034          "build directory for scripts"),
0035         ('build-temp=', 't',
0036          "temporary build directory"),
0037         ('compiler=', 'c',
0038          "specify the compiler type"),
0039         ('debug', 'g',
0040          "compile extensions and libraries with debugging information"),
0041         ('force', 'f',
0042          "forcibly build everything (ignore file timestamps)"),
0043         ('executable=', 'e',
0044          "specify final destination interpreter path (build.py)"),
0045         ]
0046 
0047     boolean_options = ['debug', 'force']
0048 
0049     help_options = [
0050         ('help-compiler', None,
0051          "list available compilers", show_compilers),
0052         ]
0053 
0054     def initialize_options (self):
0055         self.build_base = 'build'
0056         # these are decided only after 'build_base' has its final value
0057         # (unless overridden by the user or client)
0058         self.build_purelib = None
0059         self.build_platlib = None
0060         self.build_lib = None
0061         self.build_temp = None
0062         self.build_scripts = None
0063         self.compiler = None
0064         self.debug = None
0065         self.force = 0
0066         self.executable = None
0067 
0068     def finalize_options (self):
0069 
0070         plat_specifier = ".%s-%s" % (get_platform(), sys.version[0:3])
0071 
0072         # 'build_purelib' and 'build_platlib' just default to 'lib' and
0073         # 'lib.<plat>' under the base build directory.  We only use one of
0074         # them for a given distribution, though --
0075         if self.build_purelib is None:
0076             self.build_purelib = os.path.join(self.build_base, 'lib')
0077         if self.build_platlib is None:
0078             self.build_platlib = os.path.join(self.build_base,
0079                                               'lib' + plat_specifier)
0080 
0081         # 'build_lib' is the actual directory that we will use for this
0082         # particular module distribution -- if user didn't supply it, pick
0083         # one of 'build_purelib' or 'build_platlib'.
0084         if self.build_lib is None:
0085             if self.distribution.ext_modules:
0086                 self.build_lib = self.build_platlib
0087             else:
0088                 self.build_lib = self.build_purelib
0089 
0090         # 'build_temp' -- temporary directory for compiler turds,
0091         # "build/temp.<plat>"
0092         if self.build_temp is None:
0093             self.build_temp = os.path.join(self.build_base,
0094                                            'temp' + plat_specifier)
0095         if self.build_scripts is None:
0096             self.build_scripts = os.path.join(self.build_base,
0097                                               'scripts-' + sys.version[0:3])
0098 
0099         if self.executable is None:
0100             self.executable = os.path.normpath(sys.executable)
0101     # finalize_options ()
0102 
0103 
0104     def run (self):
0105 
0106         # Run all relevant sub-commands.  This will be some subset of:
0107         #  - build_py      - pure Python modules
0108         #  - build_clib    - standalone C libraries
0109         #  - build_ext     - Python extensions
0110         #  - build_scripts - (Python) scripts
0111         for cmd_name in self.get_sub_commands():
0112             self.run_command(cmd_name)
0113 
0114 
0115     # -- Predicates for the sub-command list ---------------------------
0116 
0117     def has_pure_modules (self):
0118         return self.distribution.has_pure_modules()
0119 
0120     def has_c_libraries (self):
0121         return self.distribution.has_c_libraries()
0122 
0123     def has_ext_modules (self):
0124         return self.distribution.has_ext_modules()
0125 
0126     def has_scripts (self):
0127         return self.distribution.has_scripts()
0128 
0129 
0130     sub_commands = [('build_py',      has_pure_modules),
0131                     ('build_clib',    has_c_libraries),
0132                     ('build_ext',     has_ext_modules),
0133                     ('build_scripts', has_scripts),
0134                    ]
0135 
0136 # class build
0137 

Generated by PyXR 0.9.4
SourceForge.net Logo