To force distutils to use a separate compiler, you can override several variables through the environment. First find out which distutils use by default:
>>> from distutils import sysconfig >>> sysconfig.get_config_var('LDSHARED') 'gcc-4.0 -Wl,-F. -bundle -undefined dynamic_lookup' >>> sysconfig.get_config_var('CC') 'gcc-4.0'
Then you need to override them, replacing the version of gcc that you would like to use:
% LDSHARED="gcc-4.2 -Wl,-F. -bundle -undefined dynamic_lookup" CC=gcc-4.2 \ /usr/bin/python setup.py build_ext
Keep in mind that the default sysconfig values ββare extracted from the Makefile that was originally used to compile python, so using them may lead to unexpected results:
>>> path = sysconfig.get_python_lib(plat_specific=1, standard_lib=1) >>> os.path.join(path, 'config', 'Makefile') '/System/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/config/Makefile'
samplebias
source share