Monday, January 21, 2008

mod_python, Leopard, and the trouble w/ 64 bits

mod_python is broken under Leopard, at least on 64-bit capable systems.

Actually, this is only half true. Leopard ships w/ Apache 2, but more importantly, it ships w/ a 64-bit capable Apache 2. Because it's the 64-bit version that runs on capable systems, any modules linked by Apache need to be 64-bit capable.

Apache is 64-bit capable:

kieran@bali:~$ file /usr/sbin/httpd
/usr/sbin/httpd: Mach-O universal binary with 4 architectures
/usr/sbin/httpd (for architecture ppc7400): Mach-O executable ppc
/usr/sbin/httpd (for architecture ppc64): Mach-O 64-bit executable ppc64
/usr/sbin/httpd (for architecture i386): Mach-O executable i386
/usr/sbin/httpd (for architecture x86_64): Mach-O 64-bit executable x86_64

And mod_python, built by simply running ./configure and make, is 64-bit:

kieran@bali:~$ file /usr/libexec/apache2/mod_python.so
/usr/libexec/apache2/mod_python.so: Mach-O 64-bit bundle x86_64

So that much works. And basic mod_python functionality is intact. The problem comes when you try to compile python libraries that depend upon native C/C++ code. Neither command line options nor the CFLAGS environmental variable can force python distutils to build 64-bit friendly libraries.

I haven't figured out how to force distutils to cooperate yet, but in the meantime, rebuilding the entire software stack in fink creates a usable environment.

The first step is to simply ask for mod_python:

  1. stop apache: sudo service org.apache.httpd stop

  2. install the necessary packages: fink install libapache2-mod-python-py24

  3. accept the lengthy list of dependencies


Installing the PHP module wasn't so easy; I wound up building it by hand. First, make sure the Postgres include files are installed, assuming you need Postgres:

fink install postgresql82-dev

./configure --with-apxs2=/sw/bin/apxs2 --without-iconv --with-mysql=/sw/ --with-pgsql=/sw/

1 comment:

Euan said...

I was interested to read your post saying that building mod_python gives the 64-bit architecture. I am having loads of problems getting mine not to build to i386. I have a 64-bit iMac running leopard and whatever compiler flags I add seem to still build to the 32-bit mod_python. Is there any chance you could email me your mod_python.so binary as I'm out of idea? Thanks