MCPcopy Index your code
hub / github.com/python/cpython / _remove_unsupported_archs

Function _remove_unsupported_archs

Lib/_osx_support.py:275–312  ·  view source on GitHub ↗

Remove any unsupported archs from config vars

(_config_vars)

Source from the content-addressed store, hash-verified

273
274
275def _remove_unsupported_archs(_config_vars):
276 """Remove any unsupported archs from config vars"""
277 # Different Xcode releases support different sets for '-arch'
278 # flags. In particular, Xcode 4.x no longer supports the
279 # PPC architectures.
280 #
281 # This code automatically removes '-arch ppc' and '-arch ppc64'
282 # when these are not supported. That makes it possible to
283 # build extensions on OSX 10.7 and later with the prebuilt
284 # 32-bit installer on the python.org website.
285
286 # skip checks if the compiler was overridden with a CC env variable
287 if 'CC' in os.environ:
288 return _config_vars
289
290 if re.search(r'-arch\s+ppc', _config_vars['CFLAGS']) is not None:
291 # NOTE: Cannot use subprocess here because of bootstrap
292 # issues when building Python itself
293 status = os.system(
294 """echo 'int main{};' | """
295 """'%s' -c -arch ppc -x c -o /dev/null /dev/null 2>/dev/null"""
296 %(_config_vars['CC'].replace("'", "'\"'\"'"),))
297 if status:
298 # The compile failed for some reason. Because of differences
299 # across Xcode and compiler versions, there is no reliable way
300 # to be sure why it failed. Assume here it was due to lack of
301 # PPC support and remove the related '-arch' flags from each
302 # config variables not explicitly overridden by an environment
303 # variable. If the error was for some other reason, we hope the
304 # failure will show up again when trying to compile an extension
305 # module.
306 for cv in _UNIVERSAL_CONFIG_VARS:
307 if cv in _config_vars and cv not in os.environ:
308 flags = _config_vars[cv]
309 flags = re.sub(r'-arch\s+ppc\w*\s', ' ', flags)
310 _save_modified_value(_config_vars, cv, flags)
311
312 return _config_vars
313
314
315def _override_all_archs(_config_vars):

Callers 1

customize_compilerFunction · 0.85

Calls 4

_save_modified_valueFunction · 0.85
searchMethod · 0.45
replaceMethod · 0.45
subMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…