Issue 19389: find_file might return a different directory than the tested file (original) (raw)
With Maverick OSX (latest version), there is no /usr/include/zlib.h anymore. If you try to compile Python with -sysroot, it trigger a error message:
error: /usr/include/zlib.h: No such file or directory
The issue is in setup.py, where find_file is checking the existence of a filename, but if the filename has been found in a sysroot, it will return the path without the sysroot.
In this case (zlib), find_file correctly find the zlib.h in /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS7.0.sdk/usr/include/zlib.h, but return "/usr/include", and then the setup.py open '/usr/include/zlib.h', which fail.
Thanks for the report. The issue of setup.py not looking in an OS X SDK for zlib.h was recently fixed in currently active branches: f3a2dab1623b (default), 2d8d5fea6194 (3.3), c207ac413457 (2.7).
By the way, there has been a lot of confusion about the installation of header files in OS X 10.9 Mavericks, brought on by Apple itself. In recent previous releases, most header files were only installed in the normal locations (/usr/include, /System/Library/Frameworks) as part of the Command Line Tools component (either through Xcode or the downloadable standalone package). Early on in the life cycle of Mavericks development, there apparently was an attempt to no longer install the header files by the CLT packages, forcing everyone to reference them via an SDK. For whatever reason, that attempt was dropped before Mavericks was released. With the 10.9 CLT properly installed, you should see /usr/include correctly populated, including zlib.h. In 10.9, the new way to force CLT to be installed is:
xcode-select --install