sysconfig on OS X 10.7 (Lion) and XCode 4.2

D

David Riley

Hello all,

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.



- Dave
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,744
Messages
2,569,484
Members
44,903
Latest member
orderPeak8CBDGummies

Latest Threads

Top