Skip to content

Commit da7f6db

Browse files
authored
bpo-19960: Fix building of zlib on macOS without installed headers (GH-14257)
When building 2.7 on macOS without system header files installed in ``/usr/include``, a few extension modules dependent on system-supplied third-party libraries were not being built, most notably zlib. This situation arose in the past when building without the Command Line Tools and the option to install header files in the traditional system locations (like /usr/include). As of macOS 10.14, the header files are only available in an SDK so the problem addressed here affects most 2.7 builds.
1 parent bc60c47 commit da7f6db

File tree

2 files changed

+13
-2
lines changed

2 files changed

+13
-2
lines changed
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
When building 2.7 on macOS without system header files installed in
2+
``/usr/include``, a few extension modules dependent on system-supplied
3+
third-party libraries were not being built, most notably zlib.
4+

setup.py

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -39,8 +39,15 @@ def add_dir_to_list(dirlist, dir):
3939
"""Add the directory 'dir' to the list 'dirlist' (at the front) if
4040
1) 'dir' is not already in 'dirlist'
4141
2) 'dir' actually exists, and is a directory."""
42-
if dir is not None and os.path.isdir(dir) and dir not in dirlist:
43-
dirlist.insert(0, dir)
42+
if dir is not None and dir not in dirlist:
43+
if host_platform == 'darwin' and is_macosx_sdk_path(dir):
44+
# If in a macOS SDK path, check relative to the SDK root
45+
dir_exists = os.path.isdir(
46+
os.path.join(macosx_sdk_root(), dir[1:]))
47+
else:
48+
dir_exists = os.path.isdir(dir)
49+
if dir_exists:
50+
dirlist.insert(0, dir)
4451

4552
MACOS_SDK_ROOT = None
4653

0 commit comments

Comments
 (0)