Installing mod_wsgi against Python 2.6 on Mac OSX 10.7 (Lion)
23/04/2012
If you want to install mod_wsgi on Mac OSX against Python 2.6.7 (default install) the switch --with-python=/usr/bin/python2.6 is not enough.
$ ./configure --with-python=/usr/bin/python2.6
checking for apxs2... no
checking for apxs... /usr/sbin/apxs
checking Apache version... 2.2.21
configure: creating ./config.status
config.status: creating Makefile
$ make
/usr/sbin/apxs -c -I/System/Library/Frameworks/Python.framework/Versions/2.6/include/python2.6
-DENABLE_DTRACE -DMACOSX -DNDEBUG -DNDEBUG -DENABLE_DTRACE
-Wc,'-arch x86_64' -Wc,'-arch i386' mod_wsgi.c -Wl,-F/System/Library/Frameworks -framework Python
-u _PyMac_Error /System/Library/Frameworks/ -arch x86_64 -arch i386 -ldl -framework CoreFoundation
/usr/share/apr-1/build-1/libtool --silent --mode=compile gcc -DDARWIN
-DSIGPROCMASK_SETS_THREAD_MASK -I/usr/local/include -I/usr/include/apache2
-I/usr/include/apr-1 -I/usr/include/apr-1 -arch x86_64 -arch i386
-I/System/Library/Frameworks/Python.framework/Versions/2.6/include/python2.6
-DENABLE_DTRACE -DMACOSX -DNDEBUG -DNDEBUG -DENABLE_DTRACE -c -o mod_wsgi.lo mod_wsgi.c && touch mod_wsgi.slo
/usr/share/apr-1/build-1/libtool --silent --mode=link gcc -o mod_wsgi.la -rpath /usr/libexec/apache2
-module -avoid-version mod_wsgi.lo -Wl,-F/System/Library/Frameworks -framework Python
-u _PyMac_Error /System/Library/Frameworks/ -arch x86_64 -arch i386 -ldl -framework CoreFoundation
warning: no debug symbols in executable (-arch x86_64)
warning: no debug symbols in executable (-arch i386)
As we can check with otool it was built against Python 2.7:
$ otool -L .libs/mod_wsgi.so
.libs/mod_wsgi.so:
/System/Library/Frameworks/Python.framework/Versions/2.7/Python (compatibility version 2.7.0, current version 2.7.1)
/usr/lib/libSystem.B.dylib (compatibility version 1.0.0, current version 159.1.0)
/System/Library/Frameworks/CoreFoundation.framework/Versions/A/CoreFoundation
(compatibility version 150.0.0, current version 635.19.0)
To build it for Python 2.6 you have to pass also the command --disable-framework.
$ ./configure --with-python=/usr/bin/python2.6 --disable-framework
checking for apxs2... no
checking for apxs... /usr/sbin/apxs
checking Apache version... 2.2.21
configure: creating ./config.status
config.status: creating Makefile
$ make
/usr/sbin/apxs -c -I/System/Library/Frameworks/Python.framework/Versions/2.6/include/python2.6
-DENABLE_DTRACE -DMACOSX -DNDEBUG -DNDEBUG -DENABLE_DTRACE -Wc,'-arch x86_64' -Wc,'-arch i386' mod_wsgi.c
-L/System/Library/Frameworks/Python.framework/Versions/2.6/lib
-L/System/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/config
-arch x86_64 -arch i386 -lpython2.6 -ldl -framework CoreFoundation
/usr/share/apr-1/build-1/libtool --silent --mode=compile gcc -DDARWIN -DSIGPROCMASK_SETS_THREAD_MASK
-I/usr/local/include -I/usr/include/apache2 -I/usr/include/apr-1 -I/usr/include/apr-1 -arch x86_64
-arch i386 -I/System/Library/Frameworks/Python.framework/Versions/2.6/include/python2.6
-DENABLE_DTRACE -DMACOSX -DNDEBUG -DNDEBUG -DENABLE_DTRACE -c -o mod_wsgi.lo
mod_wsgi.c && touch mod_wsgi.slo
/usr/share/apr-1/build-1/libtool --silent --mode=link gcc -o mod_wsgi.la -rpath /usr/libexec/apache2
-module -avoid-version mod_wsgi.lo -L/System/Library/Frameworks/Python.framework/Versions/2.6/lib
-L/System/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/config -arch x86_64
-arch i386 -lpython2.6 -ldl -framework CoreFoundation
warning: no debug symbols in executable (-arch x86_64)
warning: no debug symbols in executable (-arch i386)
Now it's compiled for Python 2.6:
$ otool -L .libs/mod_wsgi.so
.libs/mod_wsgi.so:
/System/Library/Frameworks/Python.framework/Versions/2.6/Python (compatibility version 2.6.0, current version 2.6.7)
/usr/lib/libSystem.B.dylib (compatibility version 1.0.0, current version 159.1.0)
/System/Library/Frameworks/CoreFoundation.framework/Versions/A/CoreFoundation
(compatibility version 150.0.0, current version 635.19.0)
