
see below for comments. Michiel Jan Laurens de Hoon wrote:
I am trying to use distutils to install a Python extension module. The extension module needs gcc to compile. Unfortunately, on my unix system, distutils uses the standard C compiler cc instead of gcc, and the compilation fails. The gcc compiler is available on our system; however, I don't know how to tell distutils to use gcc instead of cc.
Some people on comp.lang.python have told me that distutils looks for the environment variable CC, and uses the corresponding compiler for the build process. However, I couldn't get this to work on my Unix system. Both set CC=gcc and setenv CC gcc didn't have any effect. Likewise, export CC=gcc is ignored on my Cygwin system.
In an effort to get to the bottom of this, I looked at the distutils source code. As far as I can tell, distutils calls customize_compiler, which calls get_config_vars, which calls _init_posix, which calls parse_makefile. This then finds the arguments supplied to get_config_vars from the python Makefile. Does anybody know where the checks for the environment variables are made? If no such checks are made, is this something that should be added to distutils? I am willing to spend some time on this to get this working.
Below I copied some output of my trials with distutils.
Thanks in advance,
--Michiel. University of Tokyo, Human Genome Center
blue{mdehoon}23: set CC=gcc blue{mdehoon}24: python setup.py build running build running build_py not copying Pycluster/__init__.py (output up-to-date) running build_ext building 'Pycluster.cluster' extension cc -DNDEBUG -O -OPT:Olimit=0 -Iranlib/src -I/usr/local/include/python2.2 -c cluster.c -o build/temp.irix64-6.5-2.2/cluster.o
... and so on
With setenv CC gcc, I get the same result:
blue{mdehoon}6: setenv CC gcc blue{mdehoon}7: python setup.py build running build running build_py not copying Pycluster/__init__.py (output up-to-date) running build_ext building 'Pycluster.cluster' extension cc -DNDEBUG -O -OPT:Olimit=0 -Iranlib/src -I/usr/local/include/python2.2 -c clus ter.c -o build/temp.irix64-6.5-2.2/cluster.o ... and so on.
Distuitls use always the compiler used for compilation of Python. It reads it from the Python Makefile, if I remember right. And it get there also the compiler options. So a possible solution would be create an script called cc, put in your PATH and try it this way. This script has then to call your prefered compiler and possibly also modify the compiler options if necessary.
I have tried export CC=bcc32 before on Cygwin, just to see what would happen, but that also got ignored by distutils:
On Windows to use Borland's Compiler try python setup.py build --compiler=bcpp