]> granicus.if.org Git - python/commitdiff
Issue #13590: Improve support for OS X Xcode 4:
authorNed Deily <nad@acm.org>
Mon, 16 Jul 2012 04:30:03 +0000 (21:30 -0700)
committerNed Deily <nad@acm.org>
Mon, 16 Jul 2012 04:30:03 +0000 (21:30 -0700)
- fix test_distutils and test_sysconfig test failures by
  aligning sysconfig and distutils.sysconfig tailoring of
  configure variables (as in 2.7)

Lib/distutils/sysconfig.py
Lib/distutils/unixccompiler.py
Lib/sysconfig.py

index dac3035f1bfafd1fffdbb6d7f12252e11e5d1549..f6e5d999095a0ba38561db3c82319c12345e3105 100644 (file)
@@ -624,7 +624,7 @@ def get_config_vars(*args):
                 # are in CFLAGS or LDFLAGS and remove them if they are.
                 # This is needed when building extensions on a 10.3 system
                 # using a universal build of python.
-                for key in ('LDFLAGS', 'BASECFLAGS',
+                for key in ('LDFLAGS', 'BASECFLAGS', 'LDSHARED',
                         # a number of derived variables. These need to be
                         # patched up as well.
                         'CFLAGS', 'PY_CFLAGS', 'BLDSHARED'):
@@ -669,16 +669,39 @@ def get_config_vars(*args):
                 # that OS release.
                 if 'ARCHFLAGS' in os.environ:
                     arch = os.environ['ARCHFLAGS']
-                    for key in ('LDFLAGS', 'BASECFLAGS',
+                    for key in ('LDFLAGS', 'BASECFLAGS', 'LDSHARED',
                         # a number of derived variables. These need to be
                         # patched up as well.
-                        'CFLAGS', 'PY_CFLAGS', 'BLDSHARED', 'LDSHARED'):
+                        'CFLAGS', 'PY_CFLAGS', 'BLDSHARED'):
 
                         flags = _config_vars[key]
                         flags = re.sub('-arch\s+\w+\s', ' ', flags)
                         flags = flags + ' ' + arch
                         _config_vars[key] = flags
 
+                # If we're on OSX 10.5 or later and the user tries to
+                # compiles an extension using an SDK that is not present
+                # on the current machine it is better to not use an SDK
+                # than to fail.
+                #
+                # The major usecase for this is users using a Python.org
+                # binary installer  on OSX 10.6: that installer uses
+                # the 10.4u SDK, but that SDK is not installed by default
+                # when you install Xcode.
+                #
+                m = re.search('-isysroot\s+(\S+)', _config_vars['CFLAGS'])
+                if m is not None:
+                    sdk = m.group(1)
+                    if not os.path.exists(sdk):
+                        for key in ('LDFLAGS', 'BASECFLAGS', 'LDSHARED',
+                             # a number of derived variables. These need to be
+                             # patched up as well.
+                            'CFLAGS', 'PY_CFLAGS', 'BLDSHARED'):
+
+                            flags = _config_vars[key]
+                            flags = re.sub('-isysroot\s+\S+(\s|$)', ' ', flags)
+                            _config_vars[key] = flags
+
     if args:
         vals = []
         for name in args:
index 5d45faa741f100d2b7823a6c03e9b533e8f0f8d4..c70a3cc555cbf2397f49d6edc1632f6866afddae 100644 (file)
@@ -83,8 +83,9 @@ def _darwin_compiler_fixup(compiler_so, cc_args):
         except ValueError:
             pass
 
-    # Check if the SDK that is used during compilation actually exists.
-    # If not, revert to using the installed headers and hope for the best.
+    # Check if the SDK that is used during compilation actually exists,
+    # the universal build requires the usage of a universal SDK and not all
+    # users have that installed by default.
     sysroot = None
     if '-isysroot' in cc_args:
         idx = cc_args.index('-isysroot')
@@ -96,21 +97,7 @@ def _darwin_compiler_fixup(compiler_so, cc_args):
     if sysroot and not os.path.isdir(sysroot):
         log.warn("Compiling with an SDK that doesn't seem to exist: %s",
                 sysroot)
-        log.warn("Attempting to compile without the SDK")
-        while True:
-            try:
-                index = cc_args.index('-isysroot')
-                # Strip this argument and the next one:
-                del cc_args[index:index+2]
-            except ValueError:
-                break
-        while True:
-            try:
-                index = compiler_so.index('-isysroot')
-                # Strip this argument and the next one:
-                del compiler_so[index:index+2]
-            except ValueError:
-                break
+        log.warn("Please check your Xcode installation")
 
     return compiler_so
 
index 4f0a9a920c463fd8a225cb49b7642f1ab1185055..7589a1c5b3dc4c4132d4a37e2bf1eae039939e23 100644 (file)
@@ -565,7 +565,7 @@ def get_config_vars(*args):
                 # are in CFLAGS or LDFLAGS and remove them if they are.
                 # This is needed when building extensions on a 10.3 system
                 # using a universal build of python.
-                for key in ('LDFLAGS', 'BASECFLAGS',
+                for key in ('LDFLAGS', 'BASECFLAGS', 'LDSHARED',
                         # a number of derived variables. These need to be
                         # patched up as well.
                         'CFLAGS', 'PY_CFLAGS', 'BLDSHARED'):
@@ -581,7 +581,7 @@ def get_config_vars(*args):
                 # that OS release.
                 if 'ARCHFLAGS' in os.environ:
                     arch = os.environ['ARCHFLAGS']
-                    for key in ('LDFLAGS', 'BASECFLAGS',
+                    for key in ('LDFLAGS', 'BASECFLAGS', 'LDSHARED',
                         # a number of derived variables. These need to be
                         # patched up as well.
                         'CFLAGS', 'PY_CFLAGS', 'BLDSHARED'):
@@ -606,7 +606,7 @@ def get_config_vars(*args):
                 if m is not None:
                     sdk = m.group(1)
                     if not os.path.exists(sdk):
-                        for key in ('LDFLAGS', 'BASECFLAGS',
+                        for key in ('LDFLAGS', 'BASECFLAGS',  'LDSHARED',
                              # a number of derived variables. These need to be
                              # patched up as well.
                             'CFLAGS', 'PY_CFLAGS', 'BLDSHARED'):