How to make Python and distutils use the right SDK on Mac OS X?
I use Python on Mac OS X version 10.6. I recently installed the newest Mac OS X developer tools SDK, which has GCC in it. The SDKs I have are:
$ ls /Developer/SDKs/
MacOSX10.4u.sdk MacOSX10.5.sdk MacOSX10.6.sdk
I'd like to use Mac OS X 10.6 with Python/distutils, whenever I install a python package with "setup.py install" that requires compilation.
I notice that Python passes the -isysroot flags and paths to Mac OS X 10.5 (not 10.6), i.e.:
$ python-config --cflags --ldflags
-I/Library/Frameworks/EPD64.framework/Versions/7.0/include/python2.7 -I/Library/Frameworks/EPD64.framework/Versions/7.0/include/python2.7 -fno-strict-aliasing -fno-common -dynamic -arch x86_64 -isysroot /Developer/SDKs/MacOSX10.5.sdk -DNDEBUG -g -O3 -arch x86_64 -isysroot /Developer/SDKs/MacOSX10.5.sdk -I/Library/Frameworks/EPD64.framework/Versions/7.0/include
-L/Library/Frameworks/EPD64.framework/Versions/7.0/lib/python2.7/config -ldl -framework CoreFoundation -lpython2.7 EPD64.framework/Versions/7.0/Python
How can I correct this? I'd like it to use the 10.6 SDK instead.
Right now when I run "python setup.py install" on a package that requires C compilation, it yields calls to GCC that look like this:
gcc -fno-strict-aliasing -fno-common -dynamic -arch x86_6开发者_JAVA百科4 -isysroot /Developer/SDKs/MacOSX10.5.sdk -DNDEBUG -g -O3 -arch x86_64 -isysroot /Developer/SDKs/MacOSX10.5.sdk -I/Library/Frameworks/EPD64.framework/Versions/7.0/include -DHAVE_RINTF=1 -DHAVE_FINITE=1 -DHAVE_EXPM1=1 -DHAVE_RINT=1 -DHAVE_LOG2=1 -DHAVE_LOGBL=1 -DHAVE_SNPRINTF=1 -DHAVE_LOG1P=1 -DHAVE_ROUND=1 -DHAVE_FMIN=1 -Iinclude -Isrc/lapack -Isrc/f2c -I/Library/Frameworks/EPD64.framework/Versions/7.0/include/python2.7 -c src/f2c/signal_.c -o build/temp.macosx-10.5-x86_64-2.7/src/f2c/signal_.o
which calls 10.5 SDKs in its path.
I use the Enthought Python Distribution installation of Python in case that makes a difference.
Thanks very much.
It's a feature and should not cause you any worries. Distutils does this deliberately to ensure that C extension modules that you build are built the same way that the Python interpreter in use was built. Extensions built this way are upwards compatible: they will work on 10.6 as well. If you absolutely want to use 10.6 ABI features, you should use a Python that was built using the 10.6 SDK, for instance, from a recent python.org 64-bit installer or from MacPorts or Homebrew.
I completely disagree with @Ned Deily
The poster obviously uses Enthought Python Distribution (EPD), and installing the whole new Python would require an installation of the whole new infrastracture. I have the same situation. On MacBook with Mac Os X 10.6 the project (MeshPy) builds correctly, but on the Imac with Mac Os X 10.7 it does not (no 10.5 SDK is provided, and with this SDK EPD was built). You can try to install this old SDK, however, a much simpler hack (hopefully it works) is to make a symlink:
sudo ln -sf MacOSX10.6.sdk MacOSX10.5.sdk
It worked for me.
精彩评论