home *** CD-ROM | disk | FTP | other *** search
/ Chip 2011 November / CHIP_2011_11.iso / Programy / Narzedzia / Inkscape / Inkscape-0.48.2-1-win32.exe / python / Lib / distutils / command / build.py < prev    next >
Encoding:
Python Source  |  2010-05-29  |  5.6 KB  |  159 lines

  1. """distutils.command.build
  2.  
  3. Implements the Distutils 'build' command."""
  4.  
  5. # This module should be kept compatible with Python 2.1.
  6.  
  7. __revision__ = "$Id: build.py 62197 2008-04-07 01:53:39Z mark.hammond $"
  8.  
  9. import sys, os
  10. from distutils.core import Command
  11. from distutils.errors import DistutilsOptionError
  12. from distutils.util import get_platform
  13.  
  14.  
  15. def show_compilers ():
  16.     from distutils.ccompiler import show_compilers
  17.     show_compilers()
  18.  
  19.  
  20. class build (Command):
  21.  
  22.     description = "build everything needed to install"
  23.  
  24.     user_options = [
  25.         ('build-base=', 'b',
  26.          "base directory for build library"),
  27.         ('build-purelib=', None,
  28.          "build directory for platform-neutral distributions"),
  29.         ('build-platlib=', None,
  30.          "build directory for platform-specific distributions"),
  31.         ('build-lib=', None,
  32.          "build directory for all distribution (defaults to either " +
  33.          "build-purelib or build-platlib"),
  34.         ('build-scripts=', None,
  35.          "build directory for scripts"),
  36.         ('build-temp=', 't',
  37.          "temporary build directory"),
  38.         ('plat-name=', 'p',
  39.          "platform name to build for, if supported "
  40.          "(default: %s)" % get_platform()),
  41.         ('compiler=', 'c',
  42.          "specify the compiler type"),
  43.         ('debug', 'g',
  44.          "compile extensions and libraries with debugging information"),
  45.         ('force', 'f',
  46.          "forcibly build everything (ignore file timestamps)"),
  47.         ('executable=', 'e',
  48.          "specify final destination interpreter path (build.py)"),
  49.         ]
  50.  
  51.     boolean_options = ['debug', 'force']
  52.  
  53.     help_options = [
  54.         ('help-compiler', None,
  55.          "list available compilers", show_compilers),
  56.         ]
  57.  
  58.     def initialize_options (self):
  59.         self.build_base = 'build'
  60.         # these are decided only after 'build_base' has its final value
  61.         # (unless overridden by the user or client)
  62.         self.build_purelib = None
  63.         self.build_platlib = None
  64.         self.build_lib = None
  65.         self.build_temp = None
  66.         self.build_scripts = None
  67.         self.compiler = None
  68.         self.plat_name = None
  69.         self.debug = None
  70.         self.force = 0
  71.         self.executable = None
  72.  
  73.     def finalize_options (self):
  74.  
  75.         if self.plat_name is None:
  76.             self.plat_name = get_platform()
  77.         else:
  78.             # plat-name only supported for windows (other platforms are
  79.             # supported via ./configure flags, if at all).  Avoid misleading
  80.             # other platforms.
  81.             if os.name != 'nt':
  82.                 raise DistutilsOptionError(
  83.                             "--plat-name only supported on Windows (try "
  84.                             "using './configure --help' on your platform)")
  85.  
  86.         plat_specifier = ".%s-%s" % (self.plat_name, sys.version[0:3])
  87.  
  88.         # Make it so Python 2.x and Python 2.x with --with-pydebug don't
  89.         # share the same build directories. Doing so confuses the build
  90.         # process for C modules
  91.         if hasattr(sys, 'gettotalrefcount'):
  92.             plat_specifier += '-pydebug'
  93.  
  94.         # 'build_purelib' and 'build_platlib' just default to 'lib' and
  95.         # 'lib.<plat>' under the base build directory.  We only use one of
  96.         # them for a given distribution, though --
  97.         if self.build_purelib is None:
  98.             self.build_purelib = os.path.join(self.build_base, 'lib')
  99.         if self.build_platlib is None:
  100.             self.build_platlib = os.path.join(self.build_base,
  101.                                               'lib' + plat_specifier)
  102.  
  103.         # 'build_lib' is the actual directory that we will use for this
  104.         # particular module distribution -- if user didn't supply it, pick
  105.         # one of 'build_purelib' or 'build_platlib'.
  106.         if self.build_lib is None:
  107.             if self.distribution.ext_modules:
  108.                 self.build_lib = self.build_platlib
  109.             else:
  110.                 self.build_lib = self.build_purelib
  111.  
  112.         # 'build_temp' -- temporary directory for compiler turds,
  113.         # "build/temp.<plat>"
  114.         if self.build_temp is None:
  115.             self.build_temp = os.path.join(self.build_base,
  116.                                            'temp' + plat_specifier)
  117.         if self.build_scripts is None:
  118.             self.build_scripts = os.path.join(self.build_base,
  119.                                               'scripts-' + sys.version[0:3])
  120.  
  121.         if self.executable is None:
  122.             self.executable = os.path.normpath(sys.executable)
  123.     # finalize_options ()
  124.  
  125.  
  126.     def run (self):
  127.  
  128.         # Run all relevant sub-commands.  This will be some subset of:
  129.         #  - build_py      - pure Python modules
  130.         #  - build_clib    - standalone C libraries
  131.         #  - build_ext     - Python extensions
  132.         #  - build_scripts - (Python) scripts
  133.         for cmd_name in self.get_sub_commands():
  134.             self.run_command(cmd_name)
  135.  
  136.  
  137.     # -- Predicates for the sub-command list ---------------------------
  138.  
  139.     def has_pure_modules (self):
  140.         return self.distribution.has_pure_modules()
  141.  
  142.     def has_c_libraries (self):
  143.         return self.distribution.has_c_libraries()
  144.  
  145.     def has_ext_modules (self):
  146.         return self.distribution.has_ext_modules()
  147.  
  148.     def has_scripts (self):
  149.         return self.distribution.has_scripts()
  150.  
  151.  
  152.     sub_commands = [('build_py',      has_pure_modules),
  153.                     ('build_clib',    has_c_libraries),
  154.                     ('build_ext',     has_ext_modules),
  155.                     ('build_scripts', has_scripts),
  156.                    ]
  157.  
  158. # class build
  159.