Changeset 391 for python/trunk/Lib/distutils/util.py
- Timestamp:
- Mar 19, 2014, 11:31:01 PM (11 years ago)
- Location:
- python/trunk
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
python/trunk
-
Property svn:mergeinfo
set to
/python/vendor/Python-2.7.6 merged eligible /python/vendor/current merged eligible
-
Property svn:mergeinfo
set to
-
python/trunk/Lib/distutils/util.py
r382 r391 5 5 """ 6 6 7 __revision__ = "$Id : util.py 77376 2010-01-08 23:27:23Z tarek.ziade$"7 __revision__ = "$Id$" 8 8 9 9 import sys, os, string, re … … 52 52 return sys.platform 53 53 54 # Set for cross builds explicitly 55 if "_PYTHON_HOST_PLATFORM" in os.environ: 56 return os.environ["_PYTHON_HOST_PLATFORM"] 57 54 58 if os.name != "posix" or not hasattr(os, 'uname'): 55 59 # XXX what about the architecture? NT is Intel or Alpha, … … 77 81 osname = "solaris" 78 82 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] 79 88 # fall through to standard osname-release-machine representation 80 89 elif osname[:4] == "irix": # could be "irix64"! … … 89 98 release = m.group() 90 99 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) 180 104 181 105 return "%s-%s-%s" % (osname, release, machine) … … 207 131 if not paths: 208 132 return os.curdir 209 return apply(os.path.join,paths)133 return os.path.join(*paths) 210 134 211 135 # convert_path () … … 238 162 path = path[1:] 239 163 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 path246 elements = string.split(pathname, ":", 1)247 pathname = ":" + elements[1]248 return os.path.join(new_root, pathname)249 164 250 165 else: … … 410 325 log.info(msg) 411 326 if not dry_run: 412 apply(func,args)327 func(*args) 413 328 414 329
Note:
See TracChangeset
for help on using the changeset viewer.