Search code examples
pythonpython-2.7distutilsenthought

Distutils compiler options configuration


Maybe a stupid question, but I was wondering where Python's distutils get the compiler options from? It gets some linked directories wrong and I want to correct that once and for all.

I know there should be a prefix/lib/pythonver/distutils/distutils.cfg but I can't find any distutils.cfg anywhere on the computer. Obviously I haven't got a local setup.cfg or any $HOME/.pydistutils.cfg.

I'm using the Enthought 64-bit distribution, version 7.3 (Python 2.7) on Mac OS X 10.8.3

Cheers, U.


Solution

  • I actually export them to the environment, just like for autotools' configure:

    export CC=/usr/local/bin/clang
    export CFLAGS=-I${HOME}/include
    export LDFLAGS=-lboost
    

    If you also need to override the linker separately:

    export LDSHARED=/usr/local/bin/clang -shared
    

    And if you don't like exporting the settings to your environment, do something like this for a one-time setting:

    CC=/usr/local/bin/clang CFLAGS=-I${HOME}/include python setup.py build
    

    If you want to find out what the default options were when python was build, use python-config --<flag>. Some flags are cflags, ldflags, libs or includes.