Set default compiler for binding C code in Python package

I am trying to compile a Python package that has C code generated by Cython, and I run:

gcc: error: x86_64: No such file or directory

which indicates that the gcc compiler is too large, so it no longer supports -arch. I tried installing CC=/usr/bin/gccbefore python setup.py install, and this works for the main compilation command, but not for the command to create a shared library of objects:

% setenv CC /usr/bin/gcc
% python setup.py install
running install
running build
running build_py
running build_ext
skipping 'hyperion/util/integrate_core.c' Cython extension (up-to-date)
building 'hyperion.util.integrate_core' extension
/usr/bin/gcc -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.2/lib/python2.7/site-packages/numpy/core/include -I/Library/Frameworks/EPD64.framework/Versions/7.2/include/python2.7 -c hyperion/util/integrate_core.c -o build/temp.macosx-10.5-x86_64-2.7/hyperion/util/integrate_core.o
gcc -bundle -undefined dynamic_lookup -g -arch x86_64 -arch x86_64 build/temp.macosx-10.5-x86_64-2.7/hyperion/util/integrate_core.o -o build/lib.macosx-10.5-x86_64-2.7/hyperion/util/integrate_core.so

gcc: error: x86_64: No such file or directory
gcc: error: x86_64: No such file or directory
gcc: error: unrecognized option β€˜-arch’
gcc: error: unrecognized option β€˜-arch’
error: command 'gcc' failed with exit status 1

Is there a way to specify an absolute path for the compiler to communicate?

+3
source share
2 answers

Use a variable LDSHARED: LDSHARED='/usr/bin/gcc -shared'.

He is buried in the module sysconfig. Try the following:

>>> from sysconfig import get_config_vars
>>> get_config_vars('CC', 'CXX', 'LDSHARED')
+1
source

I did it like this:

CXX="/Developer/usr/bin/g++-4.0" CC="/Developer/usr/bin/gcc-4.0" python setup.py build

, ""; , scipy/numpy.

( LD_LIBRARY_PATH=/Developer/SDKs/MacOSX10.6.sdk/usr/lib/ FFLAGS="-m64" CFLAGS="-arch x86_64 -I/Developer/SDKs/MacOSX10.6.sdk/usr/lib/gcc/i686-apple-darwin10/4.0.1/ -I/usr/local/include/freetype2 -I/usr/X11/include -L/usr/X11/lib" LDFLAGS="-Wall -undefined dynamic_lookup -bundle -lpng -arch x86_64" CXX="/Developer/usr/bin/g++-4.0" CC="/Developer/usr/bin/gcc-4.0" python setup.py build)

0

All Articles