@@ -258,6 +258,41 @@ index bf0d4333f9..8a4ba3666a 100644
258
258
def test_check_environ(self):
259
259
util._environ_checked = 0
260
260
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)
261
296
diff --git a/Lib/importlib/_bootstrap_external.py b/Lib/importlib/_bootstrap_external.py
262
297
index 509f99ae8e..2005b88e94 100644
263
298
--- a/Lib/importlib/_bootstrap_external.py
@@ -3492,7 +3527,7 @@ index 41cfe07902..75cd6905a0 100644
3492
3527
#undef HAVE_PROCESS_H
3493
3528
3494
3529
diff --git a/setup.py b/setup.py
3495
- index 57be07a7e0..b15933862c 100644
3530
+ index 57be07a7e0..9a6bd11af6 100644
3496
3531
--- a/setup.py
3497
3532
+++ b/setup.py
3498
3533
@@ -44,6 +44,9 @@
@@ -3505,7 +3540,38 @@ index 57be07a7e0..b15933862c 100644
3505
3540
AIX = (HOST_PLATFORM.startswith('aix'))
3506
3541
VXWORKS = ('vxworks' in HOST_PLATFORM)
3507
3542
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 @@
3509
3575
extra_compile_args.append('-DMACOSX')
3510
3576
include_dirs.append('_ctypes/darwin')
3511
3577
@@ -3517,7 +3583,7 @@ index 57be07a7e0..b15933862c 100644
3517
3583
elif HOST_PLATFORM == 'sunos5':
3518
3584
# XXX This shouldn't be necessary; it appears that some
3519
3585
# of the assembler code is non-PIC (i.e. it has relocations
3520
- @@ -2001,7 +2009 ,8 @@
3586
+ @@ -2001,7 +2013 ,8 @@
3521
3587
libraries=['m']))
3522
3588
3523
3589
ffi_inc = sysconfig.get_config_var("LIBFFI_INCLUDEDIR")
@@ -3527,15 +3593,15 @@ index 57be07a7e0..b15933862c 100644
3527
3593
3528
3594
ffi_inc_dirs = self.inc_dirs.copy()
3529
3595
if MACOS:
3530
- @@ -2030,6 +2039 ,7 @@
3596
+ @@ -2030,6 +2043 ,7 @@
3531
3597
for lib_name in ('ffi', 'ffi_pic'):
3532
3598
if (self.compiler.find_library_file(self.lib_dirs, lib_name)):
3533
3599
ffi_lib = lib_name
3534
3600
+ self.use_system_libffi = True
3535
3601
break
3536
3602
3537
3603
if ffi_inc and ffi_lib:
3538
- @@ -2043,7 +2053 ,8 @@
3604
+ @@ -2043,7 +2057 ,8 @@
3539
3605
3540
3606
ext.include_dirs.append(ffi_inc)
3541
3607
ext.libraries.append(ffi_lib)
0 commit comments