Ignore:
Timestamp:
Mar 19, 2014, 11:31:01 PM (11 years ago)
Author:
dmik
Message:

python: Merge vendor 2.7.6 to trunk.

Location:
python/trunk
Files:
22 edited
6 copied

Legend:

Unmodified
Added
Removed
  • python/trunk

  • python/trunk/Lib/distutils/command/__init__.py

    r2 r391  
    44commands."""
    55
    6 # This module should be kept compatible with Python 2.1.
    7 
    8 __revision__ = "$Id: __init__.py 71272 2009-04-05 21:21:05Z georg.brandl $"
     6__revision__ = "$Id$"
    97
    108__all__ = ['build',
     
    2624           'bdist_wininst',
    2725           'upload',
    28 
     26           'check',
    2927           # These two are reserved for future use:
    3028           #'bdist_sdux',
  • python/trunk/Lib/distutils/command/bdist.py

    r2 r391  
    44distribution)."""
    55
    6 # This module should be kept compatible with Python 2.1.
    7 
    8 __revision__ = "$Id: bdist.py 62197 2008-04-07 01:53:39Z mark.hammond $"
     6__revision__ = "$Id$"
    97
    108import os
    11 from types import *
     9
     10from distutils.util import get_platform
    1211from distutils.core import Command
    13 from distutils.errors import *
    14 from distutils.util import get_platform
     12from distutils.errors import DistutilsPlatformError, DistutilsOptionError
    1513
    1614
    17 def show_formats ():
     15def show_formats():
    1816    """Print list of available formats (arguments to "--format" option).
    1917    """
    2018    from distutils.fancy_getopt import FancyGetopt
    21     formats=[]
     19    formats = []
    2220    for format in bdist.format_commands:
    2321        formats.append(("formats=" + format, None,
     
    2725
    2826
    29 class bdist (Command):
     27class bdist(Command):
    3028
    3129    description = "create a built (binary) distribution"
     
    4341                    ('skip-build', None,
    4442                     "skip rebuilding everything (for testing/debugging)"),
     43                    ('owner=', 'u',
     44                     "Owner name used when creating a tar file"
     45                     " [default: current user]"),
     46                    ('group=', 'g',
     47                     "Group name used when creating a tar file"
     48                     " [default: current group]"),
    4549                   ]
    4650
     
    5357
    5458    # The following commands do not take a format option from bdist
    55     no_format_option = ('bdist_rpm',
    56                         #'bdist_sdux', 'bdist_pkgtool'
    57                         )
     59    no_format_option = ('bdist_rpm',)
    5860
    5961    # This won't do in reality: will need to distinguish RPM-ish Linux,
    6062    # Debian-ish Linux, Solaris, FreeBSD, ..., Windows, Mac OS.
    61     default_format = { 'posix': 'gztar',
    62                        'nt': 'zip',
    63                        'os2': 'zip', }
     63    default_format = {'posix': 'gztar',
     64                      'nt': 'zip',
     65                      'os2': 'zip'}
    6466
    6567    # Establish the preferred order (for the --help-formats option).
    6668    format_commands = ['rpm', 'gztar', 'bztar', 'ztar', 'tar',
    67                        'wininst', 'zip',
    68                        #'pkgtool', 'sdux'
    69                        ]
     69                       'wininst', 'zip', 'msi']
    7070
    7171    # And the real information.
    72     format_command = { 'rpm':   ('bdist_rpm',  "RPM distribution"),
    73                        'zip':   ('bdist_dumb', "ZIP file"),
    74                        'gztar': ('bdist_dumb', "gzip'ed tar file"),
    75                        'bztar': ('bdist_dumb', "bzip2'ed tar file"),
    76                        'ztar':  ('bdist_dumb', "compressed tar file"),
    77                        'tar':   ('bdist_dumb', "tar file"),
    78                        'wininst': ('bdist_wininst',
    79                                    "Windows executable installer"),
    80                        'zip':   ('bdist_dumb', "ZIP file"),
    81                        #'pkgtool': ('bdist_pkgtool',
    82                        #            "Solaris pkgtool distribution"),
    83                        #'sdux':  ('bdist_sdux', "HP-UX swinstall depot"),
     72    format_command = {'rpm':   ('bdist_rpm',  "RPM distribution"),
     73                      'gztar': ('bdist_dumb', "gzip'ed tar file"),
     74                      'bztar': ('bdist_dumb', "bzip2'ed tar file"),
     75                      'ztar':  ('bdist_dumb', "compressed tar file"),
     76                      'tar':   ('bdist_dumb', "tar file"),
     77                      'wininst': ('bdist_wininst',
     78                                  "Windows executable installer"),
     79                      'zip':   ('bdist_dumb', "ZIP file"),
     80                      'msi':   ('bdist_msi',  "Microsoft Installer")
    8481                      }
    8582
    8683
    87     def initialize_options (self):
     84    def initialize_options(self):
    8885        self.bdist_base = None
    8986        self.plat_name = None
     
    9188        self.dist_dir = None
    9289        self.skip_build = 0
     90        self.group = None
     91        self.owner = None
    9392
    94     # initialize_options()
    95 
    96 
    97     def finalize_options (self):
     93    def finalize_options(self):
    9894        # have to finalize 'plat_name' before 'bdist_base'
    9995        if self.plat_name is None:
     
    123119            self.dist_dir = "dist"
    124120
    125     # finalize_options()
    126 
    127     def run (self):
    128 
     121    def run(self):
    129122        # Figure out which sub-commands we need to run.
    130123        commands = []
     
    142135                sub_cmd.format = self.formats[i]
    143136
     137            # passing the owner and group names for tar archiving
     138            if cmd_name == 'bdist_dumb':
     139                sub_cmd.owner = self.owner
     140                sub_cmd.group = self.group
     141
    144142            # If we're going to need to run this command again, tell it to
    145143            # keep its temporary files around so subsequent runs go faster.
     
    147145                sub_cmd.keep_temp = 1
    148146            self.run_command(cmd_name)
    149 
    150     # run()
    151 
    152 # class bdist
  • python/trunk/Lib/distutils/command/bdist_dumb.py

    r2 r391  
    55$exec_prefix)."""
    66
    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 $"
     7__revision__ = "$Id$"
    108
    119import os
     10
     11from sysconfig import get_python_version
     12
     13from distutils.util import get_platform
    1214from distutils.core import Command
    13 from distutils.util import get_platform
    1415from distutils.dir_util import remove_tree, ensure_relative
    15 from distutils.errors import *
    16 from distutils.sysconfig import get_python_version
     16from distutils.errors import DistutilsPlatformError
    1717from distutils import log
    1818
    1919class bdist_dumb (Command):
    2020
    21     description = "create a \"dumb\" built distribution"
     21    description = 'create a "dumb" built distribution'
    2222
    2323    user_options = [('bdist-dir=', 'd',
     
    3838                     "build the archive using relative paths"
    3939                     "(default: false)"),
     40                    ('owner=', 'u',
     41                     "Owner name used when creating a tar file"
     42                     " [default: current user]"),
     43                    ('group=', 'g',
     44                     "Group name used when creating a tar file"
     45                     " [default: current group]"),
    4046                   ]
    4147
     
    5359        self.keep_temp = 0
    5460        self.dist_dir = None
    55         self.skip_build = 0
     61        self.skip_build = None
    5662        self.relative = 0
     63        self.owner = None
     64        self.group = None
    5765
    58     # initialize_options()
    59 
    60 
    61     def finalize_options (self):
    62 
     66    def finalize_options(self):
    6367        if self.bdist_dir is None:
    6468            bdist_base = self.get_finalized_command('bdist').bdist_base
     
    7579        self.set_undefined_options('bdist',
    7680                                   ('dist_dir', 'dist_dir'),
    77                                    ('plat_name', 'plat_name'))
     81                                   ('plat_name', 'plat_name'),
     82                                   ('skip_build', 'skip_build'))
    7883
    79     # finalize_options()
    80 
    81 
    82     def run (self):
    83 
     84    def run(self):
    8485        if not self.skip_build:
    8586            self.run_command('build')
     
    120121        # Make the archive
    121122        filename = self.make_archive(pseudoinstall_root,
    122                                      self.format, root_dir=archive_root)
     123                                     self.format, root_dir=archive_root,
     124                                     owner=self.owner, group=self.group)
    123125        if self.distribution.has_ext_modules():
    124126            pyversion = get_python_version()
     
    130132        if not self.keep_temp:
    131133            remove_tree(self.bdist_dir, dry_run=self.dry_run)
    132 
    133     # run()
    134 
    135 # class bdist_dumb
  • python/trunk/Lib/distutils/command/bdist_msi.py

    r2 r391  
    11# -*- coding: iso-8859-1 -*-
    2 # Copyright (C) 2005, 2006 Martin v. Löwis
     2# Copyright (C) 2005, 2006 Martin von Löwis
    33# Licensed to PSF under a Contributor Agreement.
    44# The bdist_wininst command proper
     
    77Implements the bdist_msi command.
    88"""
    9 
    109import sys, os
     10from sysconfig import get_python_version
     11
    1112from distutils.core import Command
    1213from distutils.dir_util import remove_tree
    13 from distutils.sysconfig import get_python_version
    1414from distutils.version import StrictVersion
    1515from distutils.errors import DistutilsOptionError
     16from distutils import log
    1617from distutils.util import get_platform
    17 from distutils import log
     18
    1819import msilib
    1920from msilib import schema, sequence, text
     
    2930        Dialog.__init__(self, *args)
    3031        ruler = self.h - 36
    31         bmwidth = 152*ruler/328
    3232        #if kw.get("bitmap", True):
    3333        #    self.bitmap("Bitmap", 0, 0, bmwidth, ruler, "PythonWin")
     
    118118                       'skip-build']
    119119
     120    all_versions = ['2.0', '2.1', '2.2', '2.3', '2.4',
     121                    '2.5', '2.6', '2.7', '2.8', '2.9',
     122                    '3.0', '3.1', '3.2', '3.3', '3.4',
     123                    '3.5', '3.6', '3.7', '3.8', '3.9']
     124    other_version = 'X'
     125
    120126    def initialize_options (self):
    121127        self.bdist_dir = None
     
    126132        self.target_version = None
    127133        self.dist_dir = None
    128         self.skip_build = 0
     134        self.skip_build = None
    129135        self.install_script = None
    130136        self.pre_install_script = None
     137        self.versions = None
    131138
    132139    def finalize_options (self):
     140        self.set_undefined_options('bdist', ('skip_build', 'skip_build'))
     141
    133142        if self.bdist_dir is None:
    134143            bdist_base = self.get_finalized_command('bdist').bdist_base
    135144            self.bdist_dir = os.path.join(bdist_base, 'msi')
     145
    136146        short_version = get_python_version()
     147        if (not self.target_version) and self.distribution.has_ext_modules():
     148            self.target_version = short_version
     149
    137150        if self.target_version:
     151            self.versions = [self.target_version]
    138152            if not self.skip_build and self.distribution.has_ext_modules()\
    139153               and self.target_version != short_version:
    140154                raise DistutilsOptionError, \
    141                       "target version can only be %s, or the '--skip_build'" \
     155                      "target version can only be %s, or the '--skip-build'" \
    142156                      " option must be specified" % (short_version,)
    143157        else:
    144             self.target_version = short_version
     158            self.versions = list(self.all_versions)
    145159
    146160        self.set_undefined_options('bdist',
     
    224238        # it sorts together with the other Python packages
    225239        # in Add-Remove-Programs (APR)
    226         product_name = "Python %s %s" % (self.target_version,
    227                        self.distribution.get_fullname())
     240        fullname = self.distribution.get_fullname()
     241        if self.target_version:
     242            product_name = "Python %s %s" % (self.target_version, fullname)
     243        else:
     244            product_name = "Python %s" % (fullname)
    228245        self.db = msilib.init_database(installer_name, schema,
    229246                product_name, msilib.gen_uuid(),
     
    246263
    247264        if hasattr(self.distribution, 'dist_files'):
    248             self.distribution.dist_files.append(('bdist_msi', self.target_version, fullname))
     265            tup = 'bdist_msi', self.target_version or 'any', fullname
     266            self.distribution.dist_files.append(tup)
    249267
    250268        if not self.keep_temp:
     
    254272        db = self.db
    255273        cab = msilib.CAB("distfiles")
    256         f = Feature(db, "default", "Default Feature", "Everything", 1, directory="TARGETDIR")
    257         f.set_current()
    258274        rootdir = os.path.abspath(self.bdist_dir)
     275
    259276        root = Directory(db, cab, None, rootdir, "TARGETDIR", "SourceDir")
     277        f = Feature(db, "Python", "Python", "Everything",
     278                    0, 1, directory="TARGETDIR")
     279
     280        items = [(f, root, '')]
     281        for version in self.versions + [self.other_version]:
     282            target = "TARGETDIR" + version
     283            name = default = "Python" + version
     284            desc = "Everything"
     285            if version is self.other_version:
     286                title = "Python from another location"
     287                level = 2
     288            else:
     289                title = "Python %s from registry" % version
     290                level = 1
     291            f = Feature(db, name, title, desc, 1, level, directory=target)
     292            dir = Directory(db, cab, root, rootdir, target, default)
     293            items.append((f, dir, version))
    260294        db.Commit()
    261         todo = [root]
    262         while todo:
    263             dir = todo.pop()
    264             for file in os.listdir(dir.absolute):
    265                 afile = os.path.join(dir.absolute, file)
    266                 if os.path.isdir(afile):
    267                     newdir = Directory(db, cab, dir, file, file, "%s|%s" % (dir.make_short(file), file))
    268                     todo.append(newdir)
    269                 else:
    270                     key = dir.add_file(file)
    271                     if file==self.install_script:
    272                         if self.install_script_key:
    273                             raise DistutilsOptionError, "Multiple files with name %s" % file
    274                         self.install_script_key = '[#%s]' % key
    275 
     295
     296        seen = {}
     297        for feature, dir, version in items:
     298            todo = [dir]
     299            while todo:
     300                dir = todo.pop()
     301                for file in os.listdir(dir.absolute):
     302                    afile = os.path.join(dir.absolute, file)
     303                    if os.path.isdir(afile):
     304                        short = "%s|%s" % (dir.make_short(file), file)
     305                        default = file + version
     306                        newdir = Directory(db, cab, dir, file, default, short)
     307                        todo.append(newdir)
     308                    else:
     309                        if not dir.component:
     310                            dir.start_component(dir.logical, feature, 0)
     311                        if afile not in seen:
     312                            key = seen[afile] = dir.add_file(file)
     313                            if file==self.install_script:
     314                                if self.install_script_key:
     315                                    raise DistutilsOptionError(
     316                                          "Multiple files with name %s" % file)
     317                                self.install_script_key = '[#%s]' % key
     318                        else:
     319                            key = seen[afile]
     320                            add_data(self.db, "DuplicateFile",
     321                                [(key + version, dir.component, key, None, dir.logical)])
     322            db.Commit()
    276323        cab.commit(db)
    277324
    278325    def add_find_python(self):
    279326        """Adds code to the installer to compute the location of Python.
    280         Properties PYTHON.MACHINE, PYTHON.USER, PYTHONDIR and PYTHON will be set
    281         in both the execute and UI sequences; PYTHONDIR will be set from
    282         PYTHON.USER if defined, else from PYTHON.MACHINE.
    283         PYTHON is PYTHONDIR\python.exe"""
    284         install_path = r"SOFTWARE\Python\PythonCore\%s\InstallPath" % self.target_version
    285         if msilib.Win64:
    286             # type: msidbLocatorTypeRawValue + msidbLocatorType64bit
    287             Type = 2+16
    288         else:
    289             Type = 2
    290         add_data(self.db, "RegLocator",
    291                 [("python.machine", 2, install_path, None, Type),
    292                  ("python.user", 1, install_path, None, Type)])
    293         add_data(self.db, "AppSearch",
    294                 [("PYTHON.MACHINE", "python.machine"),
    295                  ("PYTHON.USER", "python.user")])
    296         add_data(self.db, "CustomAction",
    297                 [("PythonFromMachine", 51+256, "PYTHONDIR", "[PYTHON.MACHINE]"),
    298                  ("PythonFromUser", 51+256, "PYTHONDIR", "[PYTHON.USER]"),
    299                  ("PythonExe", 51+256, "PYTHON", "[PYTHONDIR]\\python.exe"),
    300                  ("InitialTargetDir", 51+256, "TARGETDIR", "[PYTHONDIR]")])
    301         add_data(self.db, "InstallExecuteSequence",
    302                 [("PythonFromMachine", "PYTHON.MACHINE", 401),
    303                  ("PythonFromUser", "PYTHON.USER", 402),
    304                  ("PythonExe", None, 403),
    305                  ("InitialTargetDir", 'TARGETDIR=""', 404),
    306                 ])
    307         add_data(self.db, "InstallUISequence",
    308                 [("PythonFromMachine", "PYTHON.MACHINE", 401),
    309                  ("PythonFromUser", "PYTHON.USER", 402),
    310                  ("PythonExe", None, 403),
    311                  ("InitialTargetDir", 'TARGETDIR=""', 404),
    312                 ])
     327
     328        Properties PYTHON.MACHINE.X.Y and PYTHON.USER.X.Y will be set from the
     329        registry for each version of Python.
     330
     331        Properties TARGETDIRX.Y will be set from PYTHON.USER.X.Y if defined,
     332        else from PYTHON.MACHINE.X.Y.
     333
     334        Properties PYTHONX.Y will be set to TARGETDIRX.Y\\python.exe"""
     335
     336        start = 402
     337        for ver in self.versions:
     338            install_path = r"SOFTWARE\Python\PythonCore\%s\InstallPath" % ver
     339            machine_reg = "python.machine." + ver
     340            user_reg = "python.user." + ver
     341            machine_prop = "PYTHON.MACHINE." + ver
     342            user_prop = "PYTHON.USER." + ver
     343            machine_action = "PythonFromMachine" + ver
     344            user_action = "PythonFromUser" + ver
     345            exe_action = "PythonExe" + ver
     346            target_dir_prop = "TARGETDIR" + ver
     347            exe_prop = "PYTHON" + ver
     348            if msilib.Win64:
     349                # type: msidbLocatorTypeRawValue + msidbLocatorType64bit
     350                Type = 2+16
     351            else:
     352                Type = 2
     353            add_data(self.db, "RegLocator",
     354                    [(machine_reg, 2, install_path, None, Type),
     355                     (user_reg, 1, install_path, None, Type)])
     356            add_data(self.db, "AppSearch",
     357                    [(machine_prop, machine_reg),
     358                     (user_prop, user_reg)])
     359            add_data(self.db, "CustomAction",
     360                    [(machine_action, 51+256, target_dir_prop, "[" + machine_prop + "]"),
     361                     (user_action, 51+256, target_dir_prop, "[" + user_prop + "]"),
     362                     (exe_action, 51+256, exe_prop, "[" + target_dir_prop + "]\\python.exe"),
     363                    ])
     364            add_data(self.db, "InstallExecuteSequence",
     365                    [(machine_action, machine_prop, start),
     366                     (user_action, user_prop, start + 1),
     367                     (exe_action, None, start + 2),
     368                    ])
     369            add_data(self.db, "InstallUISequence",
     370                    [(machine_action, machine_prop, start),
     371                     (user_action, user_prop, start + 1),
     372                     (exe_action, None, start + 2),
     373                    ])
     374            add_data(self.db, "Condition",
     375                    [("Python" + ver, 0, "NOT TARGETDIR" + ver)])
     376            start += 4
     377            assert start < 500
    313378
    314379    def add_scripts(self):
    315380        if self.install_script:
    316             add_data(self.db, "CustomAction",
    317                     [("install_script", 50, "PYTHON", self.install_script_key)])
    318             add_data(self.db, "InstallExecuteSequence",
    319                     [("install_script", "NOT Installed", 6800)])
     381            start = 6800
     382            for ver in self.versions + [self.other_version]:
     383                install_action = "install_script." + ver
     384                exe_prop = "PYTHON" + ver
     385                add_data(self.db, "CustomAction",
     386                        [(install_action, 50, exe_prop, self.install_script_key)])
     387                add_data(self.db, "InstallExecuteSequence",
     388                        [(install_action, "&Python%s=3" % ver, start)])
     389                start += 1
     390        # XXX pre-install scripts are currently refused in finalize_options()
     391        #     but if this feature is completed, it will also need to add
     392        #     entries for each version as the above code does
    320393        if self.pre_install_script:
    321394            scriptfn = os.path.join(self.bdist_dir, "preinstall.bat")
     
    352425        modal = 3      # visible | modal
    353426        modeless = 1   # visible
    354         track_disk_space = 32
    355427
    356428        # UI customization properties
     
    381453                  ("WhichUsersDlg", "Privileged and not Windows9x and not Installed", 141),
    382454                  # In the user interface, assume all-users installation if privileged.
    383                   ("SelectDirectoryDlg", "Not Installed", 1230),
     455                  ("SelectFeaturesDlg", "Not Installed", 1230),
    384456                  # XXX no support for resume installations yet
    385457                  #("ResumeDlg", "Installed AND (RESUME OR Preselected)", 1240),
     
    504576
    505577        #####################################################################
    506         # Target directory selection
    507         seldlg = PyDialog(db, "SelectDirectoryDlg", x, y, w, h, modal, title,
     578        # Feature (Python directory) selection
     579        seldlg = PyDialog(db, "SelectFeaturesDlg", x, y, w, h, modal, title,
    508580                        "Next", "Next", "Cancel")
    509         seldlg.title("Select Destination Directory")
    510 
    511         version = sys.version[:3]+" "
    512         seldlg.text("Hint", 15, 30, 300, 40, 3,
    513                 "The destination directory should contain a Python %sinstallation" % version)
     581        seldlg.title("Select Python Installations")
     582
     583        seldlg.text("Hint", 15, 30, 300, 20, 3,
     584                    "Select the Python locations where %s should be installed."
     585                    % self.distribution.get_fullname())
    514586
    515587        seldlg.back("< Back", None, active=0)
    516588        c = seldlg.next("Next >", "Cancel")
    517         c.event("SetTargetPath", "TARGETDIR", ordering=1)
    518         c.event("SpawnWaitDialog", "WaitForCostingDlg", ordering=2)
    519         c.event("EndDialog", "Return", ordering=3)
    520 
    521         c = seldlg.cancel("Cancel", "DirectoryCombo")
     589        order = 1
     590        c.event("[TARGETDIR]", "[SourceDir]", ordering=order)
     591        for version in self.versions + [self.other_version]:
     592            order += 1
     593            c.event("[TARGETDIR]", "[TARGETDIR%s]" % version,
     594                    "FEATURE_SELECTED AND &Python%s=3" % version,
     595                    ordering=order)
     596        c.event("SpawnWaitDialog", "WaitForCostingDlg", ordering=order + 1)
     597        c.event("EndDialog", "Return", ordering=order + 2)
     598        c = seldlg.cancel("Cancel", "Features")
    522599        c.event("SpawnDialog", "CancelDlg")
    523600
    524         seldlg.control("DirectoryCombo", "DirectoryCombo", 15, 70, 272, 80, 393219,
    525                        "TARGETDIR", None, "DirectoryList", None)
    526         seldlg.control("DirectoryList", "DirectoryList", 15, 90, 308, 136, 3, "TARGETDIR",
    527                        None, "PathEdit", None)
    528         seldlg.control("PathEdit", "PathEdit", 15, 230, 306, 16, 3, "TARGETDIR", None, "Next", None)
    529         c = seldlg.pushbutton("Up", 306, 70, 18, 18, 3, "Up", None)
    530         c.event("DirectoryListUp", "0")
    531         c = seldlg.pushbutton("NewDir", 324, 70, 30, 18, 3, "New", None)
    532         c.event("DirectoryListNew", "0")
     601        c = seldlg.control("Features", "SelectionTree", 15, 60, 300, 120, 3,
     602                           "FEATURE", None, "PathEdit", None)
     603        c.event("[FEATURE_SELECTED]", "1")
     604        ver = self.other_version
     605        install_other_cond = "FEATURE_SELECTED AND &Python%s=3" % ver
     606        dont_install_other_cond = "FEATURE_SELECTED AND &Python%s<>3" % ver
     607
     608        c = seldlg.text("Other", 15, 200, 300, 15, 3,
     609                        "Provide an alternate Python location")
     610        c.condition("Enable", install_other_cond)
     611        c.condition("Show", install_other_cond)
     612        c.condition("Disable", dont_install_other_cond)
     613        c.condition("Hide", dont_install_other_cond)
     614
     615        c = seldlg.control("PathEdit", "PathEdit", 15, 215, 300, 16, 1,
     616                           "TARGETDIR" + ver, None, "Next", None)
     617        c.condition("Enable", install_other_cond)
     618        c.condition("Show", install_other_cond)
     619        c.condition("Disable", dont_install_other_cond)
     620        c.condition("Hide", dont_install_other_cond)
    533621
    534622        #####################################################################
     
    646734    def get_installer_filename(self, fullname):
    647735        # Factored out to allow overriding in subclasses
    648         base_name = "%s.%s-py%s.msi" % (fullname, self.plat_name,
    649                                         self.target_version)
     736        if self.target_version:
     737            base_name = "%s.%s-py%s.msi" % (fullname, self.plat_name,
     738                                            self.target_version)
     739        else:
     740            base_name = "%s.%s.msi" % (fullname, self.plat_name)
    650741        installer_name = os.path.join(self.dist_dir, base_name)
    651742        return installer_name
  • python/trunk/Lib/distutils/command/bdist_rpm.py

    r10 r391  
    44distributions)."""
    55
    6 # This module should be kept compatible with Python 2.1.
    7 
    8 __revision__ = "$Id: bdist_rpm.py 61000 2008-02-23 17:40:11Z christian.heimes $"
    9 
    10 import sys, os, string
    11 from types import *
     6__revision__ = "$Id$"
     7
     8import sys
     9import os
     10import string
     11
    1212from distutils.core import Command
    1313from distutils.debug import DEBUG
    14 from distutils.util import get_platform
    1514from distutils.file_util import write_file
    16 from distutils.errors import *
    17 from distutils.sysconfig import get_python_version
     15from distutils.errors import (DistutilsOptionError, DistutilsPlatformError,
     16                              DistutilsFileError, DistutilsExecError)
    1817from distutils import log
    1918
     
    126125        ('force-arch=', None,
    127126         "Force an architecture onto the RPM build process"),
    128        ]
     127
     128        ('quiet', 'q',
     129         "Run the INSTALL phase of RPM building in quiet mode"),
     130        ]
    129131
    130132    boolean_options = ['keep-temp', 'use-rpm-opt-flags', 'rpm3-mode',
    131                        'no-autoreq']
     133                       'no-autoreq', 'quiet']
    132134
    133135    negative_opt = {'no-keep-temp': 'keep-temp',
     
    179181
    180182        self.force_arch = None
     183        self.quiet = 0
    181184
    182185    # initialize_options()
     
    224227        self.ensure_string('packager')
    225228        self.ensure_string_list('doc_files')
    226         if type(self.doc_files) is ListType:
     229        if isinstance(self.doc_files, list):
    227230            for readme in ('README', 'README.txt'):
    228231                if os.path.exists(readme) and readme not in self.doc_files:
     
    326329           os.path.exists('/bin/rpmbuild'):
    327330            rpm_cmd = ['rpmbuild']
     331
    328332        if self.source_only: # what kind of RPMs?
    329333            rpm_cmd.append('-bs')
     
    337341        if not self.keep_temp:
    338342            rpm_cmd.append('--clean')
     343
     344        if self.quiet:
     345            rpm_cmd.append('--quiet')
     346
    339347        rpm_cmd.append(spec_path)
    340348        # Determine the binary rpm names that should be built out of this spec
     
    351359
    352360        out = os.popen(q_cmd)
    353         binary_rpms = []
    354         source_rpm = None
    355         while 1:
    356             line = out.readline()
    357             if not line:
    358                 break
    359             l = string.split(string.strip(line))
    360             assert(len(l) == 2)
    361             binary_rpms.append(l[1])
    362             # The source rpm is named after the first entry in the spec file
    363             if source_rpm is None:
    364                 source_rpm = l[0]
    365 
    366         status = out.close()
    367         if status:
    368             raise DistutilsExecError("Failed to execute: %s" % repr(q_cmd))
     361        try:
     362            binary_rpms = []
     363            source_rpm = None
     364            while 1:
     365                line = out.readline()
     366                if not line:
     367                    break
     368                l = string.split(string.strip(line))
     369                assert(len(l) == 2)
     370                binary_rpms.append(l[1])
     371                # The source rpm is named after the first entry in the spec file
     372                if source_rpm is None:
     373                    source_rpm = l[0]
     374
     375            status = out.close()
     376            if status:
     377                raise DistutilsExecError("Failed to execute: %s" % repr(q_cmd))
     378
     379        finally:
     380            out.close()
    369381
    370382        self.spawn(rpm_cmd)
    371383
    372384        if not self.dry_run:
     385            if self.distribution.has_ext_modules():
     386                pyversion = get_python_version()
     387            else:
     388                pyversion = 'any'
     389
    373390            if not self.binary_only:
    374391                srpm = os.path.join(rpm_dir['SRPMS'], source_rpm)
    375392                assert(os.path.exists(srpm))
    376393                self.move_file(srpm, self.dist_dir)
     394                filename = os.path.join(self.dist_dir, source_rpm)
     395                self.distribution.dist_files.append(
     396                    ('bdist_rpm', pyversion, filename))
    377397
    378398            if not self.source_only:
     
    381401                    if os.path.exists(rpm):
    382402                        self.move_file(rpm, self.dist_dir)
     403                        filename = os.path.join(self.dist_dir,
     404                                                os.path.basename(rpm))
     405                        self.distribution.dist_files.append(
     406                            ('bdist_rpm', pyversion, filename))
    383407    # run()
    384408
     
    441465                      ):
    442466            val = getattr(self, string.lower(field))
    443             if type(val) is ListType:
     467            if isinstance(val, list):
    444468                spec_file.append('%s: %s' % (field, string.join(val)))
    445469            elif val is not None:
     
    492516        # are just text that we drop in as-is.  Hmmm.
    493517
     518        install_cmd = ('%s install -O1 --root=$RPM_BUILD_ROOT '
     519                       '--record=INSTALLED_FILES') % def_setup_call
     520
    494521        script_options = [
    495522            ('prep', 'prep_script', "%setup -n %{name}-%{unmangled_version}"),
    496523            ('build', 'build_script', def_build),
    497             ('install', 'install_script',
    498              ("%s install "
    499               "--root=$RPM_BUILD_ROOT "
    500               "--record=INSTALLED_FILES") % def_setup_call),
     524            ('install', 'install_script', install_cmd),
    501525            ('clean', 'clean_script', "rm -rf $RPM_BUILD_ROOT"),
    502526            ('verifyscript', 'verify_script', None),
  • python/trunk/Lib/distutils/command/bdist_wininst.py

    r2 r391  
    44exe-program."""
    55
    6 # This module should be kept compatible with Python 2.1.
    7 
    8 __revision__ = "$Id: bdist_wininst.py 71422 2009-04-09 22:48:19Z tarek.ziade $"
    9 
    10 import sys, os, string
     6__revision__ = "$Id$"
     7
     8import sys
     9import os
     10import string
     11
     12from sysconfig import get_python_version
     13
    1114from distutils.core import Command
     15from distutils.dir_util import remove_tree
     16from distutils.errors import DistutilsOptionError, DistutilsPlatformError
     17from distutils import log
    1218from distutils.util import get_platform
    13 from distutils.dir_util import create_tree, remove_tree
    14 from distutils.errors import *
    15 from distutils.sysconfig import get_python_version
    16 from distutils import log
    1719
    1820class bdist_wininst (Command):
     
    7072        self.bitmap = None
    7173        self.title = None
    72         self.skip_build = 0
     74        self.skip_build = None
    7375        self.install_script = None
    7476        self.pre_install_script = None
     
    7981
    8082    def finalize_options (self):
     83        self.set_undefined_options('bdist', ('skip_build', 'skip_build'))
     84
    8185        if self.bdist_dir is None:
    8286            if self.skip_build and self.plat_name:
     
    8892            bdist_base = self.get_finalized_command('bdist').bdist_base
    8993            self.bdist_dir = os.path.join(bdist_base, 'wininst')
     94
    9095        if not self.target_version:
    9196            self.target_version = ""
     97
    9298        if not self.skip_build and self.distribution.has_ext_modules():
    9399            short_version = get_python_version()
    94100            if self.target_version and self.target_version != short_version:
    95101                raise DistutilsOptionError, \
    96                       "target version can only be %s, or the '--skip_build'" \
     102                      "target version can only be %s, or the '--skip-build'" \
    97103                      " option must be specified" % (short_version,)
    98104            self.target_version = short_version
     
    355361
    356362        filename = os.path.join(directory, "wininst-%.1f%s.exe" % (bv, sfix))
    357         return open(filename, "rb").read()
     363        f = open(filename, "rb")
     364        try:
     365            return f.read()
     366        finally:
     367            f.close()
    358368# class bdist_wininst
  • python/trunk/Lib/distutils/command/build.py

    r2 r391  
    33Implements the Distutils 'build' command."""
    44
    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 $"
     5__revision__ = "$Id$"
    86
    97import sys, os
     8
     9from distutils.util import get_platform
    1010from distutils.core import Command
    1111from distutils.errors import DistutilsOptionError
    12 from distutils.util import get_platform
    1312
    14 
    15 def show_compilers ():
     13def show_compilers():
    1614    from distutils.ccompiler import show_compilers
    1715    show_compilers()
    1816
    19 
    20 class build (Command):
     17class build(Command):
    2118
    2219    description = "build everything needed to install"
     
    5653        ]
    5754
    58     def initialize_options (self):
     55    def initialize_options(self):
    5956        self.build_base = 'build'
    6057        # these are decided only after 'build_base' has its final value
     
    7168        self.executable = None
    7269
    73     def finalize_options (self):
    74 
     70    def finalize_options(self):
    7571        if self.plat_name is None:
    7672            self.plat_name = get_platform()
     
    121117        if self.executable is None:
    122118            self.executable = os.path.normpath(sys.executable)
    123     # finalize_options ()
    124119
    125 
    126     def run (self):
    127 
     120    def run(self):
    128121        # Run all relevant sub-commands.  This will be some subset of:
    129122        #  - build_py      - pure Python modules
     
    133126        for cmd_name in self.get_sub_commands():
    134127            self.run_command(cmd_name)
    135 
    136128
    137129    # -- Predicates for the sub-command list ---------------------------
     
    149141        return self.distribution.has_scripts()
    150142
    151 
    152143    sub_commands = [('build_py',      has_pure_modules),
    153144                    ('build_clib',    has_c_libraries),
     
    155146                    ('build_scripts', has_scripts),
    156147                   ]
    157 
    158 # class build
  • python/trunk/Lib/distutils/command/build_clib.py

    r2 r391  
    55module."""
    66
    7 # This module should be kept compatible with Python 2.1.
    8 
    9 __revision__ = "$Id: build_clib.py 37828 2004-11-10 22:23:15Z loewis $"
     7__revision__ = "$Id$"
    108
    119
     
    1917# cut 'n paste.  Sigh.
    2018
    21 import os, string
    22 from types import *
     19import os
    2320from distutils.core import Command
    24 from distutils.errors import *
     21from distutils.errors import DistutilsSetupError
    2522from distutils.sysconfig import customize_compiler
    2623from distutils import log
    2724
    28 def show_compilers ():
     25def show_compilers():
    2926    from distutils.ccompiler import show_compilers
    3027    show_compilers()
    3128
    3229
    33 class build_clib (Command):
     30class build_clib(Command):
    3431
    3532    description = "build C/C++ libraries used by Python extensions"
    3633
    3734    user_options = [
    38         ('build-clib', 'b',
     35        ('build-clib=', 'b',
    3936         "directory to build C/C++ libraries to"),
    40         ('build-temp', 't',
     37        ('build-temp=', 't',
    4138         "directory to put temporary build by-products"),
    4239        ('debug', 'g',
     
    5552        ]
    5653
    57     def initialize_options (self):
     54    def initialize_options(self):
    5855        self.build_clib = None
    5956        self.build_temp = None
     
    7067        self.compiler = None
    7168
    72     # initialize_options()
    73 
    74 
    75     def finalize_options (self):
    76 
     69
     70    def finalize_options(self):
    7771        # This might be confusing: both build-clib and build-temp default
    7872        # to build-temp as defined by the "build" command.  This is because
     
    9387        if self.include_dirs is None:
    9488            self.include_dirs = self.distribution.include_dirs or []
    95         if type(self.include_dirs) is StringType:
    96             self.include_dirs = string.split(self.include_dirs,
    97                                              os.pathsep)
     89        if isinstance(self.include_dirs, str):
     90            self.include_dirs = self.include_dirs.split(os.pathsep)
    9891
    9992        # XXX same as for build_ext -- what about 'self.define' and
    10093        # 'self.undef' ?
    10194
    102     # finalize_options()
    103 
    104 
    105     def run (self):
    106 
     95    def run(self):
    10796        if not self.libraries:
    10897            return
     
    127116        self.build_libraries(self.libraries)
    128117
    129     # run()
    130 
    131 
    132     def check_library_list (self, libraries):
    133         """Ensure that the list of libraries (presumably provided as a
    134            command option 'libraries') is valid, i.e. it is a list of
    135            2-tuples, where the tuples are (library_name, build_info_dict).
    136            Raise DistutilsSetupError if the structure is invalid anywhere;
    137            just returns otherwise."""
    138 
    139         # Yechh, blecch, ackk: this is ripped straight out of build_ext.py,
    140         # with only names changed to protect the innocent!
    141 
    142         if type(libraries) is not ListType:
     118
     119    def check_library_list(self, libraries):
     120        """Ensure that the list of libraries is valid.
     121
     122        `library` is presumably provided as a command option 'libraries'.
     123        This method checks that it is a list of 2-tuples, where the tuples
     124        are (library_name, build_info_dict).
     125
     126        Raise DistutilsSetupError if the structure is invalid anywhere;
     127        just returns otherwise.
     128        """
     129        if not isinstance(libraries, list):
    143130            raise DistutilsSetupError, \
    144131                  "'libraries' option must be a list of tuples"
    145132
    146133        for lib in libraries:
    147             if type(lib) is not TupleType and len(lib) != 2:
     134            if not isinstance(lib, tuple) and len(lib) != 2:
    148135                raise DistutilsSetupError, \
    149136                      "each element of 'libraries' must a 2-tuple"
    150137
    151             if type(lib[0]) is not StringType:
     138            name, build_info = lib
     139
     140            if not isinstance(name, str):
    152141                raise DistutilsSetupError, \
    153142                      "first element of each tuple in 'libraries' " + \
    154143                      "must be a string (the library name)"
    155             if '/' in lib[0] or (os.sep != '/' and os.sep in lib[0]):
     144            if '/' in name or (os.sep != '/' and os.sep in name):
    156145                raise DistutilsSetupError, \
    157146                      ("bad library name '%s': " +
     
    159148                      lib[0]
    160149
    161             if type(lib[1]) is not DictionaryType:
     150            if not isinstance(build_info, dict):
    162151                raise DistutilsSetupError, \
    163152                      "second element of each tuple in 'libraries' " + \
    164153                      "must be a dictionary (build info)"
    165         # for lib
    166 
    167     # check_library_list ()
    168 
    169 
    170     def get_library_names (self):
     154
     155    def get_library_names(self):
    171156        # Assume the library list is valid -- 'check_library_list()' is
    172157        # called from 'finalize_options()', so it should be!
    173 
    174158        if not self.libraries:
    175159            return None
     
    180164        return lib_names
    181165
    182     # get_library_names ()
    183 
    184 
    185     def get_source_files (self):
     166
     167    def get_source_files(self):
    186168        self.check_library_list(self.libraries)
    187169        filenames = []
    188170        for (lib_name, build_info) in self.libraries:
    189171            sources = build_info.get('sources')
    190             if (sources is None or
    191                 type(sources) not in (ListType, TupleType) ):
     172            if sources is None or not isinstance(sources, (list, tuple)):
    192173                raise DistutilsSetupError, \
    193174                      ("in 'libraries' option (library '%s'), "
     
    196177
    197178            filenames.extend(sources)
    198 
    199179        return filenames
    200     # get_source_files ()
    201 
    202 
    203     def build_libraries (self, libraries):
    204 
     180
     181    def build_libraries(self, libraries):
    205182        for (lib_name, build_info) in libraries:
    206183            sources = build_info.get('sources')
    207             if sources is None or type(sources) not in (ListType, TupleType):
     184            if sources is None or not isinstance(sources, (list, tuple)):
    208185                raise DistutilsSetupError, \
    209186                      ("in 'libraries' option (library '%s'), " +
     
    231208                                            output_dir=self.build_clib,
    232209                                            debug=self.debug)
    233 
    234         # for libraries
    235 
    236     # build_libraries ()
    237 
    238 # class build_lib
  • python/trunk/Lib/distutils/command/build_ext.py

    r2 r391  
    77# This module should be kept compatible with Python 2.1.
    88
    9 __revision__ = "$Id: build_ext.py 75395 2009-10-13 21:17:34Z tarek.ziade $"
     9__revision__ = "$Id$"
    1010
    1111import sys, os, string, re
     
    161161            self.include_dirs.append(plat_py_include)
    162162
    163         if isinstance(self.libraries, str):
    164             self.libraries = [self.libraries]
     163        self.ensure_string_list('libraries')
    165164
    166165        # Life is easier if we're not forever checking for None, so
     
    208207            elif MSVC_VERSION == 8:
    209208                self.library_dirs.append(os.path.join(sys.exec_prefix,
    210                                          'PC', 'VS8.0', 'win32release'))
     209                                         'PC', 'VS8.0'))
    211210            elif MSVC_VERSION == 7:
    212211                self.library_dirs.append(os.path.join(sys.exec_prefix,
     
    233232                self.library_dirs.append('.')
    234233
    235         # for extensions under Linux or Solaris with a shared Python library,
     234        # For building extensions with a shared Python library,
    236235        # Python's library directory must be appended to library_dirs
    237         sysconfig.get_config_var('Py_ENABLE_SHARED')
    238         if ((sys.platform.startswith('linux') or sys.platform.startswith('gnu')
    239              or sys.platform.startswith('sunos'))
    240             and sysconfig.get_config_var('Py_ENABLE_SHARED')):
     236        # See Issues: #1600860, #4366
     237        if (sysconfig.get_config_var('Py_ENABLE_SHARED')):
    241238            if sys.executable.startswith(os.path.join(sys.exec_prefix, "bin")):
    242239                # building third party extensions
     
    677674        so_ext = get_config_var('SO')
    678675        if os.name == 'nt' and self.debug:
    679             return apply(os.path.join, ext_path) + '_d' + so_ext
     676            return os.path.join(*ext_path) + '_d' + so_ext
    680677        return os.path.join(*ext_path) + so_ext
    681678
     
    754751            # Don't use the default code below
    755752            return ext.libraries
    756 
     753        elif sys.platform[:3] == 'aix':
     754            # Don't use the default code below
     755            return ext.libraries
    757756        else:
    758757            from distutils import sysconfig
  • python/trunk/Lib/distutils/command/build_py.py

    r2 r391  
    33Implements the Distutils 'build_py' command."""
    44
    5 # This module should be kept compatible with Python 2.1.
    6 
    7 __revision__ = "$Id: build_py.py 77376 2010-01-08 23:27:23Z tarek.ziade $"
    8 
    9 import string, os
    10 from types import *
     5__revision__ = "$Id$"
     6
     7import os
    118import sys
    129from glob import glob
    1310
    1411from distutils.core import Command
    15 from distutils.errors import *
     12from distutils.errors import DistutilsOptionError, DistutilsFileError
    1613from distutils.util import convert_path
    1714from distutils import log
    1815
    19 class build_py (Command):
     16class build_py(Command):
    2017
    2118    description = "\"build\" pure Python modules (copy to build directory)"
     
    3431    negative_opt = {'no-compile' : 'compile'}
    3532
    36 
    37     def initialize_options (self):
     33    def initialize_options(self):
    3834        self.build_lib = None
    3935        self.py_modules = None
     
    4541        self.force = None
    4642
    47     def finalize_options (self):
     43    def finalize_options(self):
    4844        self.set_undefined_options('build',
    4945                                   ('build_lib', 'build_lib'),
     
    6359        # Ick, copied straight from install_lib.py (fancy_getopt needs a
    6460        # type system!  Hell, *everything* needs a type system!!!)
    65         if type(self.optimize) is not IntType:
     61        if not isinstance(self.optimize, int):
    6662            try:
    6763                self.optimize = int(self.optimize)
    6864                assert 0 <= self.optimize <= 2
    6965            except (ValueError, AssertionError):
    70                 raise DistutilsOptionError, "optimize must be 0, 1, or 2"
    71 
    72     def run (self):
    73 
     66                raise DistutilsOptionError("optimize must be 0, 1, or 2")
     67
     68    def run(self):
    7469        # XXX copy_file by default preserves atime and mtime.  IMHO this is
    7570        # the right thing to do, but perhaps it should be an option -- in
     
    10196        self.byte_compile(self.get_outputs(include_bytecode=0))
    10297
    103     # run ()
    104 
    105     def get_data_files (self):
     98    def get_data_files(self):
    10699        """Generate list of '(package,src_dir,build_dir,filenames)' tuples"""
    107100        data = []
     
    127120        return data
    128121
    129     def find_data_files (self, package, src_dir):
     122    def find_data_files(self, package, src_dir):
    130123        """Return filenames for package's data files in 'src_dir'"""
    131124        globs = (self.package_data.get('', [])
     
    139132        return files
    140133
    141     def build_package_data (self):
     134    def build_package_data(self):
    142135        """Copy data files into build directory"""
    143         lastdir = None
    144136        for package, src_dir, build_dir, filenames in self.data_files:
    145137            for filename in filenames:
     
    149141                               preserve_mode=False)
    150142
    151     def get_package_dir (self, package):
     143    def get_package_dir(self, package):
    152144        """Return the directory, relative to the top of the source
    153145           distribution, where package 'package' should be found
    154146           (at least according to the 'package_dir' option, if any)."""
    155147
    156         path = string.split(package, '.')
     148        path = package.split('.')
    157149
    158150        if not self.package_dir:
    159151            if path:
    160                 return apply(os.path.join, path)
     152                return os.path.join(*path)
    161153            else:
    162154                return ''
     
    165157            while path:
    166158                try:
    167                     pdir = self.package_dir[string.join(path, '.')]
     159                    pdir = self.package_dir['.'.join(path)]
    168160                except KeyError:
    169161                    tail.insert(0, path[-1])
     
    185177
    186178                if tail:
    187                     return apply(os.path.join, tail)
     179                    return os.path.join(*tail)
    188180                else:
    189181                    return ''
    190182
    191     # get_package_dir ()
    192 
    193 
    194     def check_package (self, package, package_dir):
    195 
     183    def check_package(self, package, package_dir):
    196184        # Empty dir name means current directory, which we can probably
    197185        # assume exists.  Also, os.path.exists and isdir don't know about
     
    200188        if package_dir != "":
    201189            if not os.path.exists(package_dir):
    202                 raise DistutilsFileError, \
    203                       "package directory '%s' does not exist" % package_dir
     190                raise DistutilsFileError(
     191                      "package directory '%s' does not exist" % package_dir)
    204192            if not os.path.isdir(package_dir):
    205                 raise DistutilsFileError, \
    206                       ("supposed package directory '%s' exists, " +
    207                        "but is not a directory") % package_dir
     193                raise DistutilsFileError(
     194                       "supposed package directory '%s' exists, "
     195                       "but is not a directory" % package_dir)
    208196
    209197        # Require __init__.py for all but the "root package"
     
    220208        return None
    221209
    222     # check_package ()
    223 
    224 
    225     def check_module (self, module, module_file):
     210    def check_module(self, module, module_file):
    226211        if not os.path.isfile(module_file):
    227212            log.warn("file %s (for module %s) not found", module_file, module)
    228             return 0
     213            return False
    229214        else:
    230             return 1
    231 
    232     # check_module ()
    233 
    234 
    235     def find_package_modules (self, package, package_dir):
     215            return True
     216
     217    def find_package_modules(self, package, package_dir):
    236218        self.check_package(package, package_dir)
    237219        module_files = glob(os.path.join(package_dir, "*.py"))
     
    248230        return modules
    249231
    250 
    251     def find_modules (self):
     232    def find_modules(self):
    252233        """Finds individually-specified Python modules, ie. those listed by
    253234        module name in 'self.py_modules'.  Returns a list of tuples (package,
     
    258239        module.
    259240        """
    260 
    261241        # Map package names to tuples of useful info about the package:
    262242        #    (package_dir, checked)
     
    274254        # string or empty list, depending on context).  Differences:
    275255        #   - don't check for __init__.py in directory for empty package
    276 
    277256        for module in self.py_modules:
    278             path = string.split(module, '.')
    279             package = string.join(path[0:-1], '.')
     257            path = module.split('.')
     258            package = '.'.join(path[0:-1])
    280259            module_base = path[-1]
    281260
     
    303282        return modules
    304283
    305     # find_modules ()
    306 
    307 
    308     def find_all_modules (self):
     284    def find_all_modules(self):
    309285        """Compute the list of all modules that will be built, whether
    310286        they are specified one-module-at-a-time ('self.py_modules') or
     
    312288        (package, module, module_file), just like 'find_modules()' and
    313289        'find_package_modules()' do."""
    314 
    315290        modules = []
    316291        if self.py_modules:
     
    321296                m = self.find_package_modules(package, package_dir)
    322297                modules.extend(m)
    323 
    324298        return modules
    325299
    326     # find_all_modules ()
    327 
    328 
    329     def get_source_files (self):
    330 
    331         modules = self.find_all_modules()
    332         filenames = []
    333         for module in modules:
    334             filenames.append(module[-1])
    335 
    336         return filenames
    337 
    338 
    339     def get_module_outfile (self, build_dir, package, module):
     300    def get_source_files(self):
     301        return [module[-1] for module in self.find_all_modules()]
     302
     303    def get_module_outfile(self, build_dir, package, module):
    340304        outfile_path = [build_dir] + list(package) + [module + ".py"]
    341305        return os.path.join(*outfile_path)
    342306
    343 
    344     def get_outputs (self, include_bytecode=1):
     307    def get_outputs(self, include_bytecode=1):
    345308        modules = self.find_all_modules()
    346309        outputs = []
    347310        for (package, module, module_file) in modules:
    348             package = string.split(package, '.')
     311            package = package.split('.')
    349312            filename = self.get_module_outfile(self.build_lib, package, module)
    350313            outputs.append(filename)
     
    363326        return outputs
    364327
    365 
    366     def build_module (self, module, module_file, package):
    367         if type(package) is StringType:
    368             package = string.split(package, '.')
    369         elif type(package) not in (ListType, TupleType):
    370             raise TypeError, \
    371                   "'package' must be a string (dot-separated), list, or tuple"
     328    def build_module(self, module, module_file, package):
     329        if isinstance(package, str):
     330            package = package.split('.')
     331        elif not isinstance(package, (list, tuple)):
     332            raise TypeError(
     333                  "'package' must be a string (dot-separated), list, or tuple")
    372334
    373335        # Now put the module source file into the "build" area -- this is
     
    379341        return self.copy_file(module_file, outfile, preserve_mode=0)
    380342
    381 
    382     def build_modules (self):
    383 
     343    def build_modules(self):
    384344        modules = self.find_modules()
    385345        for (package, module, module_file) in modules:
     
    391351            self.build_module(module, module_file, package)
    392352
    393     # build_modules ()
    394 
    395 
    396     def build_packages (self):
    397 
     353    def build_packages(self):
    398354        for package in self.packages:
    399355
     
    416372                self.build_module(module, module_file, package)
    417373
    418     # build_packages ()
    419 
    420 
    421     def byte_compile (self, files):
     374    def byte_compile(self, files):
    422375        if sys.dont_write_bytecode:
    423376            self.warn('byte-compiling is disabled, skipping.')
     
    439392            byte_compile(files, optimize=self.optimize,
    440393                         force=self.force, prefix=prefix, dry_run=self.dry_run)
    441 
    442 # class build_py
  • python/trunk/Lib/distutils/command/build_scripts.py

    r2 r391  
    33Implements the Distutils 'build_scripts' command."""
    44
    5 # This module should be kept compatible with Python 2.1.
    6 
    7 __revision__ = "$Id: build_scripts.py 69599 2009-02-13 23:02:44Z tarek.ziade $"
     5__revision__ = "$Id$"
    86
    97import os, re
    108from stat import ST_MODE
    11 from distutils import sysconfig
    129from distutils.core import Command
    1310from distutils.dep_util import newer
     
    6057        line to refer to the current Python interpreter as we copy.
    6158        """
     59        _sysconfig = __import__('sysconfig')
    6260        self.mkpath(self.build_dir)
    6361        outfiles = []
     
    9795                if not self.dry_run:
    9896                    outf = open(outfile, "w")
    99                     if not sysconfig.python_build:
     97                    if not _sysconfig.is_python_build():
    10098                        outf.write("#!%s%s\n" %
    10199                                   (self.executable,
     
    104102                        outf.write("#!%s%s\n" %
    105103                                   (os.path.join(
    106                             sysconfig.get_config_var("BINDIR"),
    107                            "python%s%s" % (sysconfig.get_config_var("VERSION"),
    108                                            sysconfig.get_config_var("EXE"))),
     104                            _sysconfig.get_config_var("BINDIR"),
     105                           "python%s%s" % (_sysconfig.get_config_var("VERSION"),
     106                                           _sysconfig.get_config_var("EXE"))),
    109107                                    post_interp))
    110108                    outf.writelines(f.readlines())
  • python/trunk/Lib/distutils/command/clean.py

    r2 r391  
    55# contributed by Bastian Kleineidam <calvin@cs.uni-sb.de>, added 2000-03-18
    66
    7 # This module should be kept compatible with Python 2.1.
    8 
    9 __revision__ = "$Id: clean.py 38532 2005-03-03 08:12:27Z loewis $"
     7__revision__ = "$Id$"
    108
    119import os
     
    1412from distutils import log
    1513
    16 class clean (Command):
     14class clean(Command):
    1715
    1816    description = "clean up temporary files from 'build' command"
  • python/trunk/Lib/distutils/command/config.py

    r2 r391  
    1010"""
    1111
    12 # This module should be kept compatible with Python 2.1.
    13 
    14 __revision__ = "$Id: config.py 37828 2004-11-10 22:23:15Z loewis $"
    15 
    16 import sys, os, string, re
    17 from types import *
     12__revision__ = "$Id$"
     13
     14import os
     15import re
     16
    1817from distutils.core import Command
    1918from distutils.errors import DistutilsExecError
     
    2120from distutils import log
    2221
    23 LANG_EXT = {'c': '.c',
    24             'c++': '.cxx'}
    25 
    26 class config (Command):
     22LANG_EXT = {'c': '.c', 'c++': '.cxx'}
     23
     24class config(Command):
    2725
    2826    description = "prepare to build"
     
    5452    # does nothing by default, these are empty.
    5553
    56     def initialize_options (self):
     54    def initialize_options(self):
    5755        self.compiler = None
    5856        self.cc = None
    5957        self.include_dirs = None
    60         #self.define = None
    61         #self.undef = None
    6258        self.libraries = None
    6359        self.library_dirs = None
     
    7167        self.temp_files = []
    7268
    73     def finalize_options (self):
     69    def finalize_options(self):
    7470        if self.include_dirs is None:
    7571            self.include_dirs = self.distribution.include_dirs or []
    76         elif type(self.include_dirs) is StringType:
    77             self.include_dirs = string.split(self.include_dirs, os.pathsep)
     72        elif isinstance(self.include_dirs, str):
     73            self.include_dirs = self.include_dirs.split(os.pathsep)
    7874
    7975        if self.libraries is None:
    8076            self.libraries = []
    81         elif type(self.libraries) is StringType:
     77        elif isinstance(self.libraries, str):
    8278            self.libraries = [self.libraries]
    8379
    8480        if self.library_dirs is None:
    8581            self.library_dirs = []
    86         elif type(self.library_dirs) is StringType:
    87             self.library_dirs = string.split(self.library_dirs, os.pathsep)
    88 
    89 
    90     def run (self):
     82        elif isinstance(self.library_dirs, str):
     83            self.library_dirs = self.library_dirs.split(os.pathsep)
     84
     85    def run(self):
    9186        pass
    9287
     
    9691    # may use these freely.
    9792
    98     def _check_compiler (self):
     93    def _check_compiler(self):
    9994        """Check that 'self.compiler' really is a CCompiler object;
    10095        if not, make it one.
     
    115110
    116111
    117     def _gen_temp_sourcefile (self, body, headers, lang):
     112    def _gen_temp_sourcefile(self, body, headers, lang):
    118113        filename = "_configtest" + LANG_EXT[lang]
    119114        file = open(filename, "w")
     
    128123        return filename
    129124
    130     def _preprocess (self, body, headers, include_dirs, lang):
     125    def _preprocess(self, body, headers, include_dirs, lang):
    131126        src = self._gen_temp_sourcefile(body, headers, lang)
    132127        out = "_configtest.i"
     
    135130        return (src, out)
    136131
    137     def _compile (self, body, headers, include_dirs, lang):
     132    def _compile(self, body, headers, include_dirs, lang):
    138133        src = self._gen_temp_sourcefile(body, headers, lang)
    139134        if self.dump_source:
     
    144139        return (src, obj)
    145140
    146     def _link (self, body,
    147                headers, include_dirs,
    148                libraries, library_dirs, lang):
     141    def _link(self, body, headers, include_dirs, libraries, library_dirs,
     142              lang):
    149143        (src, obj) = self._compile(body, headers, include_dirs, lang)
    150144        prog = os.path.splitext(os.path.basename(src))[0]
     
    160154        return (src, obj, prog)
    161155
    162     def _clean (self, *filenames):
     156    def _clean(self, *filenames):
    163157        if not filenames:
    164158            filenames = self.temp_files
    165159            self.temp_files = []
    166         log.info("removing: %s", string.join(filenames))
     160        log.info("removing: %s", ' '.join(filenames))
    167161        for filename in filenames:
    168162            try:
     
    182176    # XXX need access to the header search path and maybe default macros.
    183177
    184     def try_cpp (self, body=None, headers=None, include_dirs=None, lang="c"):
     178    def try_cpp(self, body=None, headers=None, include_dirs=None, lang="c"):
    185179        """Construct a source file from 'body' (a string containing lines
    186180        of C/C++ code) and 'headers' (a list of header files to include)
     
    200194        return ok
    201195
    202     def search_cpp (self, pattern, body=None,
    203                     headers=None, include_dirs=None, lang="c"):
     196    def search_cpp(self, pattern, body=None, headers=None, include_dirs=None,
     197                   lang="c"):
    204198        """Construct a source file (just like 'try_cpp()'), run it through
    205199        the preprocessor, and return true if any line of the output matches
     
    209203        symbols the preprocessor and compiler set by default.
    210204        """
    211 
    212         self._check_compiler()
    213         (src, out) = self._preprocess(body, headers, include_dirs, lang)
    214 
    215         if type(pattern) is StringType:
     205        self._check_compiler()
     206        src, out = self._preprocess(body, headers, include_dirs, lang)
     207
     208        if isinstance(pattern, str):
    216209            pattern = re.compile(pattern)
    217210
     
    230223        return match
    231224
    232     def try_compile (self, body, headers=None, include_dirs=None, lang="c"):
     225    def try_compile(self, body, headers=None, include_dirs=None, lang="c"):
    233226        """Try to compile a source file built from 'body' and 'headers'.
    234227        Return true on success, false otherwise.
     
    246239        return ok
    247240
    248     def try_link (self, body,
    249                   headers=None, include_dirs=None,
    250                   libraries=None, library_dirs=None,
    251                   lang="c"):
     241    def try_link(self, body, headers=None, include_dirs=None, libraries=None,
     242                 library_dirs=None, lang="c"):
    252243        """Try to compile and link a source file, built from 'body' and
    253244        'headers', to executable form.  Return true on success, false
     
    267258        return ok
    268259
    269     def try_run (self, body,
    270                  headers=None, include_dirs=None,
    271                  libraries=None, library_dirs=None,
    272                  lang="c"):
     260    def try_run(self, body, headers=None, include_dirs=None, libraries=None,
     261                library_dirs=None, lang="c"):
    273262        """Try to compile, link to an executable, and run a program
    274263        built from 'body' and 'headers'.  Return true on success, false
     
    294283    # when implementing a real-world config command!)
    295284
    296     def check_func (self, func,
    297                     headers=None, include_dirs=None,
    298                     libraries=None, library_dirs=None,
    299                     decl=0, call=0):
     285    def check_func(self, func, headers=None, include_dirs=None,
     286                   libraries=None, library_dirs=None, decl=0, call=0):
    300287
    301288        """Determine if function 'func' is available by constructing a
     
    323310            body.append("  %s;" % func)
    324311        body.append("}")
    325         body = string.join(body, "\n") + "\n"
     312        body = "\n".join(body) + "\n"
    326313
    327314        return self.try_link(body, headers, include_dirs,
     
    330317    # check_func ()
    331318
    332     def check_lib (self, library, library_dirs=None,
    333                    headers=None, include_dirs=None, other_libraries=[]):
     319    def check_lib(self, library, library_dirs=None, headers=None,
     320                  include_dirs=None, other_libraries=[]):
    334321        """Determine if 'library' is available to be linked against,
    335322        without actually checking that any particular symbols are provided
     
    345332                             [library]+other_libraries, library_dirs)
    346333
    347     def check_header (self, header, include_dirs=None,
    348                       library_dirs=None, lang="c"):
     334    def check_header(self, header, include_dirs=None, library_dirs=None,
     335                     lang="c"):
    349336        """Determine if the system header file named by 'header_file'
    350337        exists and can be found by the preprocessor; return true if so,
     
    355342
    356343
    357 # class config
    358 
    359 
    360 def dump_file (filename, head=None):
     344def dump_file(filename, head=None):
     345    """Dumps a file content into log.info.
     346
     347    If head is not None, will be dumped before the file content.
     348    """
    361349    if head is None:
    362         print filename + ":"
     350        log.info('%s' % filename)
    363351    else:
    364         print head
    365 
     352        log.info(head)
    366353    file = open(filename)
    367     sys.stdout.write(file.read())
    368     file.close()
     354    try:
     355        log.info(file.read())
     356    finally:
     357        file.close()
  • python/trunk/Lib/distutils/command/install.py

    r10 r391  
    77# This module should be kept compatible with Python 2.1.
    88
    9 __revision__ = "$Id: install.py 62788 2008-05-06 22:41:46Z christian.heimes $"
     9__revision__ = "$Id$"
    1010
    1111import sys, os, string
     
    7070        'data'   : '$userbase',
    7171        },
    72     'mac': {
    73         'purelib': '$base/Lib/site-packages',
    74         'platlib': '$base/Lib/site-packages',
    75         'headers': '$base/Include/$dist_name',
    76         'scripts': '$base/Scripts',
    77         'data'   : '$base',
    78         },
    79     'mac_user': {
    80         'purelib': '$usersite',
    81         'platlib': '$usersite',
    82         'headers': '$userbase/$py_version_short/include/$dist_name',
    83         'scripts': '$userbase/bin',
    84         'data'   : '$userbase',
    85         },
    8672    'os2': {
    8773        'purelib': '$base/Lib/site-packages',
     
    280266        if self.user and (self.prefix or self.exec_prefix or self.home or
    281267                self.install_base or self.install_platbase):
    282             raise DistutilsOptionError("can't combine user with with prefix/"
    283                                        "exec_prefix/home or install_(plat)base")
     268            raise DistutilsOptionError("can't combine user with prefix, "
     269                                       "exec_prefix/home, or install_(plat)base")
    284270
    285271        # Next, stuff that's wrong (or dubious) only on certain platforms.
  • python/trunk/Lib/distutils/command/install_data.py

    r2 r391  
    66# contributed by Bastian Kleineidam
    77
    8 # This module should be kept compatible with Python 2.1.
    9 
    10 __revision__ = "$Id: install_data.py 37828 2004-11-10 22:23:15Z loewis $"
     8__revision__ = "$Id$"
    119
    1210import os
    13 from types import StringType
    1411from distutils.core import Command
    1512from distutils.util import change_root, convert_path
    1613
    17 class install_data (Command):
     14class install_data(Command):
    1815
    1916    description = "install data files"
     
    3027    boolean_options = ['force']
    3128
    32     def initialize_options (self):
     29    def initialize_options(self):
    3330        self.install_dir = None
    3431        self.outfiles = []
    3532        self.root = None
    3633        self.force = 0
    37 
    3834        self.data_files = self.distribution.data_files
    3935        self.warn_dir = 1
    4036
    41     def finalize_options (self):
     37    def finalize_options(self):
    4238        self.set_undefined_options('install',
    4339                                   ('install_data', 'install_dir'),
     
    4642                                  )
    4743
    48     def run (self):
     44    def run(self):
    4945        self.mkpath(self.install_dir)
    5046        for f in self.data_files:
    51             if type(f) is StringType:
     47            if isinstance(f, str):
    5248                # it's a simple file, so copy it
    5349                f = convert_path(f)
     
    7975                        self.outfiles.append(out)
    8076
    81     def get_inputs (self):
     77    def get_inputs(self):
    8278        return self.data_files or []
    8379
    84     def get_outputs (self):
     80    def get_outputs(self):
    8581        return self.outfiles
  • python/trunk/Lib/distutils/command/install_headers.py

    r2 r391  
    44files to the Python include directory."""
    55
    6 # This module should be kept compatible with Python 2.1.
    7 
    8 __revision__ = "$Id: install_headers.py 61000 2008-02-23 17:40:11Z christian.heimes $"
     6__revision__ = "$Id$"
    97
    108from distutils.core import Command
    119
    1210
    13 class install_headers (Command):
     11# XXX force is never used
     12class install_headers(Command):
    1413
    1514    description = "install C/C++ header files"
     
    2322    boolean_options = ['force']
    2423
    25     def initialize_options (self):
     24    def initialize_options(self):
    2625        self.install_dir = None
    2726        self.force = 0
    2827        self.outfiles = []
    2928
    30     def finalize_options (self):
     29    def finalize_options(self):
    3130        self.set_undefined_options('install',
    3231                                   ('install_headers', 'install_dir'),
     
    3433
    3534
    36     def run (self):
     35    def run(self):
    3736        headers = self.distribution.headers
    3837        if not headers:
     
    4443            self.outfiles.append(out)
    4544
    46     def get_inputs (self):
     45    def get_inputs(self):
    4746        return self.distribution.headers or []
    4847
    49     def get_outputs (self):
     48    def get_outputs(self):
    5049        return self.outfiles
    5150
  • python/trunk/Lib/distutils/command/install_lib.py

    r2 r391  
    1 # This module should be kept compatible with Python 2.1.
    2 
    3 __revision__ = "$Id: install_lib.py 77376 2010-01-08 23:27:23Z tarek.ziade $"
     1"""distutils.command.install_lib
     2
     3Implements the Distutils 'install_lib' command
     4(install all Python modules)."""
     5
     6__revision__ = "$Id$"
    47
    58import os
    6 from types import IntType
    79import sys
    810
     
    1719    PYTHON_SOURCE_EXTENSION = ".py"
    1820
    19 class install_lib (Command):
     21class install_lib(Command):
    2022
    2123    description = "install all Python modules (extensions and pure Python)"
     
    5153    negative_opt = {'no-compile' : 'compile'}
    5254
    53 
    54     def initialize_options (self):
     55    def initialize_options(self):
    5556        # let the 'install' command dictate our installation directory
    5657        self.install_dir = None
     
    6162        self.skip_build = None
    6263
    63     def finalize_options (self):
    64 
     64    def finalize_options(self):
    6565        # Get all the information we need to install pure Python modules
    6666        # from the umbrella 'install' command -- build (source) directory,
     
    8080            self.optimize = 0
    8181
    82         if type(self.optimize) is not IntType:
     82        if not isinstance(self.optimize, int):
    8383            try:
    8484                self.optimize = int(self.optimize)
     
    8888                raise DistutilsOptionError, "optimize must be 0, 1, or 2"
    8989
    90     def run (self):
    91 
     90    def run(self):
    9291        # Make sure we have built everything we need first
    9392        self.build()
     
    102101            self.byte_compile(outfiles)
    103102
    104     # run ()
    105 
    106 
    107103    # -- Top-level worker functions ------------------------------------
    108104    # (called from 'run()')
    109105
    110     def build (self):
     106    def build(self):
    111107        if not self.skip_build:
    112108            if self.distribution.has_pure_modules():
     
    115111                self.run_command('build_ext')
    116112
    117     def install (self):
     113    def install(self):
    118114        if os.path.isdir(self.build_dir):
    119115            outfiles = self.copy_tree(self.build_dir, self.install_dir)
     
    124120        return outfiles
    125121
    126     def byte_compile (self, files):
     122    def byte_compile(self, files):
    127123        if sys.dont_write_bytecode:
    128124            self.warn('byte-compiling is disabled, skipping.')
     
    149145    # -- Utility methods -----------------------------------------------
    150146
    151     def _mutate_outputs (self, has_any, build_cmd, cmd_option, output_dir):
    152 
     147    def _mutate_outputs(self, has_any, build_cmd, cmd_option, output_dir):
    153148        if not has_any:
    154149            return []
     
    165160        return outputs
    166161
    167     # _mutate_outputs ()
    168 
    169     def _bytecode_filenames (self, py_filenames):
     162    def _bytecode_filenames(self, py_filenames):
    170163        bytecode_files = []
    171164        for py_file in py_filenames:
     
    187180    # (called by outsiders)
    188181
    189     def get_outputs (self):
     182    def get_outputs(self):
    190183        """Return the list of files that would be installed if this command
    191184        were actually run.  Not affected by the "dry-run" flag or whether
     
    208201        return pure_outputs + bytecode_outputs + ext_outputs
    209202
    210     # get_outputs ()
    211 
    212     def get_inputs (self):
     203    def get_inputs(self):
    213204        """Get the list of files that are input to this command, ie. the
    214205        files that get installed as they are named in the build tree.
     
    227218
    228219        return inputs
    229 
    230 # class install_lib
  • python/trunk/Lib/distutils/command/install_scripts.py

    r2 r391  
    66# contributed by Bastian Kleineidam
    77
    8 # This module should be kept compatible with Python 2.1.
    9 
    10 __revision__ = "$Id: install_scripts.py 37828 2004-11-10 22:23:15Z loewis $"
     8__revision__ = "$Id$"
    119
    1210import os
  • python/trunk/Lib/distutils/command/register.py

    r2 r391  
    66# created 2002/10/21, Richard Jones
    77
    8 __revision__ = "$Id: register.py 77719 2010-01-24 00:57:20Z tarek.ziade $"
    9 
    10 import os, string, urllib2, getpass, urlparse
    11 import StringIO
     8__revision__ = "$Id$"
     9
     10import urllib2
     11import getpass
     12import urlparse
     13from warnings import warn
    1214
    1315from distutils.core import PyPIRCCommand
    14 from distutils.errors import *
    1516from distutils import log
    1617
     
    2122        ('list-classifiers', None,
    2223         'list the valid Trove classifiers'),
     24        ('strict', None ,
     25         'Will stop the registering if the meta-data are not fully compliant')
    2326        ]
    2427    boolean_options = PyPIRCCommand.boolean_options + [
    25         'verify', 'list-classifiers']
     28        'verify', 'list-classifiers', 'strict']
     29
     30    sub_commands = [('check', lambda self: True)]
    2631
    2732    def initialize_options(self):
    2833        PyPIRCCommand.initialize_options(self)
    2934        self.list_classifiers = 0
     35        self.strict = 0
     36
     37    def finalize_options(self):
     38        PyPIRCCommand.finalize_options(self)
     39        # setting options for the `check` subcommand
     40        check_options = {'strict': ('register', self.strict),
     41                         'restructuredtext': ('register', 1)}
     42        self.distribution.command_options['check'] = check_options
    3043
    3144    def run(self):
    3245        self.finalize_options()
    3346        self._set_config()
    34         self.check_metadata()
     47
     48        # Run sub commands
     49        for cmd_name in self.get_sub_commands():
     50            self.run_command(cmd_name)
     51
    3552        if self.dry_run:
    3653            self.verify_metadata()
     
    4158
    4259    def check_metadata(self):
    43         """Ensure that all required elements of meta-data (name, version,
    44            URL, (author and author_email) or (maintainer and
    45            maintainer_email)) are supplied by the Distribution object; warn if
    46            any are missing.
    47         """
    48         metadata = self.distribution.metadata
    49 
    50         missing = []
    51         for attr in ('name', 'version', 'url'):
    52             if not (hasattr(metadata, attr) and getattr(metadata, attr)):
    53                 missing.append(attr)
    54 
    55         if missing:
    56             self.warn("missing required meta-data: " +
    57                       string.join(missing, ", "))
    58 
    59         if metadata.author:
    60             if not metadata.author_email:
    61                 self.warn("missing meta-data: if 'author' supplied, " +
    62                           "'author_email' must be supplied too")
    63         elif metadata.maintainer:
    64             if not metadata.maintainer_email:
    65                 self.warn("missing meta-data: if 'maintainer' supplied, " +
    66                           "'maintainer_email' must be supplied too")
    67         else:
    68             self.warn("missing meta-data: either (author and author_email) " +
    69                       "or (maintainer and maintainer_email) " +
    70                       "must be supplied")
     60        """Deprecated API."""
     61        warn("distutils.command.register.check_metadata is deprecated, \
     62              use the check command instead", PendingDeprecationWarning)
     63        check = self.distribution.get_command_obj('check')
     64        check.ensure_finalized()
     65        check.strict = self.strict
     66        check.restructuredtext = 1
     67        check.run()
    7168
    7269    def _set_config(self):
     
    9188        '''
    9289        response = urllib2.urlopen(self.repository+'?:action=list_classifiers')
    93         print response.read()
     90        log.info(response.read())
    9491
    9592    def verify_metadata(self):
     
    9895        # send the info to the server and report the result
    9996        (code, result) = self.post_to_server(self.build_post_data('verify'))
    100         print 'Server response (%s): %s'%(code, result)
     97        log.info('Server response (%s): %s' % (code, result))
    10198
    10299
     
    174171
    175172            # possibly save the login
    176             if not self.has_config and code == 200:
    177                 self.announce(('I can store your PyPI login so future '
    178                                'submissions will be faster.'), log.INFO)
    179                 self.announce('(the login will be stored in %s)' % \
    180                               self._get_rc_file(), log.INFO)
    181 
    182                 choice = 'X'
    183                 while choice.lower() not in 'yn':
    184                     choice = raw_input('Save your login (y/N)?')
    185                     if not choice:
    186                         choice = 'n'
    187                 if choice.lower() == 'y':
    188                     self._store_pypirc(username, password)
     173            if code == 200:
     174                if self.has_config:
     175                    # sharing the password in the distribution instance
     176                    # so the upload command can reuse it
     177                    self.distribution.password = password
     178                else:
     179                    self.announce(('I can store your PyPI login so future '
     180                                   'submissions will be faster.'), log.INFO)
     181                    self.announce('(the login will be stored in %s)' % \
     182                                  self._get_rc_file(), log.INFO)
     183                    choice = 'X'
     184                    while choice.lower() not in 'yn':
     185                        choice = raw_input('Save your login (y/N)?')
     186                        if not choice:
     187                            choice = 'n'
     188                    if choice.lower() == 'y':
     189                        self._store_pypirc(username, password)
    189190
    190191        elif choice == '2':
     
    207208            code, result = self.post_to_server(data)
    208209            if code != 200:
    209                 print 'Server response (%s): %s'%(code, result)
     210                log.info('Server response (%s): %s' % (code, result))
    210211            else:
    211                 print 'You will receive an email shortly.'
    212                 print 'Follow the instructions in it to complete registration.'
     212                log.info('You will receive an email shortly.')
     213                log.info(('Follow the instructions in it to '
     214                          'complete registration.'))
    213215        elif choice == '3':
    214216            data = {':action': 'password_reset'}
     
    217219                data['email'] = raw_input('Your email address: ')
    218220            code, result = self.post_to_server(data)
    219             print 'Server response (%s): %s'%(code, result)
     221            log.info('Server response (%s): %s' % (code, result))
    220222
    221223    def build_post_data(self, action):
     
    250252        ''' Post a query to the server, and return a string response.
    251253        '''
    252         self.announce('Registering %s to %s' % (data['name'],
    253                                                 self.repository), log.INFO)
     254        if 'name' in data:
     255            self.announce('Registering %s to %s' % (data['name'],
     256                                                   self.repository),
     257                                                   log.INFO)
    254258        # Build up the MIME payload for the urllib2 POST data
    255259        boundary = '--------------GHSKFJDLGDS7543FJKLFHRE75642756743254'
    256260        sep_boundary = '\n--' + boundary
    257261        end_boundary = sep_boundary + '--'
    258         body = StringIO.StringIO()
     262        chunks = []
    259263        for key, value in data.items():
    260264            # handle multiple entries for the same name
     
    262266                value = [value]
    263267            for value in value:
    264                 body.write(sep_boundary)
    265                 body.write('\nContent-Disposition: form-data; name="%s"'%key)
    266                 body.write("\n\n")
    267                 body.write(value)
     268                chunks.append(sep_boundary)
     269                chunks.append('\nContent-Disposition: form-data; name="%s"'%key)
     270                chunks.append("\n\n")
     271                chunks.append(value)
    268272                if value and value[-1] == '\r':
    269                     body.write('\n')  # write an extra newline (lurve Macs)
    270         body.write(end_boundary)
    271         body.write("\n")
    272         body = body.getvalue()
     273                    chunks.append('\n')  # write an extra newline (lurve Macs)
     274        chunks.append(end_boundary)
     275        chunks.append("\n")
     276
     277        # chunks may be bytes (str) or unicode objects that we need to encode
     278        body = []
     279        for chunk in chunks:
     280            if isinstance(chunk, unicode):
     281                body.append(chunk.encode('utf-8'))
     282            else:
     283                body.append(chunk)
     284
     285        body = ''.join(body)
    273286
    274287        # build the Request
     
    297310            result = 200, 'OK'
    298311        if self.show_response:
    299             print '-'*75, data, '-'*75
     312            dashes = '-' * 75
     313            self.announce('%s%s%s' % (dashes, data, dashes))
     314
    300315        return result
  • python/trunk/Lib/distutils/command/sdist.py

    r2 r391  
    33Implements the Distutils 'sdist' command (create a source distribution)."""
    44
    5 # This module should be kept compatible with Python 2.1.
    6 
    7 __revision__ = "$Id: sdist.py 68968 2009-01-26 17:20:15Z tarek.ziade $"
    8 
    9 import os, string
     5__revision__ = "$Id$"
     6
     7import os
     8import string
    109import sys
    11 from types import *
    1210from glob import glob
     11from warnings import warn
     12
    1313from distutils.core import Command
    1414from distutils import dir_util, dep_util, file_util, archive_util
    1515from distutils.text_file import TextFile
    16 from distutils.errors import *
     16from distutils.errors import (DistutilsPlatformError, DistutilsOptionError,
     17                              DistutilsTemplateError)
    1718from distutils.filelist import FileList
    1819from distutils import log
    19 
    20 
    21 def show_formats ():
     20from distutils.util import convert_path
     21
     22def show_formats():
    2223    """Print all possible values for the 'formats' option (used by
    2324    the "--help-formats" command-line option).
     
    2526    from distutils.fancy_getopt import FancyGetopt
    2627    from distutils.archive_util import ARCHIVE_FORMATS
    27     formats=[]
     28    formats = []
    2829    for format in ARCHIVE_FORMATS.keys():
    2930        formats.append(("formats=" + format, None,
    3031                        ARCHIVE_FORMATS[format][2]))
    3132    formats.sort()
    32     pretty_printer = FancyGetopt(formats)
    33     pretty_printer.print_help(
     33    FancyGetopt(formats).print_help(
    3434        "List of available source distribution formats:")
    3535
    36 class sdist (Command):
     36class sdist(Command):
    3737
    3838    description = "create a source distribution (tarball, zip file, etc.)"
     39
     40    def checking_metadata(self):
     41        """Callable used for the check sub-command.
     42
     43        Placed here so user_options can view it"""
     44        return self.metadata_check
    3945
    4046    user_options = [
     
    5864         "(implies --force-manifest)"),
    5965        ('force-manifest', 'f',
    60          "forcibly regenerate the manifest and carry on as usual"),
     66         "forcibly regenerate the manifest and carry on as usual. "
     67         "Deprecated: now the manifest is always regenerated."),
    6168        ('formats=', None,
    6269         "formats for source distribution (comma-separated list)"),
     
    6774         "directory to put the source distribution archive(s) in "
    6875         "[default: dist]"),
     76        ('metadata-check', None,
     77         "Ensure that all required elements of meta-data "
     78         "are supplied. Warn if any missing. [default]"),
     79        ('owner=', 'u',
     80         "Owner name used when creating a tar file [default: current user]"),
     81        ('group=', 'g',
     82         "Group name used when creating a tar file [default: current group]"),
    6983        ]
    7084
    7185    boolean_options = ['use-defaults', 'prune',
    7286                       'manifest-only', 'force-manifest',
    73                        'keep-temp']
     87                       'keep-temp', 'metadata-check']
    7488
    7589    help_options = [
     
    8195                    'no-prune': 'prune' }
    8296
    83     default_format = { 'posix': 'gztar',
    84                        'nt': 'zip' }
    85 
    86     def initialize_options (self):
     97    default_format = {'posix': 'gztar',
     98                      'nt': 'zip' }
     99
     100    sub_commands = [('check', checking_metadata)]
     101
     102    def initialize_options(self):
    87103        # 'template' and 'manifest' are, respectively, the names of
    88104        # the manifest template and manifest file.
     
    103119
    104120        self.archive_files = None
    105 
    106 
    107     def finalize_options (self):
     121        self.metadata_check = 1
     122        self.owner = None
     123        self.group = None
     124
     125    def finalize_options(self):
    108126        if self.manifest is None:
    109127            self.manifest = "MANIFEST"
     
    128146            self.dist_dir = "dist"
    129147
    130 
    131     def run (self):
    132 
     148    def run(self):
    133149        # 'filelist' contains the list of files that will make up the
    134150        # manifest
    135151        self.filelist = FileList()
    136152
    137         # Ensure that all required meta-data is given; warn if not (but
    138         # don't die, it's not *that* serious!)
    139         self.check_metadata()
     153        # Run sub commands
     154        for cmd_name in self.get_sub_commands():
     155            self.run_command(cmd_name)
    140156
    141157        # Do whatever it takes to get the list of files to process
     
    152168        self.make_distribution()
    153169
    154 
    155     def check_metadata (self):
    156         """Ensure that all required elements of meta-data (name, version,
    157         URL, (author and author_email) or (maintainer and
    158         maintainer_email)) are supplied by the Distribution object; warn if
    159         any are missing.
    160         """
    161         metadata = self.distribution.metadata
    162 
    163         missing = []
    164         for attr in ('name', 'version', 'url'):
    165             if not (hasattr(metadata, attr) and getattr(metadata, attr)):
    166                 missing.append(attr)
    167 
    168         if missing:
    169             self.warn("missing required meta-data: " +
    170                       string.join(missing, ", "))
    171 
    172         if metadata.author:
    173             if not metadata.author_email:
    174                 self.warn("missing meta-data: if 'author' supplied, " +
    175                           "'author_email' must be supplied too")
    176         elif metadata.maintainer:
    177             if not metadata.maintainer_email:
    178                 self.warn("missing meta-data: if 'maintainer' supplied, " +
    179                           "'maintainer_email' must be supplied too")
    180         else:
    181             self.warn("missing meta-data: either (author and author_email) " +
    182                       "or (maintainer and maintainer_email) " +
    183                       "must be supplied")
    184 
    185     # check_metadata ()
    186 
    187 
    188     def get_file_list (self):
     170    def check_metadata(self):
     171        """Deprecated API."""
     172        warn("distutils.command.sdist.check_metadata is deprecated, \
     173              use the check command instead", PendingDeprecationWarning)
     174        check = self.distribution.get_command_obj('check')
     175        check.ensure_finalized()
     176        check.run()
     177
     178    def get_file_list(self):
    189179        """Figure out the list of files to include in the source
    190180        distribution, and put it in 'self.filelist'.  This might involve
    191181        reading the manifest template (and writing the manifest), or just
    192182        reading the manifest, or just using the default file set -- it all
    193         depends on the user's options and the state of the filesystem.
    194         """
    195 
    196         # If we have a manifest template, see if it's newer than the
    197         # manifest; if so, we'll regenerate the manifest.
     183        depends on the user's options.
     184        """
     185        # new behavior when using a template:
     186        # the file list is recalculated every time because
     187        # even if MANIFEST.in or setup.py are not changed
     188        # the user might have added some files in the tree that
     189        # need to be included.
     190        #
     191        #  This makes --force the default and only behavior with templates.
    198192        template_exists = os.path.isfile(self.template)
    199         if template_exists:
    200             template_newer = dep_util.newer(self.template, self.manifest)
    201 
    202         # The contents of the manifest file almost certainly depend on the
    203         # setup script as well as the manifest template -- so if the setup
    204         # script is newer than the manifest, we'll regenerate the manifest
    205         # from the template.  (Well, not quite: if we already have a
    206         # manifest, but there's no template -- which will happen if the
    207         # developer elects to generate a manifest some other way -- then we
    208         # can't regenerate the manifest, so we don't.)
    209         self.debug_print("checking if %s newer than %s" %
    210                          (self.distribution.script_name, self.manifest))
    211         setup_newer = dep_util.newer(self.distribution.script_name,
    212                                      self.manifest)
    213 
    214         # cases:
    215         #   1) no manifest, template exists: generate manifest
    216         #      (covered by 2a: no manifest == template newer)
    217         #   2) manifest & template exist:
    218         #      2a) template or setup script newer than manifest:
    219         #          regenerate manifest
    220         #      2b) manifest newer than both:
    221         #          do nothing (unless --force or --manifest-only)
    222         #   3) manifest exists, no template:
    223         #      do nothing (unless --force or --manifest-only)
    224         #   4) no manifest, no template: generate w/ warning ("defaults only")
    225 
    226         manifest_outofdate = (template_exists and
    227                               (template_newer or setup_newer))
    228         force_regen = self.force_manifest or self.manifest_only
    229         manifest_exists = os.path.isfile(self.manifest)
    230         neither_exists = (not template_exists and not manifest_exists)
    231 
    232         # Regenerate the manifest if necessary (or if explicitly told to)
    233         if manifest_outofdate or neither_exists or force_regen:
    234             if not template_exists:
    235                 self.warn(("manifest template '%s' does not exist " +
    236                            "(using default file list)") %
    237                           self.template)
    238             self.filelist.findall()
    239 
    240             if self.use_defaults:
    241                 self.add_defaults()
    242             if template_exists:
    243                 self.read_template()
    244             if self.prune:
    245                 self.prune_file_list()
    246 
     193        if not template_exists and self._manifest_is_not_generated():
     194            self.read_manifest()
    247195            self.filelist.sort()
    248196            self.filelist.remove_duplicates()
    249             self.write_manifest()
    250 
    251         # Don't regenerate the manifest, just read it in.
    252         else:
    253             self.read_manifest()
    254 
    255     # get_file_list ()
    256 
    257 
    258     def add_defaults (self):
     197            return
     198
     199        if not template_exists:
     200            self.warn(("manifest template '%s' does not exist " +
     201                        "(using default file list)") %
     202                        self.template)
     203        self.filelist.findall()
     204
     205        if self.use_defaults:
     206            self.add_defaults()
     207
     208        if template_exists:
     209            self.read_template()
     210
     211        if self.prune:
     212            self.prune_file_list()
     213
     214        self.filelist.sort()
     215        self.filelist.remove_duplicates()
     216        self.write_manifest()
     217
     218    def add_defaults(self):
    259219        """Add all the default files to self.filelist:
    260220          - README or README.txt
     
    262222          - test/test*.py
    263223          - all pure Python modules mentioned in setup script
     224          - all files pointed by package_data (build_py)
     225          - all files defined in data_files.
     226          - all files defined as scripts.
    264227          - all C sources listed as part of extensions or C libraries
    265228            in the setup script (doesn't catch C headers!)
     
    270233        standards = [('README', 'README.txt'), self.distribution.script_name]
    271234        for fn in standards:
    272             if type(fn) is TupleType:
     235            if isinstance(fn, tuple):
    273236                alts = fn
    274237                got_it = 0
     
    294257                self.filelist.extend(files)
    295258
     259        # build_py is used to get:
     260        #  - python modules
     261        #  - files defined in package_data
     262        build_py = self.get_finalized_command('build_py')
     263
     264        # getting python files
    296265        if self.distribution.has_pure_modules():
    297             build_py = self.get_finalized_command('build_py')
    298266            self.filelist.extend(build_py.get_source_files())
     267
     268        # getting package_data files
     269        # (computed in build_py.data_files by build_py.finalize_options)
     270        for pkg, src_dir, build_dir, filenames in build_py.data_files:
     271            for filename in filenames:
     272                self.filelist.append(os.path.join(src_dir, filename))
     273
     274        # getting distribution.data_files
     275        if self.distribution.has_data_files():
     276            for item in self.distribution.data_files:
     277                if isinstance(item, str): # plain file
     278                    item = convert_path(item)
     279                    if os.path.isfile(item):
     280                        self.filelist.append(item)
     281                else:    # a (dirname, filenames) tuple
     282                    dirname, filenames = item
     283                    for f in filenames:
     284                        f = convert_path(f)
     285                        if os.path.isfile(f):
     286                            self.filelist.append(f)
    299287
    300288        if self.distribution.has_ext_modules():
     
    310298            self.filelist.extend(build_scripts.get_source_files())
    311299
    312     # add_defaults ()
    313 
    314 
    315     def read_template (self):
     300    def read_template(self):
    316301        """Read and parse manifest template file named by self.template.
    317302
     
    328313                            collapse_join=1)
    329314
    330         while 1:
    331             line = template.readline()
    332             if line is None:            # end of file
    333                 break
    334 
    335             try:
    336                 self.filelist.process_template_line(line)
    337             except DistutilsTemplateError, msg:
    338                 self.warn("%s, line %d: %s" % (template.filename,
    339                                                template.current_line,
    340                                                msg))
    341 
    342     # read_template ()
    343 
    344 
    345     def prune_file_list (self):
     315        try:
     316            while 1:
     317                line = template.readline()
     318                if line is None:            # end of file
     319                    break
     320
     321                try:
     322                    self.filelist.process_template_line(line)
     323                # the call above can raise a DistutilsTemplateError for
     324                # malformed lines, or a ValueError from the lower-level
     325                # convert_path function
     326                except (DistutilsTemplateError, ValueError) as msg:
     327                    self.warn("%s, line %d: %s" % (template.filename,
     328                                                   template.current_line,
     329                                                   msg))
     330        finally:
     331            template.close()
     332
     333    def prune_file_list(self):
    346334        """Prune off branches that might slip into the file list as created
    347335        by 'read_template()', but really don't belong there:
     
    369357        self.filelist.exclude_pattern(vcs_ptrn, is_regex=1)
    370358
    371     def write_manifest (self):
     359    def write_manifest(self):
    372360        """Write the file list in 'self.filelist' (presumably as filled in
    373361        by 'add_defaults()' and 'read_template()') to the manifest file
    374362        named by 'self.manifest'.
    375363        """
    376         self.execute(file_util.write_file,
    377                      (self.manifest, self.filelist.files),
     364        if self._manifest_is_not_generated():
     365            log.info("not writing to manually maintained "
     366                     "manifest file '%s'" % self.manifest)
     367            return
     368
     369        content = self.filelist.files[:]
     370        content.insert(0, '# file GENERATED by distutils, do NOT edit')
     371        self.execute(file_util.write_file, (self.manifest, content),
    378372                     "writing manifest file '%s'" % self.manifest)
    379373
    380     # write_manifest ()
    381 
    382 
    383     def read_manifest (self):
     374    def _manifest_is_not_generated(self):
     375        # check for special comment used in 2.7.1 and higher
     376        if not os.path.isfile(self.manifest):
     377            return False
     378
     379        fp = open(self.manifest, 'rU')
     380        try:
     381            first_line = fp.readline()
     382        finally:
     383            fp.close()
     384        return first_line != '# file GENERATED by distutils, do NOT edit\n'
     385
     386    def read_manifest(self):
    384387        """Read the manifest file (named by 'self.manifest') and use it to
    385388        fill in 'self.filelist', the list of files to include in the source
     
    388391        log.info("reading manifest file '%s'", self.manifest)
    389392        manifest = open(self.manifest)
    390         while 1:
    391             line = manifest.readline()
    392             if line == '':              # end of file
    393                 break
    394             if line[-1] == '\n':
    395                 line = line[0:-1]
     393        for line in manifest:
     394            # ignore comments and blank lines
     395            line = line.strip()
     396            if line.startswith('#') or not line:
     397                continue
    396398            self.filelist.append(line)
    397399        manifest.close()
    398400
    399     # read_manifest ()
    400 
    401 
    402     def make_release_tree (self, base_dir, files):
     401    def make_release_tree(self, base_dir, files):
    403402        """Create the directory tree that will become the source
    404403        distribution archive.  All directories implied by the filenames in
     
    442441        self.distribution.metadata.write_pkg_info(base_dir)
    443442
    444     # make_release_tree ()
    445 
    446     def make_distribution (self):
     443    def make_distribution(self):
    447444        """Create the source distribution(s).  First, we create the release
    448445        tree with 'make_release_tree()'; then, we create all required
     
    464461
    465462        for fmt in self.formats:
    466             file = self.make_archive(base_name, fmt, base_dir=base_dir)
     463            file = self.make_archive(base_name, fmt, base_dir=base_dir,
     464                                     owner=self.owner, group=self.group)
    467465            archive_files.append(file)
    468466            self.distribution.dist_files.append(('sdist', '', file))
     
    473471            dir_util.remove_tree(base_dir, dry_run=self.dry_run)
    474472
    475     def get_archive_files (self):
     473    def get_archive_files(self):
    476474        """Return the list of archive files created when the command
    477475        was run, or None if the command hasn't run yet.
    478476        """
    479477        return self.archive_files
    480 
    481 # class sdist
  • python/trunk/Lib/distutils/command/upload.py

    r2 r391  
    22
    33Implements the Distutils 'upload' subcommand (upload package to PyPI)."""
     4import os
     5import socket
     6import platform
     7from urllib2 import urlopen, Request, HTTPError
     8from base64 import standard_b64encode
     9import urlparse
     10import cStringIO as StringIO
     11from hashlib import md5
    412
    5 from distutils.errors import *
     13from distutils.errors import DistutilsOptionError
    614from distutils.core import PyPIRCCommand
    715from distutils.spawn import spawn
    816from distutils import log
    9 from hashlib import md5
    10 import os
    11 import socket
    12 import platform
    13 import httplib
    14 from base64 import standard_b64encode
    15 import urlparse
    16 import cStringIO as StringIO
    17 from ConfigParser import ConfigParser
    18 
    1917
    2018class upload(PyPIRCCommand):
     
    5149            self.realm = config['realm']
    5250
     51        # getting the password from the distribution
     52        # if previously set by the register command
     53        if not self.password and self.distribution.password:
     54            self.password = self.distribution.password
     55
    5356    def run(self):
    5457        if not self.distribution.dist_files:
     
    5861
    5962    def upload_file(self, command, pyversion, filename):
     63        # Makes sure the repository URL is compliant
     64        schema, netloc, url, params, query, fragments = \
     65            urlparse.urlparse(self.repository)
     66        if params or query or fragments:
     67            raise AssertionError("Incompatible url %s" % self.repository)
     68
     69        if schema not in ('http', 'https'):
     70            raise AssertionError("unsupported schema " + schema)
     71
    6072        # Sign if requested
    6173        if self.sign:
     
    6880        # Fill in the data - send all the meta-data in case we need to
    6981        # register a new release
    70         content = open(filename,'rb').read()
     82        f = open(filename,'rb')
     83        try:
     84            content = f.read()
     85        finally:
     86            f.close()
    7187        meta = self.distribution.metadata
    7288        data = {
     
    126142        for key, value in data.items():
    127143            # handle multiple entries for the same name
    128             if type(value) != type([]):
     144            if not isinstance(value, list):
    129145                value = [value]
    130146            for value in value:
    131                 if type(value) is tuple:
     147                if isinstance(value, tuple):
    132148                    fn = ';filename="%s"' % value[0]
    133149                    value = value[1]
     
    149165
    150166        # build the Request
    151         # We can't use urllib2 since we need to send the Basic
    152         # auth right with the first request
    153         schema, netloc, url, params, query, fragments = \
    154             urlparse.urlparse(self.repository)
    155         assert not params and not query and not fragments
    156         if schema == 'http':
    157             http = httplib.HTTPConnection(netloc)
    158         elif schema == 'https':
    159             http = httplib.HTTPSConnection(netloc)
    160         else:
    161             raise AssertionError, "unsupported schema "+schema
     167        headers = {'Content-type':
     168                        'multipart/form-data; boundary=%s' % boundary,
     169                   'Content-length': str(len(body)),
     170                   'Authorization': auth}
    162171
    163         data = ''
    164         loglevel = log.INFO
     172        request = Request(self.repository, data=body,
     173                          headers=headers)
     174        # send the data
    165175        try:
    166             http.connect()
    167             http.putrequest("POST", url)
    168             http.putheader('Content-type',
    169                            'multipart/form-data; boundary=%s'%boundary)
    170             http.putheader('Content-length', str(len(body)))
    171             http.putheader('Authorization', auth)
    172             http.endheaders()
    173             http.send(body)
     176            result = urlopen(request)
     177            status = result.getcode()
     178            reason = result.msg
     179            if self.show_response:
     180                msg = '\n'.join(('-' * 75, r.read(), '-' * 75))
     181                self.announce(msg, log.INFO)
    174182        except socket.error, e:
    175183            self.announce(str(e), log.ERROR)
    176184            return
     185        except HTTPError, e:
     186            status = e.code
     187            reason = e.msg
    177188
    178         r = http.getresponse()
    179         if r.status == 200:
    180             self.announce('Server response (%s): %s' % (r.status, r.reason),
     189        if status == 200:
     190            self.announce('Server response (%s): %s' % (status, reason),
    181191                          log.INFO)
    182192        else:
    183             self.announce('Upload failed (%s): %s' % (r.status, r.reason),
     193            self.announce('Upload failed (%s): %s' % (status, reason),
    184194                          log.ERROR)
    185         if self.show_response:
    186             print '-'*75, r.read(), '-'*75
Note: See TracChangeset for help on using the changeset viewer.