[Python-checkins] r75022 - python/trunk/Lib/distutils/sysconfig.py

ronald.oussoren python-checkins at python.org
Tue Sep 22 21:27:45 CEST 2009


Author: ronald.oussoren
Date: Tue Sep 22 21:27:44 2009
New Revision: 75022

Log:
Half of the fix for issue 6957: ensure that distutils
ignores the '-isysroot' option on OSX when the 
corresponding SDK is not installed.

This ensures that the user can compile extensions
on OSX 10.6 using the Python.org installer and a
default installation of Xcode.


Modified:
   python/trunk/Lib/distutils/sysconfig.py

Modified: python/trunk/Lib/distutils/sysconfig.py
==============================================================================
--- python/trunk/Lib/distutils/sysconfig.py	(original)
+++ python/trunk/Lib/distutils/sysconfig.py	Tue Sep 22 21:27:44 2009
@@ -592,6 +592,29 @@
                         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',
+                             # 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:


More information about the Python-checkins mailing list