@@ -257,6 +257,41 @@ index bf0d4333f9..8a4ba3666a 100644
257
257
def test_check_environ(self):
258
258
util._environ_checked = 0
259
259
os.environ.pop('HOME', None)
260
+ diff --git a/Lib/distutils/unixccompiler.py b/Lib/distutils/unixccompiler.py
261
+ index d00c48981e..5d12b4779d 100644
262
+ --- a/Lib/distutils/unixccompiler.py
263
+ +++ b/Lib/distutils/unixccompiler.py
264
+ @@ -270,9 +270,9 @@
265
+ static_f = self.library_filename(lib, lib_type='static')
266
+
267
+ if sys.platform == 'darwin':
268
+ - # On OSX users can specify an alternate SDK using
269
+ - # '-isysroot', calculate the SDK root if it is specified
270
+ - # (and use it further on)
271
+ + # On macOS users can specify an alternate SDK using
272
+ + # '-isysroot <path>' or --sysroot=<path>, calculate the SDK root
273
+ + # if it is specified (and use it further on)
274
+ #
275
+ # Note that, as of Xcode 7, Apple SDKs may contain textual stub
276
+ # libraries with .tbd extensions rather than the normal .dylib
277
+ @@ -291,12 +291,14 @@
278
+ cflags = sysconfig.get_config_var('CFLAGS')
279
+ m = re.search(r'-isysroot\s*(\S+)', cflags)
280
+ if m is None:
281
+ - sysroot = _osx_support._default_sysroot(sysconfig.get_config_var('CC'))
282
+ + m = re.search(r'--sysroot=(\S+)', cflags)
283
+ + if m is None:
284
+ + sysroot = _osx_support._default_sysroot(sysconfig.get_config_var('CC'))
285
+ + else:
286
+ + sysroot = m.group(1)
287
+ else:
288
+ sysroot = m.group(1)
289
+
290
+ -
291
+ -
292
+ for dir in dirs:
293
+ shared = os.path.join(dir, shared_f)
294
+ dylib = os.path.join(dir, dylib_f)
260
295
diff --git a/Lib/importlib/_bootstrap_external.py b/Lib/importlib/_bootstrap_external.py
261
296
index f3828b10e1..7e86539bfa 100644
262
297
--- a/Lib/importlib/_bootstrap_external.py
@@ -3429,7 +3464,7 @@ index aa515da465..81f956f3d2 100644
3429
3464
# Check for use of the system libmpdec library
3430
3465
AC_MSG_CHECKING(for --with-system-libmpdec)
3431
3466
diff --git a/setup.py b/setup.py
3432
- index 0bec170d3f..4e64c30d26 100644
3467
+ index 0bec170d3f..284eee3f51 100644
3433
3468
--- a/setup.py
3434
3469
+++ b/setup.py
3435
3470
@@ -63,6 +63,9 @@
@@ -3442,7 +3477,38 @@ index 0bec170d3f..4e64c30d26 100644
3442
3477
AIX = (HOST_PLATFORM.startswith('aix'))
3443
3478
VXWORKS = ('vxworks' in HOST_PLATFORM)
3444
3479
CC = os.environ.get("CC")
3445
- @@ -2122,6 +2125,11 @@
3480
+ @@ -142,16 +145,20 @@
3481
+ for var_name in make_vars:
3482
+ var = sysconfig.get_config_var(var_name)
3483
+ if var is not None:
3484
+ - m = re.search(r'--sysroot=([^"]\S*|"[^"]+")', var)
3485
+ - if m is not None:
3486
+ - sysroot = m.group(1).strip('"')
3487
+ - for subdir in subdirs:
3488
+ - if os.path.isabs(subdir):
3489
+ - subdir = subdir[1:]
3490
+ - path = os.path.join(sysroot, subdir)
3491
+ - if os.path.isdir(path):
3492
+ - dirs.append(path)
3493
+ - break
3494
+ + for pattern in [
3495
+ + r'-isysroot\s*([^"]\S*|"[^"]+")',
3496
+ + r'--sysroot=([^"]\S*|"[^"]+")',
3497
+ + ]:
3498
+ + m = re.search(pattern, var)
3499
+ + if m is not None:
3500
+ + sysroot = m.group(1).strip('"')
3501
+ + for subdir in subdirs:
3502
+ + if os.path.isabs(subdir):
3503
+ + subdir = subdir[1:]
3504
+ + path = os.path.join(sysroot, subdir)
3505
+ + if os.path.isdir(path):
3506
+ + dirs.append(path)
3507
+ + break
3508
+ return dirs
3509
+
3510
+
3511
+ @@ -2122,6 +2129,11 @@
3446
3512
extra_compile_args.append('-DMACOSX')
3447
3513
include_dirs.append('_ctypes/darwin')
3448
3514
@@ -3454,7 +3520,7 @@ index 0bec170d3f..4e64c30d26 100644
3454
3520
elif HOST_PLATFORM == 'sunos5':
3455
3521
# XXX This shouldn't be necessary; it appears that some
3456
3522
# of the assembler code is non-PIC (i.e. it has relocations
3457
- @@ -2151,7 +2159 ,8 @@
3523
+ @@ -2151,7 +2163 ,8 @@
3458
3524
libraries=['m']))
3459
3525
3460
3526
ffi_inc = sysconfig.get_config_var("LIBFFI_INCLUDEDIR")
@@ -3464,15 +3530,15 @@ index 0bec170d3f..4e64c30d26 100644
3464
3530
3465
3531
ffi_inc_dirs = self.inc_dirs.copy()
3466
3532
if MACOS:
3467
- @@ -2180,6 +2189 ,7 @@
3533
+ @@ -2180,6 +2193 ,7 @@
3468
3534
for lib_name in ('ffi', 'ffi_pic'):
3469
3535
if (self.compiler.find_library_file(self.lib_dirs, lib_name)):
3470
3536
ffi_lib = lib_name
3471
3537
+ self.use_system_libffi = True
3472
3538
break
3473
3539
3474
3540
if ffi_inc and ffi_lib:
3475
- @@ -2193,7 +2203 ,8 @@
3541
+ @@ -2193,7 +2207 ,8 @@
3476
3542
3477
3543
ext.include_dirs.append(ffi_inc)
3478
3544
ext.libraries.append(ffi_lib)
0 commit comments