[Pythonmac-SIG] Building extension modules with Xcode 5

Andrew Barnert abarnert at yahoo.com
Fri Oct 25 01:50:38 CEST 2013


If you use a binary installer of Python 2.7.5, 3.3.2, or 3.4.0a4 from python.org on either 10.8 or 10.9, and you have Xcode 5, you can't build any C extension modules, because you don't have a compiler named "gcc-4.2".

What should users be doing until this is fixed?

The workaround that everyone suggests, setting CC=clang CXX=clang++, does not work for many packages because they depend on other variables (MAINCC, LINKCC, or, worst of all, CONFIG_ARGS, which you don't want to try passing on the command line).


The best workarounds that I've discovered are: (1) use a Homebrew or manually-built Python instead of the installers from python.org, or (2) keep an old machine around (ideally with OS X 10.6.8 and Xcode 3.2.6, but at least with OS X 10.8.5 and Xcode 4.6.3) and build all your Python extensions there. Neither one of these seems very novice-friendly.

You can also hack up /Library/Frameworks/Python.framework/Versions/X.Y/lib/pythonX.Y/config-X.Ym/Makefile, or create a bunch of symlinks to trick the dev environment into working, but those seem much less like good ideas.

Meanwhile, what's the plan to fix this? I've seen http://bugs.python.org/issue19019, but that doesn't seem likely to be resolved soon, or to be ported back to 3.3 and 2.7.


If there isn't one, I think there may be a simple solution: Change the default darwin compiler from gcc-4.2 to gcc or cc; make new builds of 2.7.5, 3.3.2, and 3.4.0a4; test and ship.

I believe that may break Xcode 3.1, but not Xcode 3.2, because Xcode 3.2's gcc and cc are both gcc 4.2, not gcc 4.0. (Unfortunately, I do not have a test machine at the moment to verify this.) Meanwhile, in Xcode 4.2-4.6.3, gcc and cc are both llvm-gcc-4.2, and in 5.0-5.0.1, they're both clang, but since those are the closest things those environment have to gcc 4.2 anyway, that's not a problem.

What I have verified is this: On OS X 10.7.5, with Xcode 4.1.0, build Python 3.3.2 with gcc and the 10.6 SDK. Install the result on a machine with OS X 10.9.0 and Xcode 5.0.1. Use it to install and test numpy, lxml, and appscript.


More information about the Pythonmac-SIG mailing list