Skip to content

Commit 3d2f68d

Browse files
committed
Issue #19400: Prevent extension module build failures with Xcode 5 on OS X
10.8+ when using a universal Python that included a PPC architecture, such as with a python.org 32-bit-only binary installer.
1 parent 6fd25c3 commit 3d2f68d

File tree

2 files changed

+17
-7
lines changed

2 files changed

+17
-7
lines changed

Lib/_osx_support.py

Lines changed: 13 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -235,13 +235,19 @@ def _remove_unsupported_archs(_config_vars):
235235
if re.search('-arch\s+ppc', _config_vars['CFLAGS']) is not None:
236236
# NOTE: Cannot use subprocess here because of bootstrap
237237
# issues when building Python itself
238-
status = os.system("'%s' -arch ppc -x c /dev/null 2>/dev/null"%(
239-
_config_vars['CC'].replace("'", "'\"'\"'"),))
240-
# The Apple compiler drivers return status 255 if no PPC
241-
if (status >> 8) == 255:
242-
# Compiler doesn't support PPC, remove the related
243-
# '-arch' flags if not explicitly overridden by an
244-
# environment variable
238+
status = os.system(
239+
"""echo 'int main{};' | """
240+
"""'%s' -c -arch ppc -x c -o /dev/null /dev/null 2>/dev/null"""
241+
%(_config_vars['CC'].replace("'", "'\"'\"'"),))
242+
if status:
243+
# The compile failed for some reason. Because of differences
244+
# across Xcode and compiler versions, there is no reliable way
245+
# to be sure why it failed. Assume here it was due to lack of
246+
# PPC support and remove the related '-arch' flags from each
247+
# config variables not explicitly overriden by an environment
248+
# variable. If the error was for some other reason, we hope the
249+
# failure will show up again when trying to compile an extension
250+
# module.
245251
for cv in _UNIVERSAL_CONFIG_VARS:
246252
if cv in _config_vars and cv not in os.environ:
247253
flags = _config_vars[cv]

Misc/NEWS

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -411,6 +411,10 @@ Library
411411
existing directory caused mkstemp and related APIs to fail instead of
412412
retrying. Report and fix by Vlad Shcherbina.
413413

414+
- Issue #19400: Prevent extension module build failures with Xcode 5 on OS X
415+
10.8+ when using a universal Python that included a PPC architecture,
416+
such as with a python.org 32-bit-only binary installer.
417+
414418
C API
415419
-----
416420

0 commit comments

Comments
 (0)