symbian-qemu-0.9.1-12/python-win32-2.6.1/lib/distutils/command/bdist_dumb.py
changeset 1 2fb8b9db1c86
equal deleted inserted replaced
0:ffa851df0825 1:2fb8b9db1c86
       
     1 """distutils.command.bdist_dumb
       
     2 
       
     3 Implements the Distutils 'bdist_dumb' command (create a "dumb" built
       
     4 distribution -- i.e., just an archive to be unpacked under $prefix or
       
     5 $exec_prefix)."""
       
     6 
       
     7 # This module should be kept compatible with Python 2.1.
       
     8 
       
     9 __revision__ = "$Id: bdist_dumb.py 61000 2008-02-23 17:40:11Z christian.heimes $"
       
    10 
       
    11 import os
       
    12 from distutils.core import Command
       
    13 from distutils.util import get_platform
       
    14 from distutils.dir_util import remove_tree, ensure_relative
       
    15 from distutils.errors import *
       
    16 from distutils.sysconfig import get_python_version
       
    17 from distutils import log
       
    18 
       
    19 class bdist_dumb (Command):
       
    20 
       
    21     description = "create a \"dumb\" built distribution"
       
    22 
       
    23     user_options = [('bdist-dir=', 'd',
       
    24                      "temporary directory for creating the distribution"),
       
    25                     ('plat-name=', 'p',
       
    26                      "platform name to embed in generated filenames "
       
    27                      "(default: %s)" % get_platform()),
       
    28                     ('format=', 'f',
       
    29                      "archive format to create (tar, ztar, gztar, zip)"),
       
    30                     ('keep-temp', 'k',
       
    31                      "keep the pseudo-installation tree around after " +
       
    32                      "creating the distribution archive"),
       
    33                     ('dist-dir=', 'd',
       
    34                      "directory to put final built distributions in"),
       
    35                     ('skip-build', None,
       
    36                      "skip rebuilding everything (for testing/debugging)"),
       
    37                     ('relative', None,
       
    38                      "build the archive using relative paths"
       
    39                      "(default: false)"),
       
    40                    ]
       
    41 
       
    42     boolean_options = ['keep-temp', 'skip-build', 'relative']
       
    43 
       
    44     default_format = { 'posix': 'gztar',
       
    45                        'nt': 'zip',
       
    46                        'os2': 'zip' }
       
    47 
       
    48 
       
    49     def initialize_options (self):
       
    50         self.bdist_dir = None
       
    51         self.plat_name = None
       
    52         self.format = None
       
    53         self.keep_temp = 0
       
    54         self.dist_dir = None
       
    55         self.skip_build = 0
       
    56         self.relative = 0
       
    57 
       
    58     # initialize_options()
       
    59 
       
    60 
       
    61     def finalize_options (self):
       
    62 
       
    63         if self.bdist_dir is None:
       
    64             bdist_base = self.get_finalized_command('bdist').bdist_base
       
    65             self.bdist_dir = os.path.join(bdist_base, 'dumb')
       
    66 
       
    67         if self.format is None:
       
    68             try:
       
    69                 self.format = self.default_format[os.name]
       
    70             except KeyError:
       
    71                 raise DistutilsPlatformError, \
       
    72                       ("don't know how to create dumb built distributions " +
       
    73                        "on platform %s") % os.name
       
    74 
       
    75         self.set_undefined_options('bdist',
       
    76                                    ('dist_dir', 'dist_dir'),
       
    77                                    ('plat_name', 'plat_name'))
       
    78 
       
    79     # finalize_options()
       
    80 
       
    81 
       
    82     def run (self):
       
    83 
       
    84         if not self.skip_build:
       
    85             self.run_command('build')
       
    86 
       
    87         install = self.reinitialize_command('install', reinit_subcommands=1)
       
    88         install.root = self.bdist_dir
       
    89         install.skip_build = self.skip_build
       
    90         install.warn_dir = 0
       
    91 
       
    92         log.info("installing to %s" % self.bdist_dir)
       
    93         self.run_command('install')
       
    94 
       
    95         # And make an archive relative to the root of the
       
    96         # pseudo-installation tree.
       
    97         archive_basename = "%s.%s" % (self.distribution.get_fullname(),
       
    98                                       self.plat_name)
       
    99 
       
   100         # OS/2 objects to any ":" characters in a filename (such as when
       
   101         # a timestamp is used in a version) so change them to hyphens.
       
   102         if os.name == "os2":
       
   103             archive_basename = archive_basename.replace(":", "-")
       
   104 
       
   105         pseudoinstall_root = os.path.join(self.dist_dir, archive_basename)
       
   106         if not self.relative:
       
   107             archive_root = self.bdist_dir
       
   108         else:
       
   109             if (self.distribution.has_ext_modules() and
       
   110                 (install.install_base != install.install_platbase)):
       
   111                 raise DistutilsPlatformError, \
       
   112                       ("can't make a dumb built distribution where "
       
   113                        "base and platbase are different (%s, %s)"
       
   114                        % (repr(install.install_base),
       
   115                           repr(install.install_platbase)))
       
   116             else:
       
   117                 archive_root = os.path.join(self.bdist_dir,
       
   118                                    ensure_relative(install.install_base))
       
   119 
       
   120         # Make the archive
       
   121         filename = self.make_archive(pseudoinstall_root,
       
   122                                      self.format, root_dir=archive_root)
       
   123         if self.distribution.has_ext_modules():
       
   124             pyversion = get_python_version()
       
   125         else:
       
   126             pyversion = 'any'
       
   127         self.distribution.dist_files.append(('bdist_dumb', pyversion,
       
   128                                              filename))
       
   129 
       
   130         if not self.keep_temp:
       
   131             remove_tree(self.bdist_dir, dry_run=self.dry_run)
       
   132 
       
   133     # run()
       
   134 
       
   135 # class bdist_dumb