@@ -260,6 +260,41 @@ index d4a01c6e91..f3fc4607e1 100644
260
260
def test_check_environ(self):
261
261
util._environ_checked = 0
262
262
os.environ.pop('HOME', None)
263
+ diff --git a/Lib/distutils/unixccompiler.py b/Lib/distutils/unixccompiler.py
264
+ index d00c48981e..5d12b4779d 100644
265
+ --- a/Lib/distutils/unixccompiler.py
266
+ +++ b/Lib/distutils/unixccompiler.py
267
+ @@ -270,9 +270,9 @@
268
+ static_f = self.library_filename(lib, lib_type='static')
269
+
270
+ if sys.platform == 'darwin':
271
+ - # On OSX users can specify an alternate SDK using
272
+ - # '-isysroot', calculate the SDK root if it is specified
273
+ - # (and use it further on)
274
+ + # On macOS users can specify an alternate SDK using
275
+ + # '-isysroot <path>' or --sysroot=<path>, calculate the SDK root
276
+ + # if it is specified (and use it further on)
277
+ #
278
+ # Note that, as of Xcode 7, Apple SDKs may contain textual stub
279
+ # libraries with .tbd extensions rather than the normal .dylib
280
+ @@ -291,12 +291,14 @@
281
+ cflags = sysconfig.get_config_var('CFLAGS')
282
+ m = re.search(r'-isysroot\s*(\S+)', cflags)
283
+ if m is None:
284
+ - sysroot = _osx_support._default_sysroot(sysconfig.get_config_var('CC'))
285
+ + m = re.search(r'--sysroot=(\S+)', cflags)
286
+ + if m is None:
287
+ + sysroot = _osx_support._default_sysroot(sysconfig.get_config_var('CC'))
288
+ + else:
289
+ + sysroot = m.group(1)
290
+ else:
291
+ sysroot = m.group(1)
292
+
293
+ -
294
+ -
295
+ for dir in dirs:
296
+ shared = os.path.join(dir, shared_f)
297
+ dylib = os.path.join(dir, dylib_f)
263
298
diff --git a/Lib/importlib/_bootstrap_external.py b/Lib/importlib/_bootstrap_external.py
264
299
index 49bcaea78d..891356e54d 100644
265
300
--- a/Lib/importlib/_bootstrap_external.py
@@ -3466,7 +3501,7 @@ index cc69015b10..d81f17dad6 100644
3466
3501
3467
3502
echo "creating Makefile" >&AS_MESSAGE_FD
3468
3503
diff --git a/setup.py b/setup.py
3469
- index 85a2b26357..510a1ac62b 100644
3504
+ index 85a2b26357..86d97d1dd8 100644
3470
3505
--- a/setup.py
3471
3506
+++ b/setup.py
3472
3507
@@ -84,6 +84,9 @@
@@ -3479,7 +3514,38 @@ index 85a2b26357..510a1ac62b 100644
3479
3514
AIX = (HOST_PLATFORM.startswith('aix'))
3480
3515
VXWORKS = ('vxworks' in HOST_PLATFORM)
3481
3516
CC = os.environ.get("CC")
3482
- @@ -2243,6 +2246,11 @@
3517
+ @@ -163,16 +166,20 @@
3518
+ for var_name in make_vars:
3519
+ var = sysconfig.get_config_var(var_name)
3520
+ if var is not None:
3521
+ - m = re.search(r'--sysroot=([^"]\S*|"[^"]+")', var)
3522
+ - if m is not None:
3523
+ - sysroot = m.group(1).strip('"')
3524
+ - for subdir in subdirs:
3525
+ - if os.path.isabs(subdir):
3526
+ - subdir = subdir[1:]
3527
+ - path = os.path.join(sysroot, subdir)
3528
+ - if os.path.isdir(path):
3529
+ - dirs.append(path)
3530
+ - break
3531
+ + for pattern in [
3532
+ + r'-isysroot\s*([^"]\S*|"[^"]+")',
3533
+ + r'--sysroot=([^"]\S*|"[^"]+")',
3534
+ + ]:
3535
+ + m = re.search(pattern, var)
3536
+ + if m is not None:
3537
+ + sysroot = m.group(1).strip('"')
3538
+ + for subdir in subdirs:
3539
+ + if os.path.isabs(subdir):
3540
+ + subdir = subdir[1:]
3541
+ + path = os.path.join(sysroot, subdir)
3542
+ + if os.path.isdir(path):
3543
+ + dirs.append(path)
3544
+ + break
3545
+ return dirs
3546
+
3547
+
3548
+ @@ -2243,6 +2250,11 @@
3483
3549
extra_compile_args.append('-DMACOSX')
3484
3550
include_dirs.append('_ctypes/darwin')
3485
3551
@@ -3491,7 +3557,7 @@ index 85a2b26357..510a1ac62b 100644
3491
3557
elif HOST_PLATFORM == 'sunos5':
3492
3558
# XXX This shouldn't be necessary; it appears that some
3493
3559
# of the assembler code is non-PIC (i.e. it has relocations
3494
- @@ -2272,7 +2280 ,8 @@
3560
+ @@ -2272,7 +2284 ,8 @@
3495
3561
libraries=['m']))
3496
3562
3497
3563
ffi_inc = sysconfig.get_config_var("LIBFFI_INCLUDEDIR")
@@ -3501,15 +3567,15 @@ index 85a2b26357..510a1ac62b 100644
3501
3567
3502
3568
ffi_inc_dirs = self.inc_dirs.copy()
3503
3569
if MACOS:
3504
- @@ -2301,6 +2310 ,7 @@
3570
+ @@ -2301,6 +2314 ,7 @@
3505
3571
for lib_name in ('ffi', 'ffi_pic'):
3506
3572
if (self.compiler.find_library_file(self.lib_dirs, lib_name)):
3507
3573
ffi_lib = lib_name
3508
3574
+ self.use_system_libffi = True
3509
3575
break
3510
3576
3511
3577
if ffi_inc and ffi_lib:
3512
- @@ -2314,7 +2324 ,8 @@
3578
+ @@ -2314,7 +2328 ,8 @@
3513
3579
3514
3580
ext.include_dirs.append(ffi_inc)
3515
3581
ext.libraries.append(ffi_lib)
0 commit comments