Skip to content

Commit b889b12

Browse files
committed
Update sysroot identification for iOS/tvOS/watchOS.
1 parent fffcd9f commit b889b12

File tree

1 file changed

+71
-5
lines changed

1 file changed

+71
-5
lines changed

patch/Python/Python.patch

Lines changed: 71 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -260,6 +260,41 @@ index d4a01c6e91..f3fc4607e1 100644
260260
def test_check_environ(self):
261261
util._environ_checked = 0
262262
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)
263298
diff --git a/Lib/importlib/_bootstrap_external.py b/Lib/importlib/_bootstrap_external.py
264299
index 49bcaea78d..891356e54d 100644
265300
--- a/Lib/importlib/_bootstrap_external.py
@@ -3466,7 +3501,7 @@ index cc69015b10..d81f17dad6 100644
34663501

34673502
echo "creating Makefile" >&AS_MESSAGE_FD
34683503
diff --git a/setup.py b/setup.py
3469-
index 85a2b26357..510a1ac62b 100644
3504+
index 85a2b26357..86d97d1dd8 100644
34703505
--- a/setup.py
34713506
+++ b/setup.py
34723507
@@ -84,6 +84,9 @@
@@ -3479,7 +3514,38 @@ index 85a2b26357..510a1ac62b 100644
34793514
AIX = (HOST_PLATFORM.startswith('aix'))
34803515
VXWORKS = ('vxworks' in HOST_PLATFORM)
34813516
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 @@
34833549
extra_compile_args.append('-DMACOSX')
34843550
include_dirs.append('_ctypes/darwin')
34853551

@@ -3491,7 +3557,7 @@ index 85a2b26357..510a1ac62b 100644
34913557
elif HOST_PLATFORM == 'sunos5':
34923558
# XXX This shouldn't be necessary; it appears that some
34933559
# of the assembler code is non-PIC (i.e. it has relocations
3494-
@@ -2272,7 +2280,8 @@
3560+
@@ -2272,7 +2284,8 @@
34953561
libraries=['m']))
34963562

34973563
ffi_inc = sysconfig.get_config_var("LIBFFI_INCLUDEDIR")
@@ -3501,15 +3567,15 @@ index 85a2b26357..510a1ac62b 100644
35013567

35023568
ffi_inc_dirs = self.inc_dirs.copy()
35033569
if MACOS:
3504-
@@ -2301,6 +2310,7 @@
3570+
@@ -2301,6 +2314,7 @@
35053571
for lib_name in ('ffi', 'ffi_pic'):
35063572
if (self.compiler.find_library_file(self.lib_dirs, lib_name)):
35073573
ffi_lib = lib_name
35083574
+ self.use_system_libffi = True
35093575
break
35103576

35113577
if ffi_inc and ffi_lib:
3512-
@@ -2314,7 +2324,8 @@
3578+
@@ -2314,7 +2328,8 @@
35133579

35143580
ext.include_dirs.append(ffi_inc)
35153581
ext.libraries.append(ffi_lib)

0 commit comments

Comments
 (0)