classification
Title: zlib skipped when building 2.7 on macOS without /usr/include installed
Type: compile error Stage: resolved
Components: Build Versions: Python 2.7
process
Status: closed Resolution: fixed
Dependencies: Superseder:
Assigned To: ronaldoussoren Nosy List: hynek, ned.deily, ronaldoussoren
Priority: high Keywords: needs review, patch

Created on 2013-12-12 12:07 by ronaldoussoren, last changed 2019-07-01 23:19 by ned.deily. This issue is now closed.

Files
File name Uploaded Description Edit
python2.7-alternative-sdk.txt ronaldoussoren, 2013-12-12 12:07 review
Pull Requests
URL Status Linked Edit
PR 14257 merged ned.deily, 2019-06-20 06:08
Messages (4)
msg205952 - (view) Author: Ronald Oussoren (ronaldoussoren) * (Python committer) Date: 2013-12-12 12:07
When you build python 2.7 on an OSX 10.9 machine with Xcode but without the command-line tools installed that build mostly succeeds, but doesn't detect a number of dependencies (in particular zlib).

The attached patch teaches "add_dir_to_list" about the SDK sysroot on OSX and with that the build succeeds.

Aside: I also noticed problems with build tinter, with 2.7 but also with 3.3 and 3.4. I'll file a separate issue about that.
msg228476 - (view) Author: Mark Lawrence (BreamoreBoy) * Date: 2014-10-04 18:40
Just a reminder that a patch review is needed here guys.
msg346102 - (view) Author: Ned Deily (ned.deily) * (Python committer) Date: 2019-06-20 06:34
Now that Apple, as of 10.14, has removed the option to install system header files into their traditional locations (like /usr/include), thus making every build a build from an SDK, this problem is now more noticeable.  At least, I finally noticed it while fixing the more general problems that setup.py had on all branches (see Issue36231).  This issue is in addition and is specific to 2.7.  As can be seen in Ronald's patch, which I didn't find until after I had written my own, the problem is that, in 2.7's setup.py, add_dir_to_list() does not take the SDK manipulation into account and, in particular, skips adding /usr/include because that directory doen't exist in the root filesystem anymore.  On my systems, besides zlib, the dbm and nis modules were also being skipped. Curiously, some other extension modules with system library dependencies do get built properly, like _sqlite3, because their build step in setup.py explicitly added /usr/include to the SDK search paths.

Anyway, the PR I produced is somewhat more complicated that Ronald's original patch.  It's more careful about what paths it checks for and it also stores the directory name, if found, without the prepended SDK path.  That may be important in other steps in setup.py where it is doing path comparisons.  The SDK will eventually get added again, either explicitly or implicitly by the compiler tool chain.
msg347087 - (view) Author: Ned Deily (ned.deily) * (Python committer) Date: 2019-07-01 23:15
New changeset da7f6dbbf52fe7074360a9eae918806da60139c5 by Ned Deily in branch '2.7':
bpo-19960: Fix building of zlib on macOS without installed headers (GH-14257)
https://github.com/python/cpython/commit/da7f6dbbf52fe7074360a9eae918806da60139c5
History
Date User Action Args
2019-07-01 23:19:24ned.deilysetstatus: open -> closed
resolution: fixed
stage: patch review -> resolved
2019-07-01 23:15:12ned.deilysetmessages: + msg347087
2019-06-20 06:34:31ned.deilysetpriority: normal -> high

messages: + msg346102
title: MacOSX: Building 2.7 without the xcode command line tools installed -> zlib skipped when building 2.7 on macOS without /usr/include installed
2019-06-20 06:08:24ned.deilysetpull_requests: + pull_request14087
2019-04-26 18:03:55BreamoreBoysetnosy: - BreamoreBoy
2014-10-04 18:40:20BreamoreBoysetnosy: + BreamoreBoy
messages: + msg228476
2013-12-12 12:07:05ronaldoussorencreate