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:
2 edited

Legend:

Unmodified
Added
Removed
  • python/trunk

  • python/trunk/Lib/distutils/util.py

    r382 r391  
    55"""
    66
    7 __revision__ = "$Id: util.py 77376 2010-01-08 23:27:23Z tarek.ziade $"
     7__revision__ = "$Id$"
    88
    99import sys, os, string, re
     
    5252        return sys.platform
    5353
     54    # Set for cross builds explicitly
     55    if "_PYTHON_HOST_PLATFORM" in os.environ:
     56        return os.environ["_PYTHON_HOST_PLATFORM"]
     57
    5458    if os.name != "posix" or not hasattr(os, 'uname'):
    5559        # XXX what about the architecture? NT is Intel or Alpha,
     
    7781            osname = "solaris"
    7882            release = "%d.%s" % (int(release[0]) - 3, release[2:])
     83            # We can't use "platform.architecture()[0]" because a
     84            # bootstrap problem. We use a dict to get an error
     85            # if some suspicious happens.
     86            bitness = {2147483647:"32bit", 9223372036854775807:"64bit"}
     87            machine += ".%s" % bitness[sys.maxint]
    7988        # fall through to standard osname-release-machine representation
    8089    elif osname[:4] == "irix":              # could be "irix64"!
     
    8998            release = m.group()
    9099    elif osname[:6] == "darwin":
    91         #
    92         # For our purposes, we'll assume that the system version from
    93         # distutils' perspective is what MACOSX_DEPLOYMENT_TARGET is set
    94         # to. This makes the compatibility story a bit more sane because the
    95         # machine is going to compile and link as if it were
    96         # MACOSX_DEPLOYMENT_TARGET.
    97         from distutils.sysconfig import get_config_vars
    98         cfgvars = get_config_vars()
    99 
    100         macver = os.environ.get('MACOSX_DEPLOYMENT_TARGET')
    101         if not macver:
    102             macver = cfgvars.get('MACOSX_DEPLOYMENT_TARGET')
    103 
    104         if 1:
    105             # Always calculate the release of the running machine,
    106             # needed to determine if we can build fat binaries or not.
    107 
    108             macrelease = macver
    109             # Get the system version. Reading this plist is a documented
    110             # way to get the system version (see the documentation for
    111             # the Gestalt Manager)
    112             try:
    113                 f = open('/System/Library/CoreServices/SystemVersion.plist')
    114             except IOError:
    115                 # We're on a plain darwin box, fall back to the default
    116                 # behaviour.
    117                 pass
    118             else:
    119                 m = re.search(
    120                         r'<key>ProductUserVisibleVersion</key>\s*' +
    121                         r'<string>(.*?)</string>', f.read())
    122                 f.close()
    123                 if m is not None:
    124                     macrelease = '.'.join(m.group(1).split('.')[:2])
    125                 # else: fall back to the default behaviour
    126 
    127         if not macver:
    128             macver = macrelease
    129 
    130         if macver:
    131             from distutils.sysconfig import get_config_vars
    132             release = macver
    133             osname = "macosx"
    134 
    135             if (macrelease + '.') >= '10.4.' and \
    136                     '-arch' in get_config_vars().get('CFLAGS', '').strip():
    137                 # The universal build will build fat binaries, but not on
    138                 # systems before 10.4
    139                 #
    140                 # Try to detect 4-way universal builds, those have machine-type
    141                 # 'universal' instead of 'fat'.
    142 
    143                 machine = 'fat'
    144                 cflags = get_config_vars().get('CFLAGS')
    145 
    146                 archs = re.findall('-arch\s+(\S+)', cflags)
    147                 archs.sort()
    148                 archs = tuple(archs)
    149 
    150                 if len(archs) == 1:
    151                     machine = archs[0]
    152                 elif archs == ('i386', 'ppc'):
    153                     machine = 'fat'
    154                 elif archs == ('i386', 'x86_64'):
    155                     machine = 'intel'
    156                 elif archs == ('i386', 'ppc', 'x86_64'):
    157                     machine = 'fat3'
    158                 elif archs == ('ppc64', 'x86_64'):
    159                     machine = 'fat64'
    160                 elif archs == ('i386', 'ppc', 'ppc64', 'x86_64'):
    161                     machine = 'universal'
    162                 else:
    163                     raise ValueError(
    164                        "Don't know machine value for archs=%r"%(archs,))
    165 
    166             elif machine == 'i386':
    167                 # On OSX the machine type returned by uname is always the
    168                 # 32-bit variant, even if the executable architecture is
    169                 # the 64-bit variant
    170                 if sys.maxint >= 2**32:
    171                     machine = 'x86_64'
    172 
    173             elif machine in ('PowerPC', 'Power_Macintosh'):
    174                 # Pick a sane name for the PPC architecture.
    175                 machine = 'ppc'
    176 
    177                 # See 'i386' case
    178                 if sys.maxint >= 2**32:
    179                     machine = 'ppc64'
     100        import _osx_support, distutils.sysconfig
     101        osname, release, machine = _osx_support.get_platform_osx(
     102                                        distutils.sysconfig.get_config_vars(),
     103                                        osname, release, machine)
    180104
    181105    return "%s-%s-%s" % (osname, release, machine)
     
    207131    if not paths:
    208132        return os.curdir
    209     return apply(os.path.join, paths)
     133    return os.path.join(*paths)
    210134
    211135# convert_path ()
     
    238162            path = path[1:]
    239163        return os.path.join(new_root, path)
    240 
    241     elif os.name == 'mac':
    242         if not os.path.isabs(pathname):
    243             return os.path.join(new_root, pathname)
    244         else:
    245             # Chop off volume name from start of path
    246             elements = string.split(pathname, ":", 1)
    247             pathname = ":" + elements[1]
    248             return os.path.join(new_root, pathname)
    249164
    250165    else:
     
    410325    log.info(msg)
    411326    if not dry_run:
    412         apply(func, args)
     327        func(*args)
    413328
    414329
Note: See TracChangeset for help on using the changeset viewer.