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/

Monday, January 14, 2008

Magsafe Connector Disassembly

The chord nearest the Magsafe plug on a modern Apple laptop is under a good deal of mechanical stress, and mine finally gave out; the outer layer of wire looked like loose steel wool. So I decided to take the plug apart:






Notice that black bit on the PCB in the left-hand image? That's a chip, identified by the following text:

A3
2100
613A1

It most likely controls the switch between the orange "charging" LED indicator and the green "powered" LED. However, I wonder if this chip doesn't hold the answer to another mystery: why won't the Macbook battery charge off the Magsafe airline adapter?

For further information on the subject, I'd suggest Stuart Schmitt's guide to hacking the MagSafe cable for use w/ a standard DC transformer.

Tuesday, January 8, 2008

mod_python under Leopard

OS upgrades break my workaround for compiling mod_python under OSX.

This is a good guide for fixing mod_python under Leopard, but with a caveat: if you've upgraded your system from Tiger, the "missing symbol" problem might persist. Run otool -L /usr/libexec/apache2/mod_python.so -- if you see a reference to /Library/Frameworks/Python.framework/Versions/2.4/, that's your problem. I simply renamed /Library/Frameworks/Python.framework to /Library/Frameworks/_Python.framework and rebuilt.

Update: I take it all back; mod_python essentially doesn't work under Leopard, at least on a 64-bit capable system. See my Jan 21 post for more information.