Edit File by line
/home/barbar84/www/wp-conte.../plugins/sujqvwi/AnonR/smanonr..../lib64/python2....
File: _osx_support.py
"""Shared OS X support functions."""
[0] Fix | Delete
[1] Fix | Delete
import os
[2] Fix | Delete
import re
[3] Fix | Delete
import sys
[4] Fix | Delete
[5] Fix | Delete
__all__ = [
[6] Fix | Delete
'compiler_fixup',
[7] Fix | Delete
'customize_config_vars',
[8] Fix | Delete
'customize_compiler',
[9] Fix | Delete
'get_platform_osx',
[10] Fix | Delete
]
[11] Fix | Delete
[12] Fix | Delete
# configuration variables that may contain universal build flags,
[13] Fix | Delete
# like "-arch" or "-isdkroot", that may need customization for
[14] Fix | Delete
# the user environment
[15] Fix | Delete
_UNIVERSAL_CONFIG_VARS = ('CFLAGS', 'LDFLAGS', 'CPPFLAGS', 'BASECFLAGS',
[16] Fix | Delete
'BLDSHARED', 'LDSHARED', 'CC', 'CXX',
[17] Fix | Delete
'PY_CFLAGS', 'PY_LDFLAGS', 'PY_CPPFLAGS',
[18] Fix | Delete
'PY_CORE_CFLAGS')
[19] Fix | Delete
[20] Fix | Delete
# configuration variables that may contain compiler calls
[21] Fix | Delete
_COMPILER_CONFIG_VARS = ('BLDSHARED', 'LDSHARED', 'CC', 'CXX')
[22] Fix | Delete
[23] Fix | Delete
# prefix added to original configuration variable names
[24] Fix | Delete
_INITPRE = '_OSX_SUPPORT_INITIAL_'
[25] Fix | Delete
[26] Fix | Delete
[27] Fix | Delete
def _find_executable(executable, path=None):
[28] Fix | Delete
"""Tries to find 'executable' in the directories listed in 'path'.
[29] Fix | Delete
[30] Fix | Delete
A string listing directories separated by 'os.pathsep'; defaults to
[31] Fix | Delete
os.environ['PATH']. Returns the complete filename or None if not found.
[32] Fix | Delete
"""
[33] Fix | Delete
if path is None:
[34] Fix | Delete
path = os.environ['PATH']
[35] Fix | Delete
[36] Fix | Delete
paths = path.split(os.pathsep)
[37] Fix | Delete
base, ext = os.path.splitext(executable)
[38] Fix | Delete
[39] Fix | Delete
if (sys.platform == 'win32' or os.name == 'os2') and (ext != '.exe'):
[40] Fix | Delete
executable = executable + '.exe'
[41] Fix | Delete
[42] Fix | Delete
if not os.path.isfile(executable):
[43] Fix | Delete
for p in paths:
[44] Fix | Delete
f = os.path.join(p, executable)
[45] Fix | Delete
if os.path.isfile(f):
[46] Fix | Delete
# the file exists, we have a shot at spawn working
[47] Fix | Delete
return f
[48] Fix | Delete
return None
[49] Fix | Delete
else:
[50] Fix | Delete
return executable
[51] Fix | Delete
[52] Fix | Delete
[53] Fix | Delete
def _read_output(commandstring):
[54] Fix | Delete
"""Output from successful command execution or None"""
[55] Fix | Delete
# Similar to os.popen(commandstring, "r").read(),
[56] Fix | Delete
# but without actually using os.popen because that
[57] Fix | Delete
# function is not usable during python bootstrap.
[58] Fix | Delete
# tempfile is also not available then.
[59] Fix | Delete
import contextlib
[60] Fix | Delete
try:
[61] Fix | Delete
import tempfile
[62] Fix | Delete
fp = tempfile.NamedTemporaryFile()
[63] Fix | Delete
except ImportError:
[64] Fix | Delete
fp = open("/tmp/_osx_support.%s"%(
[65] Fix | Delete
os.getpid(),), "w+b")
[66] Fix | Delete
[67] Fix | Delete
with contextlib.closing(fp) as fp:
[68] Fix | Delete
cmd = "%s 2>/dev/null >'%s'" % (commandstring, fp.name)
[69] Fix | Delete
return fp.read().strip() if not os.system(cmd) else None
[70] Fix | Delete
[71] Fix | Delete
[72] Fix | Delete
def _find_build_tool(toolname):
[73] Fix | Delete
"""Find a build tool on current path or using xcrun"""
[74] Fix | Delete
return (_find_executable(toolname)
[75] Fix | Delete
or _read_output("/usr/bin/xcrun -find %s" % (toolname,))
[76] Fix | Delete
or ''
[77] Fix | Delete
)
[78] Fix | Delete
[79] Fix | Delete
_SYSTEM_VERSION = None
[80] Fix | Delete
[81] Fix | Delete
def _get_system_version():
[82] Fix | Delete
"""Return the OS X system version as a string"""
[83] Fix | Delete
# Reading this plist is a documented way to get the system
[84] Fix | Delete
# version (see the documentation for the Gestalt Manager)
[85] Fix | Delete
# We avoid using platform.mac_ver to avoid possible bootstrap issues during
[86] Fix | Delete
# the build of Python itself (distutils is used to build standard library
[87] Fix | Delete
# extensions).
[88] Fix | Delete
[89] Fix | Delete
global _SYSTEM_VERSION
[90] Fix | Delete
[91] Fix | Delete
if _SYSTEM_VERSION is None:
[92] Fix | Delete
_SYSTEM_VERSION = ''
[93] Fix | Delete
try:
[94] Fix | Delete
f = open('/System/Library/CoreServices/SystemVersion.plist')
[95] Fix | Delete
except IOError:
[96] Fix | Delete
# We're on a plain darwin box, fall back to the default
[97] Fix | Delete
# behaviour.
[98] Fix | Delete
pass
[99] Fix | Delete
else:
[100] Fix | Delete
try:
[101] Fix | Delete
m = re.search(r'<key>ProductUserVisibleVersion</key>\s*'
[102] Fix | Delete
r'<string>(.*?)</string>', f.read())
[103] Fix | Delete
finally:
[104] Fix | Delete
f.close()
[105] Fix | Delete
if m is not None:
[106] Fix | Delete
_SYSTEM_VERSION = '.'.join(m.group(1).split('.')[:2])
[107] Fix | Delete
# else: fall back to the default behaviour
[108] Fix | Delete
[109] Fix | Delete
return _SYSTEM_VERSION
[110] Fix | Delete
[111] Fix | Delete
def _remove_original_values(_config_vars):
[112] Fix | Delete
"""Remove original unmodified values for testing"""
[113] Fix | Delete
# This is needed for higher-level cross-platform tests of get_platform.
[114] Fix | Delete
for k in list(_config_vars):
[115] Fix | Delete
if k.startswith(_INITPRE):
[116] Fix | Delete
del _config_vars[k]
[117] Fix | Delete
[118] Fix | Delete
def _save_modified_value(_config_vars, cv, newvalue):
[119] Fix | Delete
"""Save modified and original unmodified value of configuration var"""
[120] Fix | Delete
[121] Fix | Delete
oldvalue = _config_vars.get(cv, '')
[122] Fix | Delete
if (oldvalue != newvalue) and (_INITPRE + cv not in _config_vars):
[123] Fix | Delete
_config_vars[_INITPRE + cv] = oldvalue
[124] Fix | Delete
_config_vars[cv] = newvalue
[125] Fix | Delete
[126] Fix | Delete
def _supports_universal_builds():
[127] Fix | Delete
"""Returns True if universal builds are supported on this system"""
[128] Fix | Delete
# As an approximation, we assume that if we are running on 10.4 or above,
[129] Fix | Delete
# then we are running with an Xcode environment that supports universal
[130] Fix | Delete
# builds, in particular -isysroot and -arch arguments to the compiler. This
[131] Fix | Delete
# is in support of allowing 10.4 universal builds to run on 10.3.x systems.
[132] Fix | Delete
[133] Fix | Delete
osx_version = _get_system_version()
[134] Fix | Delete
if osx_version:
[135] Fix | Delete
try:
[136] Fix | Delete
osx_version = tuple(int(i) for i in osx_version.split('.'))
[137] Fix | Delete
except ValueError:
[138] Fix | Delete
osx_version = ''
[139] Fix | Delete
return bool(osx_version >= (10, 4)) if osx_version else False
[140] Fix | Delete
[141] Fix | Delete
[142] Fix | Delete
def _find_appropriate_compiler(_config_vars):
[143] Fix | Delete
"""Find appropriate C compiler for extension module builds"""
[144] Fix | Delete
[145] Fix | Delete
# Issue #13590:
[146] Fix | Delete
# The OSX location for the compiler varies between OSX
[147] Fix | Delete
# (or rather Xcode) releases. With older releases (up-to 10.5)
[148] Fix | Delete
# the compiler is in /usr/bin, with newer releases the compiler
[149] Fix | Delete
# can only be found inside Xcode.app if the "Command Line Tools"
[150] Fix | Delete
# are not installed.
[151] Fix | Delete
#
[152] Fix | Delete
# Furthermore, the compiler that can be used varies between
[153] Fix | Delete
# Xcode releases. Up to Xcode 4 it was possible to use 'gcc-4.2'
[154] Fix | Delete
# as the compiler, after that 'clang' should be used because
[155] Fix | Delete
# gcc-4.2 is either not present, or a copy of 'llvm-gcc' that
[156] Fix | Delete
# miscompiles Python.
[157] Fix | Delete
[158] Fix | Delete
# skip checks if the compiler was overridden with a CC env variable
[159] Fix | Delete
if 'CC' in os.environ:
[160] Fix | Delete
return _config_vars
[161] Fix | Delete
[162] Fix | Delete
# The CC config var might contain additional arguments.
[163] Fix | Delete
# Ignore them while searching.
[164] Fix | Delete
cc = oldcc = _config_vars['CC'].split()[0]
[165] Fix | Delete
if not _find_executable(cc):
[166] Fix | Delete
# Compiler is not found on the shell search PATH.
[167] Fix | Delete
# Now search for clang, first on PATH (if the Command LIne
[168] Fix | Delete
# Tools have been installed in / or if the user has provided
[169] Fix | Delete
# another location via CC). If not found, try using xcrun
[170] Fix | Delete
# to find an uninstalled clang (within a selected Xcode).
[171] Fix | Delete
[172] Fix | Delete
# NOTE: Cannot use subprocess here because of bootstrap
[173] Fix | Delete
# issues when building Python itself (and os.popen is
[174] Fix | Delete
# implemented on top of subprocess and is therefore not
[175] Fix | Delete
# usable as well)
[176] Fix | Delete
[177] Fix | Delete
cc = _find_build_tool('clang')
[178] Fix | Delete
[179] Fix | Delete
elif os.path.basename(cc).startswith('gcc'):
[180] Fix | Delete
# Compiler is GCC, check if it is LLVM-GCC
[181] Fix | Delete
data = _read_output("'%s' --version"
[182] Fix | Delete
% (cc.replace("'", "'\"'\"'"),))
[183] Fix | Delete
if data and 'llvm-gcc' in data:
[184] Fix | Delete
# Found LLVM-GCC, fall back to clang
[185] Fix | Delete
cc = _find_build_tool('clang')
[186] Fix | Delete
[187] Fix | Delete
if not cc:
[188] Fix | Delete
raise SystemError(
[189] Fix | Delete
"Cannot locate working compiler")
[190] Fix | Delete
[191] Fix | Delete
if cc != oldcc:
[192] Fix | Delete
# Found a replacement compiler.
[193] Fix | Delete
# Modify config vars using new compiler, if not already explicitly
[194] Fix | Delete
# overridden by an env variable, preserving additional arguments.
[195] Fix | Delete
for cv in _COMPILER_CONFIG_VARS:
[196] Fix | Delete
if cv in _config_vars and cv not in os.environ:
[197] Fix | Delete
cv_split = _config_vars[cv].split()
[198] Fix | Delete
cv_split[0] = cc if cv != 'CXX' else cc + '++'
[199] Fix | Delete
_save_modified_value(_config_vars, cv, ' '.join(cv_split))
[200] Fix | Delete
[201] Fix | Delete
return _config_vars
[202] Fix | Delete
[203] Fix | Delete
[204] Fix | Delete
def _remove_universal_flags(_config_vars):
[205] Fix | Delete
"""Remove all universal build arguments from config vars"""
[206] Fix | Delete
[207] Fix | Delete
for cv in _UNIVERSAL_CONFIG_VARS:
[208] Fix | Delete
# Do not alter a config var explicitly overridden by env var
[209] Fix | Delete
if cv in _config_vars and cv not in os.environ:
[210] Fix | Delete
flags = _config_vars[cv]
[211] Fix | Delete
flags = re.sub('-arch\s+\w+\s', ' ', flags)
[212] Fix | Delete
flags = re.sub('-isysroot [^ \t]*', ' ', flags)
[213] Fix | Delete
_save_modified_value(_config_vars, cv, flags)
[214] Fix | Delete
[215] Fix | Delete
return _config_vars
[216] Fix | Delete
[217] Fix | Delete
[218] Fix | Delete
def _remove_unsupported_archs(_config_vars):
[219] Fix | Delete
"""Remove any unsupported archs from config vars"""
[220] Fix | Delete
# Different Xcode releases support different sets for '-arch'
[221] Fix | Delete
# flags. In particular, Xcode 4.x no longer supports the
[222] Fix | Delete
# PPC architectures.
[223] Fix | Delete
#
[224] Fix | Delete
# This code automatically removes '-arch ppc' and '-arch ppc64'
[225] Fix | Delete
# when these are not supported. That makes it possible to
[226] Fix | Delete
# build extensions on OSX 10.7 and later with the prebuilt
[227] Fix | Delete
# 32-bit installer on the python.org website.
[228] Fix | Delete
[229] Fix | Delete
# skip checks if the compiler was overridden with a CC env variable
[230] Fix | Delete
if 'CC' in os.environ:
[231] Fix | Delete
return _config_vars
[232] Fix | Delete
[233] Fix | Delete
if re.search('-arch\s+ppc', _config_vars['CFLAGS']) is not None:
[234] Fix | Delete
# NOTE: Cannot use subprocess here because of bootstrap
[235] Fix | Delete
# issues when building Python itself
[236] Fix | Delete
status = os.system(
[237] Fix | Delete
"""echo 'int main{};' | """
[238] Fix | Delete
"""'%s' -c -arch ppc -x c -o /dev/null /dev/null 2>/dev/null"""
[239] Fix | Delete
%(_config_vars['CC'].replace("'", "'\"'\"'"),))
[240] Fix | Delete
if status:
[241] Fix | Delete
# The compile failed for some reason. Because of differences
[242] Fix | Delete
# across Xcode and compiler versions, there is no reliable way
[243] Fix | Delete
# to be sure why it failed. Assume here it was due to lack of
[244] Fix | Delete
# PPC support and remove the related '-arch' flags from each
[245] Fix | Delete
# config variables not explicitly overridden by an environment
[246] Fix | Delete
# variable. If the error was for some other reason, we hope the
[247] Fix | Delete
# failure will show up again when trying to compile an extension
[248] Fix | Delete
# module.
[249] Fix | Delete
for cv in _UNIVERSAL_CONFIG_VARS:
[250] Fix | Delete
if cv in _config_vars and cv not in os.environ:
[251] Fix | Delete
flags = _config_vars[cv]
[252] Fix | Delete
flags = re.sub('-arch\s+ppc\w*\s', ' ', flags)
[253] Fix | Delete
_save_modified_value(_config_vars, cv, flags)
[254] Fix | Delete
[255] Fix | Delete
return _config_vars
[256] Fix | Delete
[257] Fix | Delete
[258] Fix | Delete
def _override_all_archs(_config_vars):
[259] Fix | Delete
"""Allow override of all archs with ARCHFLAGS env var"""
[260] Fix | Delete
# NOTE: This name was introduced by Apple in OSX 10.5 and
[261] Fix | Delete
# is used by several scripting languages distributed with
[262] Fix | Delete
# that OS release.
[263] Fix | Delete
if 'ARCHFLAGS' in os.environ:
[264] Fix | Delete
arch = os.environ['ARCHFLAGS']
[265] Fix | Delete
for cv in _UNIVERSAL_CONFIG_VARS:
[266] Fix | Delete
if cv in _config_vars and '-arch' in _config_vars[cv]:
[267] Fix | Delete
flags = _config_vars[cv]
[268] Fix | Delete
flags = re.sub('-arch\s+\w+\s', ' ', flags)
[269] Fix | Delete
flags = flags + ' ' + arch
[270] Fix | Delete
_save_modified_value(_config_vars, cv, flags)
[271] Fix | Delete
[272] Fix | Delete
return _config_vars
[273] Fix | Delete
[274] Fix | Delete
[275] Fix | Delete
def _check_for_unavailable_sdk(_config_vars):
[276] Fix | Delete
"""Remove references to any SDKs not available"""
[277] Fix | Delete
# If we're on OSX 10.5 or later and the user tries to
[278] Fix | Delete
# compile an extension using an SDK that is not present
[279] Fix | Delete
# on the current machine it is better to not use an SDK
[280] Fix | Delete
# than to fail. This is particularly important with
[281] Fix | Delete
# the standalone Command Line Tools alternative to a
[282] Fix | Delete
# full-blown Xcode install since the CLT packages do not
[283] Fix | Delete
# provide SDKs. If the SDK is not present, it is assumed
[284] Fix | Delete
# that the header files and dev libs have been installed
[285] Fix | Delete
# to /usr and /System/Library by either a standalone CLT
[286] Fix | Delete
# package or the CLT component within Xcode.
[287] Fix | Delete
cflags = _config_vars.get('CFLAGS', '')
[288] Fix | Delete
m = re.search(r'-isysroot\s+(\S+)', cflags)
[289] Fix | Delete
if m is not None:
[290] Fix | Delete
sdk = m.group(1)
[291] Fix | Delete
if not os.path.exists(sdk):
[292] Fix | Delete
for cv in _UNIVERSAL_CONFIG_VARS:
[293] Fix | Delete
# Do not alter a config var explicitly overridden by env var
[294] Fix | Delete
if cv in _config_vars and cv not in os.environ:
[295] Fix | Delete
flags = _config_vars[cv]
[296] Fix | Delete
flags = re.sub(r'-isysroot\s+\S+(?:\s|$)', ' ', flags)
[297] Fix | Delete
_save_modified_value(_config_vars, cv, flags)
[298] Fix | Delete
[299] Fix | Delete
return _config_vars
[300] Fix | Delete
[301] Fix | Delete
[302] Fix | Delete
def compiler_fixup(compiler_so, cc_args):
[303] Fix | Delete
"""
[304] Fix | Delete
This function will strip '-isysroot PATH' and '-arch ARCH' from the
[305] Fix | Delete
compile flags if the user has specified one them in extra_compile_flags.
[306] Fix | Delete
[307] Fix | Delete
This is needed because '-arch ARCH' adds another architecture to the
[308] Fix | Delete
build, without a way to remove an architecture. Furthermore GCC will
[309] Fix | Delete
barf if multiple '-isysroot' arguments are present.
[310] Fix | Delete
"""
[311] Fix | Delete
stripArch = stripSysroot = False
[312] Fix | Delete
[313] Fix | Delete
compiler_so = list(compiler_so)
[314] Fix | Delete
[315] Fix | Delete
if not _supports_universal_builds():
[316] Fix | Delete
# OSX before 10.4.0, these don't support -arch and -isysroot at
[317] Fix | Delete
# all.
[318] Fix | Delete
stripArch = stripSysroot = True
[319] Fix | Delete
else:
[320] Fix | Delete
stripArch = '-arch' in cc_args
[321] Fix | Delete
stripSysroot = '-isysroot' in cc_args
[322] Fix | Delete
[323] Fix | Delete
if stripArch or 'ARCHFLAGS' in os.environ:
[324] Fix | Delete
while True:
[325] Fix | Delete
try:
[326] Fix | Delete
index = compiler_so.index('-arch')
[327] Fix | Delete
# Strip this argument and the next one:
[328] Fix | Delete
del compiler_so[index:index+2]
[329] Fix | Delete
except ValueError:
[330] Fix | Delete
break
[331] Fix | Delete
[332] Fix | Delete
if 'ARCHFLAGS' in os.environ and not stripArch:
[333] Fix | Delete
# User specified different -arch flags in the environ,
[334] Fix | Delete
# see also distutils.sysconfig
[335] Fix | Delete
compiler_so = compiler_so + os.environ['ARCHFLAGS'].split()
[336] Fix | Delete
[337] Fix | Delete
if stripSysroot:
[338] Fix | Delete
while True:
[339] Fix | Delete
try:
[340] Fix | Delete
index = compiler_so.index('-isysroot')
[341] Fix | Delete
# Strip this argument and the next one:
[342] Fix | Delete
del compiler_so[index:index+2]
[343] Fix | Delete
except ValueError:
[344] Fix | Delete
break
[345] Fix | Delete
[346] Fix | Delete
# Check if the SDK that is used during compilation actually exists,
[347] Fix | Delete
# the universal build requires the usage of a universal SDK and not all
[348] Fix | Delete
# users have that installed by default.
[349] Fix | Delete
sysroot = None
[350] Fix | Delete
if '-isysroot' in cc_args:
[351] Fix | Delete
idx = cc_args.index('-isysroot')
[352] Fix | Delete
sysroot = cc_args[idx+1]
[353] Fix | Delete
elif '-isysroot' in compiler_so:
[354] Fix | Delete
idx = compiler_so.index('-isysroot')
[355] Fix | Delete
sysroot = compiler_so[idx+1]
[356] Fix | Delete
[357] Fix | Delete
if sysroot and not os.path.isdir(sysroot):
[358] Fix | Delete
from distutils import log
[359] Fix | Delete
log.warn("Compiling with an SDK that doesn't seem to exist: %s",
[360] Fix | Delete
sysroot)
[361] Fix | Delete
log.warn("Please check your Xcode installation")
[362] Fix | Delete
[363] Fix | Delete
return compiler_so
[364] Fix | Delete
[365] Fix | Delete
[366] Fix | Delete
def customize_config_vars(_config_vars):
[367] Fix | Delete
"""Customize Python build configuration variables.
[368] Fix | Delete
[369] Fix | Delete
Called internally from sysconfig with a mutable mapping
[370] Fix | Delete
containing name/value pairs parsed from the configured
[371] Fix | Delete
makefile used to build this interpreter. Returns
[372] Fix | Delete
the mapping updated as needed to reflect the environment
[373] Fix | Delete
in which the interpreter is running; in the case of
[374] Fix | Delete
a Python from a binary installer, the installed
[375] Fix | Delete
environment may be very different from the build
[376] Fix | Delete
environment, i.e. different OS levels, different
[377] Fix | Delete
built tools, different available CPU architectures.
[378] Fix | Delete
[379] Fix | Delete
This customization is performed whenever
[380] Fix | Delete
distutils.sysconfig.get_config_vars() is first
[381] Fix | Delete
called. It may be used in environments where no
[382] Fix | Delete
compilers are present, i.e. when installing pure
[383] Fix | Delete
Python dists. Customization of compiler paths
[384] Fix | Delete
and detection of unavailable archs is deferred
[385] Fix | Delete
until the first extension module build is
[386] Fix | Delete
requested (in distutils.sysconfig.customize_compiler).
[387] Fix | Delete
[388] Fix | Delete
Currently called from distutils.sysconfig
[389] Fix | Delete
"""
[390] Fix | Delete
[391] Fix | Delete
if not _supports_universal_builds():
[392] Fix | Delete
# On Mac OS X before 10.4, check if -arch and -isysroot
[393] Fix | Delete
# are in CFLAGS or LDFLAGS and remove them if they are.
[394] Fix | Delete
# This is needed when building extensions on a 10.3 system
[395] Fix | Delete
# using a universal build of python.
[396] Fix | Delete
_remove_universal_flags(_config_vars)
[397] Fix | Delete
[398] Fix | Delete
# Allow user to override all archs with ARCHFLAGS env var
[399] Fix | Delete
_override_all_archs(_config_vars)
[400] Fix | Delete
[401] Fix | Delete
# Remove references to sdks that are not found
[402] Fix | Delete
_check_for_unavailable_sdk(_config_vars)
[403] Fix | Delete
[404] Fix | Delete
return _config_vars
[405] Fix | Delete
[406] Fix | Delete
[407] Fix | Delete
def customize_compiler(_config_vars):
[408] Fix | Delete
"""Customize compiler path and configuration variables.
[409] Fix | Delete
[410] Fix | Delete
This customization is performed when the first
[411] Fix | Delete
extension module build is requested
[412] Fix | Delete
in distutils.sysconfig.customize_compiler).
[413] Fix | Delete
"""
[414] Fix | Delete
[415] Fix | Delete
# Find a compiler to use for extension module builds
[416] Fix | Delete
_find_appropriate_compiler(_config_vars)
[417] Fix | Delete
[418] Fix | Delete
# Remove ppc arch flags if not supported here
[419] Fix | Delete
_remove_unsupported_archs(_config_vars)
[420] Fix | Delete
[421] Fix | Delete
# Allow user to override all archs with ARCHFLAGS env var
[422] Fix | Delete
_override_all_archs(_config_vars)
[423] Fix | Delete
[424] Fix | Delete
return _config_vars
[425] Fix | Delete
[426] Fix | Delete
[427] Fix | Delete
def get_platform_osx(_config_vars, osname, release, machine):
[428] Fix | Delete
"""Filter values for get_platform()"""
[429] Fix | Delete
# called from get_platform() in sysconfig and distutils.util
[430] Fix | Delete
#
[431] Fix | Delete
# For our purposes, we'll assume that the system version from
[432] Fix | Delete
# distutils' perspective is what MACOSX_DEPLOYMENT_TARGET is set
[433] Fix | Delete
# to. This makes the compatibility story a bit more sane because the
[434] Fix | Delete
# machine is going to compile and link as if it were
[435] Fix | Delete
# MACOSX_DEPLOYMENT_TARGET.
[436] Fix | Delete
[437] Fix | Delete
macver = _config_vars.get('MACOSX_DEPLOYMENT_TARGET', '')
[438] Fix | Delete
macrelease = _get_system_version() or macver
[439] Fix | Delete
macver = macver or macrelease
[440] Fix | Delete
[441] Fix | Delete
if macver:
[442] Fix | Delete
release = macver
[443] Fix | Delete
osname = "macosx"
[444] Fix | Delete
[445] Fix | Delete
# Use the original CFLAGS value, if available, so that we
[446] Fix | Delete
# return the same machine type for the platform string.
[447] Fix | Delete
# Otherwise, distutils may consider this a cross-compiling
[448] Fix | Delete
# case and disallow installs.
[449] Fix | Delete
cflags = _config_vars.get(_INITPRE+'CFLAGS',
[450] Fix | Delete
_config_vars.get('CFLAGS', ''))
[451] Fix | Delete
if macrelease:
[452] Fix | Delete
try:
[453] Fix | Delete
macrelease = tuple(int(i) for i in macrelease.split('.')[0:2])
[454] Fix | Delete
except ValueError:
[455] Fix | Delete
macrelease = (10, 0)
[456] Fix | Delete
else:
[457] Fix | Delete
# assume no universal support
[458] Fix | Delete
macrelease = (10, 0)
[459] Fix | Delete
[460] Fix | Delete
if (macrelease >= (10, 4)) and '-arch' in cflags.strip():
[461] Fix | Delete
# The universal build will build fat binaries, but not on
[462] Fix | Delete
# systems before 10.4
[463] Fix | Delete
[464] Fix | Delete
machine = 'fat'
[465] Fix | Delete
[466] Fix | Delete
archs = re.findall('-arch\s+(\S+)', cflags)
[467] Fix | Delete
archs = tuple(sorted(set(archs)))
[468] Fix | Delete
[469] Fix | Delete
if len(archs) == 1:
[470] Fix | Delete
machine = archs[0]
[471] Fix | Delete
elif archs == ('i386', 'ppc'):
[472] Fix | Delete
machine = 'fat'
[473] Fix | Delete
elif archs == ('i386', 'x86_64'):
[474] Fix | Delete
machine = 'intel'
[475] Fix | Delete
elif archs == ('i386', 'ppc', 'x86_64'):
[476] Fix | Delete
machine = 'fat3'
[477] Fix | Delete
elif archs == ('ppc64', 'x86_64'):
[478] Fix | Delete
machine = 'fat64'
[479] Fix | Delete
elif archs == ('i386', 'ppc', 'ppc64', 'x86_64'):
[480] Fix | Delete
machine = 'universal'
[481] Fix | Delete
else:
[482] Fix | Delete
raise ValueError(
[483] Fix | Delete
"Don't know machine value for archs=%r" % (archs,))
[484] Fix | Delete
[485] Fix | Delete
elif machine == 'i386':
[486] Fix | Delete
# On OSX the machine type returned by uname is always the
[487] Fix | Delete
# 32-bit variant, even if the executable architecture is
[488] Fix | Delete
# the 64-bit variant
[489] Fix | Delete
if sys.maxint >= 2**32:
[490] Fix | Delete
machine = 'x86_64'
[491] Fix | Delete
[492] Fix | Delete
elif machine in ('PowerPC', 'Power_Macintosh'):
[493] Fix | Delete
# Pick a sane name for the PPC architecture.
[494] Fix | Delete
# See 'i386' case
[495] Fix | Delete
if sys.maxint >= 2**32:
[496] Fix | Delete
machine = 'ppc64'
[497] Fix | Delete
else:
[498] Fix | Delete
machine = 'ppc'
[499] Fix | Delete
12
It is recommended that you Edit text format, this type of Fix handles quite a lot in one request
Function