Author dimpase
Recipients dimpase, ned.deily, ronaldoussoren
Date 2019-03-08.10:03:46
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1552039427.3.0.599611853277.issue36231@roundup.psfhosted.org>
In-reply-to
Content
Neither Xcode nor its command-line tools on macOS 10.14 Mojave come with header files installed in /usr/ and other "normal" directories.

This is not documented in https://devguide.python.org/setup/#macos-and-os-x

While an extra step to handle this, i.e. to install the headers, is available (see a discussion on https://bugs.python.org/issue34956), Apple stated that this workaround will disappear.

It is thus highly desirable to provide a way to deal with headers located not at /usr/include, but at `xcrun --show-sdk-path`/usr/include.
A small change in setup.py along the lines of the following:

--- a/setup.py
+++ b/setup.py
@@ -134,7 +134,8 @@ def macosx_sdk_root():
     cflags = sysconfig.get_config_var('CFLAGS')
     m = re.search(r'-isysroot\s+(\S+)', cflags)
     if m is None:
-        sysroot = '/'
+        import subprocess
+        sysroot = subprocess.check_output(["xcrun", "--show-sdk-path"]).decode("utf-8").strip('\n')
     else:
         sysroot = m.group(1)
     return sysroot
@@ -146,6 +147,7 @@ def is_macosx_sdk_path(path):
     """
     return ( (path.startswith('/usr/') and not path.startswith('/usr/local'))
                 or path.startswith('/System/')
+                or path.startswith('/Applications/')
                 or path.startswith('/Library/') )

with the necessary changes to enable various modules (see attachment for a complete POC diff against the current master), the result builds and passes all the (enabled) tests on an OSX 10.13 system with empty /usr/include and /usr/local/include containing only LZMA headers.

Needless to say, a proper patch would not modify Modules/Setup, it'd adjust configure.ac etc.
History
Date User Action Args
2019-03-08 10:03:47dimpasesetrecipients: + dimpase, ronaldoussoren, ned.deily
2019-03-08 10:03:47dimpasesetmessageid: <1552039427.3.0.599611853277.issue36231@roundup.psfhosted.org>
2019-03-08 10:03:47dimpaselinkissue36231 messages
2019-03-08 10:03:47dimpasecreate