Reinstall python on Mac OS 10.6 with a different version of gcc

I am trying to install a Python package that requires gcc 4.2 to run. My gcc correctly points to gcc-4.2, i.e.

$ gcc -v Using built-in specs. Target: i686-apple-darwin10 Configured with: /var/tmp/gcc/gcc-5664~38/src/configure --disable-checking --enable-werror --prefix=/usr --mandir=/share/man --enable-languages=c,objc,c++,obj-c++ --program-transform-name=/^[cg][^.-]*$/s/$/-4.2/ --with-slibdir=/usr/lib --build=i686-apple-darwin10 --program-prefix=i686-apple-darwin10- --host=x86_64-apple-darwin10 --target=i686-apple-darwin10 --with-gxx-include-dir=/include/c++/4.2.1 Thread model: posix gcc version 4.2.1 (Apple Inc. build 5664) 

However, my python is built using gcc 4.0, i.e.

 $ python Python 2.5.4 (r254:67917, Dec 23 2008, 15:47:06) [GCC 4.0.1 (Apple Inc. build 5363)] on darwin Type "help", "copyright", "credits" or "license" for more information. 

Is there a way to rebuild Python on GCC 4.2 without having to reinstall all my Python packages?

My operating system is Mac OS 10.6.

NOTE. This will not help me just point gcc to gcc-4.0. I need to use gcc-4.2.

+1
source share
2 answers

On current OS X, Pythons Distutils is trying to ensure that C-extension modules are built using the same GCC and MACOSX_DEPLOYMENT_TARGET (ABI) as the Python interpreter itself. This ensures that there are no conflicts with the underlying system libraries.

But if you are on OS X 10.6, then you are proposing a version of Python, this is not one of the supplied Apple Python, both of which are built using gcc-4.2. Most likely you have a senior python.org 2.5, also installed with symbolic links in /usr/local/bin .

 # OS X 10.6.4 $ /usr/bin/python -c 'import sys;print(sys.version)' 2.6.1 (r261:67515, Feb 11 2010, 00:51:29) [GCC 4.2.1 (Apple Inc. build 5646)] $ /usr/bin/python2.6 -c 'import sys;print(sys.version)' # same as above 2.6.1 (r261:67515, Feb 11 2010, 00:51:29) [GCC 4.2.1 (Apple Inc. build 5646)] $ /usr/bin/python2.5 -c 'import sys;print(sys.version)' 2.5.4 (r254:67916, Feb 11 2010, 00:50:55) [GCC 4.2.1 (Apple Inc. build 5646)] $ /usr/local/bin/python2.5 -c 'import sys;print(sys.version);print(sys.executable)' 2.5.4 (r254:67917, Dec 23 2008, 14:57:27) [GCC 4.0.1 (Apple Computer, Inc. build 5363)] /Library/Frameworks/Python.framework/Versions/2.5/Resources/Python.app/Contents/MacOS/Python 

which python will tell you which Python call is being called. Either use the absolute path to the interpreter you want, either change the PATH shell or remove the old Python 2.5.

+3
source

This is most likely a distutils problem, you do not need to recompile python or reinstall any packages.

Have you checked for which version the CC environment variable is set? It can be installed on 4.0. You can try:

 export CC=gcc-4.2 python setup.py build 

You can also take a look at:

/Library/Frameworks/Python.framework/Versions/Current/lib/python2.5/config/Makefile

This is where distutils gets its build settings.

+1
source

All Articles