@@ -258,6 +258,41 @@ index bf0d4333f9..8a4ba3666a 100644
258258 def test_check_environ(self):
259259 util._environ_checked = 0
260260 os.environ.pop('HOME', None)
261+ diff --git a/Lib/distutils/unixccompiler.py b/Lib/distutils/unixccompiler.py
262+ index f0792de74a..7bbade8814 100644
263+ --- a/Lib/distutils/unixccompiler.py
264+ +++ b/Lib/distutils/unixccompiler.py
265+ @@ -269,9 +269,9 @@
266+ static_f = self.library_filename(lib, lib_type='static')
267+
268+ if sys.platform == 'darwin':
269+ - # On OSX users can specify an alternate SDK using
270+ - # '-isysroot', calculate the SDK root if it is specified
271+ - # (and use it further on)
272+ + # On macOS users can specify an alternate SDK using
273+ + # '-isysroot <path>' or --sysroot=<path>, calculate the SDK root
274+ + # if it is specified (and use it further on)
275+ #
276+ # Note that, as of Xcode 7, Apple SDKs may contain textual stub
277+ # libraries with .tbd extensions rather than the normal .dylib
278+ @@ -290,12 +290,14 @@
279+ cflags = sysconfig.get_config_var('CFLAGS')
280+ m = re.search(r'-isysroot\s*(\S+)', cflags)
281+ if m is None:
282+ - sysroot = _osx_support._default_sysroot(sysconfig.get_config_var('CC'))
283+ + m = re.search(r'--sysroot=(\S+)', cflags)
284+ + if m is None:
285+ + sysroot = _osx_support._default_sysroot(sysconfig.get_config_var('CC'))
286+ + else:
287+ + sysroot = m.group(1)
288+ else:
289+ sysroot = m.group(1)
290+
291+ -
292+ -
293+ for dir in dirs:
294+ shared = os.path.join(dir, shared_f)
295+ dylib = os.path.join(dir, dylib_f)
261296diff --git a/Lib/importlib/_bootstrap_external.py b/Lib/importlib/_bootstrap_external.py
262297index 509f99ae8e..2005b88e94 100644
263298--- a/Lib/importlib/_bootstrap_external.py
@@ -3492,7 +3527,7 @@ index 41cfe07902..75cd6905a0 100644
34923527 #undef HAVE_PROCESS_H
34933528
34943529diff --git a/setup.py b/setup.py
3495- index 57be07a7e0..b15933862c 100644
3530+ index 57be07a7e0..9a6bd11af6 100644
34963531--- a/setup.py
34973532+++ b/setup.py
34983533@@ -44,6 +44,9 @@
@@ -3505,7 +3540,38 @@ index 57be07a7e0..b15933862c 100644
35053540 AIX = (HOST_PLATFORM.startswith('aix'))
35063541 VXWORKS = ('vxworks' in HOST_PLATFORM)
35073542
3508- @@ -1972,6 +1975,11 @@
3543+ @@ -115,16 +118,20 @@
3544+ for var_name in make_vars:
3545+ var = sysconfig.get_config_var(var_name)
3546+ if var is not None:
3547+ - m = re.search(r'--sysroot=([^"]\S*|"[^"]+")', var)
3548+ - if m is not None:
3549+ - sysroot = m.group(1).strip('"')
3550+ - for subdir in subdirs:
3551+ - if os.path.isabs(subdir):
3552+ - subdir = subdir[1:]
3553+ - path = os.path.join(sysroot, subdir)
3554+ - if os.path.isdir(path):
3555+ - dirs.append(path)
3556+ - break
3557+ + for pattern in [
3558+ + r'-isysroot\s*([^"]\S*|"[^"]+")',
3559+ + r'--sysroot=([^"]\S*|"[^"]+")',
3560+ + ]:
3561+ + m = re.search(pattern, var)
3562+ + if m is not None:
3563+ + sysroot = m.group(1).strip('"')
3564+ + for subdir in subdirs:
3565+ + if os.path.isabs(subdir):
3566+ + subdir = subdir[1:]
3567+ + path = os.path.join(sysroot, subdir)
3568+ + if os.path.isdir(path):
3569+ + dirs.append(path)
3570+ + break
3571+ return dirs
3572+
3573+ MACOS_SDK_ROOT = None
3574+ @@ -1972,6 +1979,11 @@
35093575 extra_compile_args.append('-DMACOSX')
35103576 include_dirs.append('_ctypes/darwin')
35113577
@@ -3517,7 +3583,7 @@ index 57be07a7e0..b15933862c 100644
35173583 elif HOST_PLATFORM == 'sunos5':
35183584 # XXX This shouldn't be necessary; it appears that some
35193585 # of the assembler code is non-PIC (i.e. it has relocations
3520- @@ -2001,7 +2009 ,8 @@
3586+ @@ -2001,7 +2013 ,8 @@
35213587 libraries=['m']))
35223588
35233589 ffi_inc = sysconfig.get_config_var("LIBFFI_INCLUDEDIR")
@@ -3527,15 +3593,15 @@ index 57be07a7e0..b15933862c 100644
35273593
35283594 ffi_inc_dirs = self.inc_dirs.copy()
35293595 if MACOS:
3530- @@ -2030,6 +2039 ,7 @@
3596+ @@ -2030,6 +2043 ,7 @@
35313597 for lib_name in ('ffi', 'ffi_pic'):
35323598 if (self.compiler.find_library_file(self.lib_dirs, lib_name)):
35333599 ffi_lib = lib_name
35343600+ self.use_system_libffi = True
35353601 break
35363602
35373603 if ffi_inc and ffi_lib:
3538- @@ -2043,7 +2053 ,8 @@
3604+ @@ -2043,7 +2057 ,8 @@
35393605
35403606 ext.include_dirs.append(ffi_inc)
35413607 ext.libraries.append(ffi_lib)
0 commit comments