Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
C
cpython
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Kirill Smelkov
cpython
Commits
c421c66a
Commit
c421c66a
authored
Jun 20, 2019
by
Ned Deily
Committed by
GitHub
Jun 20, 2019
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
bpo-36231: Support building on macOS without /usr/include (GH-13773) (GH-14256)
parent
598c7564
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
49 additions
and
7 deletions
+49
-7
Misc/NEWS.d/next/macOS/2019-06-03-05-49-49.bpo-36231.RfmW_p.rst
...EWS.d/next/macOS/2019-06-03-05-49-49.bpo-36231.RfmW_p.rst
+3
-0
setup.py
setup.py
+46
-7
No files found.
Misc/NEWS.d/next/macOS/2019-06-03-05-49-49.bpo-36231.RfmW_p.rst
0 → 100644
View file @
c421c66a
Support building Python on macOS without /usr/include installed. As of macOS
10.14, system header files are only available within an SDK provided by
either the Command Line Tools or the Xcode app.
setup.py
View file @
c421c66a
...
...
@@ -42,18 +42,57 @@ def add_dir_to_list(dirlist, dir):
if
dir
is
not
None
and
os
.
path
.
isdir
(
dir
)
and
dir
not
in
dirlist
:
dirlist
.
insert
(
0
,
dir
)
MACOS_SDK_ROOT
=
None
def
macosx_sdk_root
():
"""Return the directory of the current macOS SDK.
If no SDK was explicitly configured, call the compiler to find which
include files paths are being searched by default. Use '/' if the
compiler is searching /usr/include (meaning system header files are
installed) or use the root of an SDK if that is being searched.
(The SDK may be supplied via Xcode or via the Command Line Tools).
The SDK paths used by Apple-supplied tool chains depend on the
setting of various variables; see the xcrun man page for more info.
"""
Return the directory of the current OSX SDK,
or '/' if no SDK was specified.
"""
global
MACOS_SDK_ROOT
# If already called, return cached result.
if
MACOS_SDK_ROOT
:
return
MACOS_SDK_ROOT
cflags
=
sysconfig
.
get_config_var
(
'CFLAGS'
)
m
=
re
.
search
(
r'-isysroot\
s+(
\S+)'
,
cflags
)
if
m
is
None
:
sysroot
=
'/'
if
m
is
not
None
:
MACOS_SDK_ROOT
=
m
.
group
(
1
)
else
:
sysroot
=
m
.
group
(
1
)
return
sysroot
MACOS_SDK_ROOT
=
'/'
cc
=
sysconfig
.
get_config_var
(
'CC'
)
tmpfile
=
'/tmp/setup_sdk_root.%d'
%
os
.
getpid
()
try
:
os
.
unlink
(
tmpfile
)
except
:
pass
ret
=
os
.
system
(
'%s -E -v - </dev/null 2>%s 1>/dev/null'
%
(
cc
,
tmpfile
))
in_incdirs
=
False
try
:
if
ret
>>
8
==
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
)
return
MACOS_SDK_ROOT
def
is_macosx_sdk_path
(
path
):
"""
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment