mirror of
https://github.com/python/cpython.git
synced 2025-07-12 13:55:34 +00:00
bpo-41116: Ensure system supplied libraries are found on macOS 11 (GH-23301) (GH-23455)
On macOS system provided libraries are in a shared library cache
and not at their usual location. This PR teaches distutils to search
in the SDK, even if there was no "-sysroot" argument in
the compiler flags.
(cherry picked from commit 404a719b51
)
Co-authored-by: Ronald Oussoren <ronaldoussoren@mac.com>
This commit is contained in:
parent
4f87126969
commit
0aab3522b2
4 changed files with 38 additions and 30 deletions
31
setup.py
31
setup.py
|
@ -9,6 +9,7 @@ import re
|
|||
import sys
|
||||
import sysconfig
|
||||
from glob import glob, escape
|
||||
import _osx_support
|
||||
|
||||
|
||||
try:
|
||||
|
@ -176,34 +177,10 @@ def macosx_sdk_root():
|
|||
m = re.search(r'-isysroot\s*(\S+)', cflags)
|
||||
if m is not None:
|
||||
MACOS_SDK_ROOT = m.group(1)
|
||||
MACOS_SDK_SPECIFIED = MACOS_SDK_ROOT != '/'
|
||||
else:
|
||||
MACOS_SDK_ROOT = '/'
|
||||
MACOS_SDK_SPECIFIED = False
|
||||
cc = sysconfig.get_config_var('CC')
|
||||
tmpfile = '/tmp/setup_sdk_root.%d' % os.getpid()
|
||||
try:
|
||||
os.unlink(tmpfile)
|
||||
except:
|
||||
pass
|
||||
ret = run_command('%s -E -v - </dev/null 2>%s 1>/dev/null' % (cc, tmpfile))
|
||||
in_incdirs = False
|
||||
try:
|
||||
if ret == 0:
|
||||
with open(tmpfile) as fp:
|
||||
for line in fp.readlines():
|
||||
if line.startswith("#include <...>"):
|
||||
in_incdirs = True
|
||||
elif line.startswith("End of search list"):
|
||||
in_incdirs = False
|
||||
elif in_incdirs:
|
||||
line = line.strip()
|
||||
if line == '/usr/include':
|
||||
MACOS_SDK_ROOT = '/'
|
||||
elif line.endswith(".sdk/usr/include"):
|
||||
MACOS_SDK_ROOT = line[:-12]
|
||||
finally:
|
||||
os.unlink(tmpfile)
|
||||
MACOS_SDK_ROOT = _osx_support._default_sysroot(
|
||||
sysconfig.get_config_var('CC'))
|
||||
MACOS_SDK_SPECIFIED = MACOS_SDK_ROOT != '/'
|
||||
|
||||
return MACOS_SDK_ROOT
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue