@@ -82,6 +82,41 @@ index 0912ffd15c..959aa90522 100644
82
82
class CygwinCCompilerTestCase(support.TempdirManager,
83
83
unittest.TestCase):
84
84
85
+ diff --git a/Lib/distutils/unixccompiler.py b/Lib/distutils/unixccompiler.py
86
+ index d00c48981e..5d12b4779d 100644
87
+ --- a/Lib/distutils/unixccompiler.py
88
+ +++ b/Lib/distutils/unixccompiler.py
89
+ @@ -270,9 +270,9 @@
90
+ static_f = self.library_filename(lib, lib_type='static')
91
+
92
+ if sys.platform == 'darwin':
93
+ - # On OSX users can specify an alternate SDK using
94
+ - # '-isysroot', calculate the SDK root if it is specified
95
+ - # (and use it further on)
96
+ + # On macOS users can specify an alternate SDK using
97
+ + # '-isysroot <path>' or --sysroot=<path>, calculate the SDK root
98
+ + # if it is specified (and use it further on)
99
+ #
100
+ # Note that, as of Xcode 7, Apple SDKs may contain textual stub
101
+ # libraries with .tbd extensions rather than the normal .dylib
102
+ @@ -291,12 +291,14 @@
103
+ cflags = sysconfig.get_config_var('CFLAGS')
104
+ m = re.search(r'-isysroot\s*(\S+)', cflags)
105
+ if m is None:
106
+ - sysroot = _osx_support._default_sysroot(sysconfig.get_config_var('CC'))
107
+ + m = re.search(r'--sysroot=(\S+)', cflags)
108
+ + if m is None:
109
+ + sysroot = _osx_support._default_sysroot(sysconfig.get_config_var('CC'))
110
+ + else:
111
+ + sysroot = m.group(1)
112
+ else:
113
+ sysroot = m.group(1)
114
+
115
+ -
116
+ -
117
+ for dir in dirs:
118
+ shared = os.path.join(dir, shared_f)
119
+ dylib = os.path.join(dir, dylib_f)
85
120
diff --git a/Lib/distutils/util.py b/Lib/distutils/util.py
86
121
index 2ce5c5b64d..6e10a0c4a5 100644
87
122
--- a/Lib/distutils/util.py
@@ -2530,7 +2565,7 @@ index ab5e1de6fa..99d3147959 100644
2530
2565
[QNX*], [PY_STDLIB_MOD_SET_NA([_scproxy], [nis])],
2531
2566
[FreeBSD*], [PY_STDLIB_MOD_SET_NA([_scproxy], [spwd])],
2532
2567
diff --git a/setup.py b/setup.py
2533
- index 15d0d4576a..b59083aa47 100644
2568
+ index 15d0d4576a..a080c69d1f 100644
2534
2569
--- a/setup.py
2535
2570
+++ b/setup.py
2536
2571
@@ -82,6 +82,9 @@
@@ -2543,7 +2578,38 @@ index 15d0d4576a..b59083aa47 100644
2543
2578
AIX = (HOST_PLATFORM.startswith('aix'))
2544
2579
VXWORKS = ('vxworks' in HOST_PLATFORM)
2545
2580
EMSCRIPTEN = HOST_PLATFORM == 'emscripten-wasm32'
2546
- @@ -1396,6 +1399,11 @@
2581
+ @@ -166,16 +169,20 @@
2582
+ for var_name in make_vars:
2583
+ var = sysconfig.get_config_var(var_name)
2584
+ if var is not None:
2585
+ - m = re.search(r'--sysroot=([^"]\S*|"[^"]+")', var)
2586
+ - if m is not None:
2587
+ - sysroot = m.group(1).strip('"')
2588
+ - for subdir in subdirs:
2589
+ - if os.path.isabs(subdir):
2590
+ - subdir = subdir[1:]
2591
+ - path = os.path.join(sysroot, subdir)
2592
+ - if os.path.isdir(path):
2593
+ - dirs.append(path)
2594
+ - break
2595
+ + for pattern in [
2596
+ + r'-isysroot\s*([^"]\S*|"[^"]+")',
2597
+ + r'--sysroot=([^"]\S*|"[^"]+")',
2598
+ + ]:
2599
+ + m = re.search(pattern, var)
2600
+ + if m is not None:
2601
+ + sysroot = m.group(1).strip('"')
2602
+ + for subdir in subdirs:
2603
+ + if os.path.isabs(subdir):
2604
+ + subdir = subdir[1:]
2605
+ + path = os.path.join(sysroot, subdir)
2606
+ + if os.path.isdir(path):
2607
+ + dirs.append(path)
2608
+ + break
2609
+ return dirs
2610
+
2611
+
2612
+ @@ -1396,6 +1403,11 @@
2547
2613
extra_compile_args.append('-DMACOSX')
2548
2614
include_dirs.append('_ctypes/darwin')
2549
2615
@@ -2555,7 +2621,7 @@ index 15d0d4576a..b59083aa47 100644
2555
2621
elif HOST_PLATFORM == 'sunos5':
2556
2622
# XXX This shouldn't be necessary; it appears that some
2557
2623
# of the assembler code is non-PIC (i.e. it has relocations
2558
- @@ -1418,7 +1426 ,8 @@
2624
+ @@ -1418,7 +1430 ,8 @@
2559
2625
self.addext(Extension('_ctypes_test', ['_ctypes/_ctypes_test.c']))
2560
2626
2561
2627
ffi_inc = sysconfig.get_config_var("LIBFFI_INCLUDEDIR")
@@ -2565,15 +2631,15 @@ index 15d0d4576a..b59083aa47 100644
2565
2631
2566
2632
ffi_inc_dirs = self.inc_dirs.copy()
2567
2633
if MACOS:
2568
- @@ -1447,6 +1456 ,7 @@
2634
+ @@ -1447,6 +1460 ,7 @@
2569
2635
for lib_name in ('ffi', 'ffi_pic'):
2570
2636
if (self.compiler.find_library_file(self.lib_dirs, lib_name)):
2571
2637
ffi_lib = lib_name
2572
2638
+ self.use_system_libffi = True
2573
2639
break
2574
2640
2575
2641
if ffi_inc and ffi_lib:
2576
- @@ -1460,7 +1470 ,8 @@
2642
+ @@ -1460,7 +1474 ,8 @@
2577
2643
2578
2644
ext.include_dirs.append(ffi_inc)
2579
2645
ext.libraries.append(ffi_lib)
0 commit comments