NovaBryan/EVE_Dump
Log | Files | 📦 下载最新源码 (.zip) | Refs | README

bdist.py (4006B)


      1 #Embedded file name: C:\BuildAgent\work\20d73f1b24eed06e\eve\release\V24.01\carbon\common\stdlib\distutils\command\bdist.py
      2 __revision__ = '$Id: bdist.py 82110 2010-06-20 13:38:51Z kristjan.jonsson $'
      3 import os
      4 from distutils.util import get_platform
      5 from distutils.core import Command
      6 from distutils.errors import DistutilsPlatformError, DistutilsOptionError
      7 
      8 def show_formats():
      9     from distutils.fancy_getopt import FancyGetopt
     10     formats = []
     11     for format in bdist.format_commands:
     12         formats.append(('formats=' + format, None, bdist.format_command[format][1]))
     13 
     14     pretty_printer = FancyGetopt(formats)
     15     pretty_printer.print_help('List of available distribution formats:')
     16 
     17 
     18 class bdist(Command):
     19     description = 'create a built (binary) distribution'
     20     user_options = [('bdist-base=', 'b', 'temporary directory for creating built distributions'),
     21      ('plat-name=', 'p', 'platform name to embed in generated filenames (default: %s)' % get_platform()),
     22      ('formats=', None, 'formats for distribution (comma-separated list)'),
     23      ('dist-dir=', 'd', 'directory to put final built distributions in [default: dist]'),
     24      ('skip-build', None, 'skip rebuilding everything (for testing/debugging)'),
     25      ('owner=', 'u', 'Owner name used when creating a tar file [default: current user]'),
     26      ('group=', 'g', 'Group name used when creating a tar file [default: current group]')]
     27     boolean_options = ['skip-build']
     28     help_options = [('help-formats',
     29       None,
     30       'lists available distribution formats',
     31       show_formats)]
     32     no_format_option = ('bdist_rpm',)
     33     default_format = {'posix': 'gztar',
     34      'nt': 'zip',
     35      'os2': 'zip'}
     36     format_commands = ['rpm',
     37      'gztar',
     38      'bztar',
     39      'ztar',
     40      'tar',
     41      'wininst',
     42      'zip',
     43      'msi']
     44     format_command = {'rpm': ('bdist_rpm', 'RPM distribution'),
     45      'gztar': ('bdist_dumb', "gzip'ed tar file"),
     46      'bztar': ('bdist_dumb', "bzip2'ed tar file"),
     47      'ztar': ('bdist_dumb', 'compressed tar file'),
     48      'tar': ('bdist_dumb', 'tar file'),
     49      'wininst': ('bdist_wininst', 'Windows executable installer'),
     50      'zip': ('bdist_dumb', 'ZIP file'),
     51      'msi': ('bdist_msi', 'Microsoft Installer')}
     52 
     53     def initialize_options(self):
     54         self.bdist_base = None
     55         self.plat_name = None
     56         self.formats = None
     57         self.dist_dir = None
     58         self.skip_build = 0
     59         self.group = None
     60         self.owner = None
     61 
     62     def finalize_options(self):
     63         if self.plat_name is None:
     64             if self.skip_build:
     65                 self.plat_name = get_platform()
     66             else:
     67                 self.plat_name = self.get_finalized_command('build').plat_name
     68         if self.bdist_base is None:
     69             build_base = self.get_finalized_command('build').build_base
     70             self.bdist_base = os.path.join(build_base, 'bdist.' + self.plat_name)
     71         self.ensure_string_list('formats')
     72         if self.formats is None:
     73             try:
     74                 self.formats = [self.default_format[os.name]]
     75             except KeyError:
     76                 raise DistutilsPlatformError, "don't know how to create built distributions " + 'on platform %s' % os.name
     77 
     78         if self.dist_dir is None:
     79             self.dist_dir = 'dist'
     80 
     81     def run(self):
     82         commands = []
     83         for format in self.formats:
     84             try:
     85                 commands.append(self.format_command[format][0])
     86             except KeyError:
     87                 raise DistutilsOptionError, "invalid format '%s'" % format
     88 
     89         for i in range(len(self.formats)):
     90             cmd_name = commands[i]
     91             sub_cmd = self.reinitialize_command(cmd_name)
     92             if cmd_name not in self.no_format_option:
     93                 sub_cmd.format = self.formats[i]
     94             if cmd_name == 'bdist_dumb':
     95                 sub_cmd.owner = self.owner
     96                 sub_cmd.group = self.group
     97             if cmd_name in commands[i + 1:]:
     98                 sub_cmd.keep_temp = 1
     99             self.run_command(cmd_name)