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