sysconfig on OS X 10.7 (Lion) and XCode 4.2

Ned Deily nad at acm.org
Thu Oct 20 16:20:50 EDT 2011


In article <5ED3F418-A03D-4BE6-91A5-51C0DF899FC5 at mantaro.com>,
 David Riley <driley at mantaro.com> wrote:
> I've struggled mightily to get Numpy and pyopencl installed on my brand-new 
> Lion machine running XCode 4.2 (not recommended, I know, but I'm a sucker for 
> punishment).  I did finally succeed, anyway.
> 
> I found that the greatest problem I had (after installing gfortran from a 
> precompiled package) was getting setup.py and subsidiaries to use the right 
> GCC.  The python.org official builds of Python (I'm specifically using 3.2.2, 
> though I'm sure this applies to 2.7 as well) have some trouble with building 
> extensions because CC is specified as "gcc-4.2", which no longer exists in 
> XCode 4.2 (one could chalk that up to being Apple's problem, but hey).
> 
> The root of this problem is in the sysconfig module, which I assume has 
> hardcoded names for the compiler, etc.  Most insidious was fixing LDSHARED, 
> which was gcc-4.2 with a bunch of flags appended to it including the system 
> framework (for 10.6, I should point out, which is also what sysconfig 
> returned for sysconfig.platform()).
> 
> Is there any way to permanently override these values in sysconfig short of 
> building my own Python and installing it?  I'm having to override the 
> environment variables whenever I build a C/C++ module, and it's getting to be 
> a pain.
> 
> 
> 
> For anyone looking for the answer to a similar problem (usually gcc-4.2 not 
> being found when running setup.py), export the following environment 
> variables to build things under XCode 4.2:
> 
> CC=gcc
> CXX=g++
> LDSHARED="gcc -bundle -undefined dynamic_lookup -arch i386 -arch x86_64 
> -isysroot /Developer/SDKs/MacOSX10.7.sdk -isysroot 
> /Developer/SDKs/MacOSX10.7.sdk -g"
> 
> (obviously, replace 10.7 with 10.6 if you're building under 10.6)
> 
> For example:
> 
> sudo CC=gcc CXX=g++ LDSHARED="gcc -bundle -undefined dynamic_lookup -arch 
> i386 -arch x86_64 -isysroot /Developer/SDKs/MacOSX10.7.sdk -isysroot 
> /Developer/SDKs/MacOSX10.7.sdk -g" pip install pyopencl
> 
> 
> This will override the default values taken from the sysconfig module.

On OS X, Python's Distutils goes to some trouble to ensure that C 
extension modules are built with the same compiler and compatible 
settings as the Python interpreter itself was built.   The current 
python.org 64-bit/32-bit installers (which I assume you are using) for 
3.2.x and 2.7.x were built on 10.6 using the gcc-4.2 available in Xcode 
3.  Now that Xcode 4.2 has been released and has deleted gcc-4.2, that's 
a problem.  A thorough building and testing cycle using the various 
compiler options (llvm-gcc and clang) is needed for Lion; there have 
been problems already reported and corrected for clang with Xcode 4.1.  
I'm starting to do that.  It would be helpful if you could open an issue 
on the Python bug tracker (http://bugs.python.org) and summarize what 
you've found there.

-- 
 Ned Deily,
 nad at acm.org




More information about the Python-list mailing list