Skip to content

Commit ed15fed

Browse files
committed
Update sysroot identification for iOS/tvOS/watchOS.
1 parent ead0528 commit ed15fed

File tree

1 file changed

+71
-5
lines changed

1 file changed

+71
-5
lines changed

patch/Python/Python.patch

+71-5
Original file line numberDiff line numberDiff line change
@@ -82,6 +82,41 @@ index 0912ffd15c..959aa90522 100644
8282
class CygwinCCompilerTestCase(support.TempdirManager,
8383
unittest.TestCase):
8484

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)
85120
diff --git a/Lib/distutils/util.py b/Lib/distutils/util.py
86121
index 2ce5c5b64d..6e10a0c4a5 100644
87122
--- a/Lib/distutils/util.py
@@ -2530,7 +2565,7 @@ index ab5e1de6fa..99d3147959 100644
25302565
[QNX*], [PY_STDLIB_MOD_SET_NA([_scproxy], [nis])],
25312566
[FreeBSD*], [PY_STDLIB_MOD_SET_NA([_scproxy], [spwd])],
25322567
diff --git a/setup.py b/setup.py
2533-
index 15d0d4576a..b59083aa47 100644
2568+
index 15d0d4576a..a080c69d1f 100644
25342569
--- a/setup.py
25352570
+++ b/setup.py
25362571
@@ -82,6 +82,9 @@
@@ -2543,7 +2578,38 @@ index 15d0d4576a..b59083aa47 100644
25432578
AIX = (HOST_PLATFORM.startswith('aix'))
25442579
VXWORKS = ('vxworks' in HOST_PLATFORM)
25452580
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 @@
25472613
extra_compile_args.append('-DMACOSX')
25482614
include_dirs.append('_ctypes/darwin')
25492615

@@ -2555,7 +2621,7 @@ index 15d0d4576a..b59083aa47 100644
25552621
elif HOST_PLATFORM == 'sunos5':
25562622
# XXX This shouldn't be necessary; it appears that some
25572623
# of the assembler code is non-PIC (i.e. it has relocations
2558-
@@ -1418,7 +1426,8 @@
2624+
@@ -1418,7 +1430,8 @@
25592625
self.addext(Extension('_ctypes_test', ['_ctypes/_ctypes_test.c']))
25602626

25612627
ffi_inc = sysconfig.get_config_var("LIBFFI_INCLUDEDIR")
@@ -2565,15 +2631,15 @@ index 15d0d4576a..b59083aa47 100644
25652631

25662632
ffi_inc_dirs = self.inc_dirs.copy()
25672633
if MACOS:
2568-
@@ -1447,6 +1456,7 @@
2634+
@@ -1447,6 +1460,7 @@
25692635
for lib_name in ('ffi', 'ffi_pic'):
25702636
if (self.compiler.find_library_file(self.lib_dirs, lib_name)):
25712637
ffi_lib = lib_name
25722638
+ self.use_system_libffi = True
25732639
break
25742640

25752641
if ffi_inc and ffi_lib:
2576-
@@ -1460,7 +1470,8 @@
2642+
@@ -1460,7 +1474,8 @@
25772643

25782644
ext.include_dirs.append(ffi_inc)
25792645
ext.libraries.append(ffi_lib)

0 commit comments

Comments
 (0)