@@ -624,7 +624,7 @@ def get_config_vars(*args):
624624 # are in CFLAGS or LDFLAGS and remove them if they are.
625625 # This is needed when building extensions on a 10.3 system
626626 # using a universal build of python.
627- for key in ('LDFLAGS' , 'BASECFLAGS' ,
627+ for key in ('LDFLAGS' , 'BASECFLAGS' , 'LDSHARED' ,
628628 # a number of derived variables. These need to be
629629 # patched up as well.
630630 'CFLAGS' , 'PY_CFLAGS' , 'BLDSHARED' ):
@@ -669,16 +669,39 @@ def get_config_vars(*args):
669669 # that OS release.
670670 if 'ARCHFLAGS' in os .environ :
671671 arch = os .environ ['ARCHFLAGS' ]
672- for key in ('LDFLAGS' , 'BASECFLAGS' ,
672+ for key in ('LDFLAGS' , 'BASECFLAGS' , 'LDSHARED' ,
673673 # a number of derived variables. These need to be
674674 # patched up as well.
675- 'CFLAGS' , 'PY_CFLAGS' , 'BLDSHARED' , 'LDSHARED' ):
675+ 'CFLAGS' , 'PY_CFLAGS' , 'BLDSHARED' ):
676676
677677 flags = _config_vars [key ]
678678 flags = re .sub ('-arch\s+\w+\s' , ' ' , flags )
679679 flags = flags + ' ' + arch
680680 _config_vars [key ] = flags
681681
682+ # If we're on OSX 10.5 or later and the user tries to
683+ # compiles an extension using an SDK that is not present
684+ # on the current machine it is better to not use an SDK
685+ # than to fail.
686+ #
687+ # The major usecase for this is users using a Python.org
688+ # binary installer on OSX 10.6: that installer uses
689+ # the 10.4u SDK, but that SDK is not installed by default
690+ # when you install Xcode.
691+ #
692+ m = re .search ('-isysroot\s+(\S+)' , _config_vars ['CFLAGS' ])
693+ if m is not None :
694+ sdk = m .group (1 )
695+ if not os .path .exists (sdk ):
696+ for key in ('LDFLAGS' , 'BASECFLAGS' , 'LDSHARED' ,
697+ # a number of derived variables. These need to be
698+ # patched up as well.
699+ 'CFLAGS' , 'PY_CFLAGS' , 'BLDSHARED' ):
700+
701+ flags = _config_vars [key ]
702+ flags = re .sub ('-isysroot\s+\S+(\s|$)' , ' ' , flags )
703+ _config_vars [key ] = flags
704+
682705 if args :
683706 vals = []
684707 for name in args :
0 commit comments