Half a Python (aka The Twist in Leopard's Python)


So, here I am trying to get Coherence to work on Leopard (given that Apple persists in ignoring DLNA and UPnP and doing their own thing), and failing because, out of some obscure selective package selection rules, Apple decided to ship only portions of Twisted Core version 2.4.0 rather than the whole enchilada.

For starters, twisted.web, which is pretty damn essential, is not there – and I’m not talking about “Twisted Web”, I’m talking about the portion of Twisted Core by the same name, which has been part of the distribution for, oh, well, several years now.

I am guessing that it’s due to the fact that Twisted is a fairly large and complex beast, but there are still several bits that I would expect to find there, and as such, I am officially revoking the praise I lavished upon Leopard’s Python revamp until I have assayed exactly what modules and versions are shipped with the OS – this sort of selective crippling of packages isn’t something I look kindly upon.

Fetch, kitty, fetch!

Trying to benefit from easy_install to deploy a complete version, however, didn’t pan out as expected:


$ sudo easy_install Twisted
Searching for Twisted
Reading http://pypi.python.org/simple/Twisted/
Reading Twisted
Reading http://www.twistedmatrix.com
Reading Twistedprojects/core/
Reading Twistedproducts/download
Best match: Twisted 2.5.0
Downloading http://tmrc.mit.edu/mirror/twisted/Twisted/2.5/Twisted-2.5.0.tar.bz2
Processing Twisted-2.5.0.tar.bz2
Running Twisted-2.5.0/setup.py -q bdist_egg —dist-dir /tmp/easy_install-NTkmPB/Twisted-2.5.0/egg-dist-tmp-jCSgm2
usage: setup.py [global_opts] cmd1 [cmd1_opts] [cmd2 [cmd2_opts] …] or: setup.py —help [cmd1 cmd2 …] or: setup.py —help-commands or: setup.py cmd —help

error: invalid command ‘bdist_egg’
Error: Subprocess exited with result 1 for project core
error: Setup script exited with 1

…which is weird, since I was under the impression that egg support was built in as well. I guess it’s not.

To Apple’s credit, the rather roundabout process of replicating their module selection on a fresh Ubuntu virtual machine yields the same result:


$ sudo apt-get install python-setuptools python-zope-interface
Reading package lists… Done

Setting up python-zopeinterface (3.3.1-0ubuntu3) …
$ sudo easy_install Twisted
Searching for Twisted
Reading http://cheeseshop.python.org/pypi/Twisted/
Reading Twisted
Reading http://cheeseshop.python.org/pypi/Twisted/2.5.0
Best match: Twisted 2.5.0
Downloading http://tmrc.mit.edu/mirror/twisted/Twisted/2.5/Twisted-2.5.0.tar.bz2
Processing Twisted-2.5.0.tar.bz2
Running Twisted-2.5.0/setup.py -q bdist_egg —dist-dir /tmp/easy_install-w7Lp64/Twisted-2.5.0/egg-dist-tmp-F3-A3-
usage: setup.py [global_opts] cmd1 [cmd1_opts] [cmd2 [cmd2_opts] …] or: setup.py —help [cmd1 cmd2 …] or: setup.py —help-commands or: setup.py cmd —help

error: invalid command ‘bdist_egg’
Error: Subprocess exited with result 1 for project core
error: Setup script exited with 1

After all, I wouldn’t want Mark Pilgrim to pull another stunt like his recent parody regarding mySQL installation in Ubuntu when compared to Dan Benjamin’s updated HOWTO for Leopard.

But all of the nastiness above is dealt with by typing apt-get install python-twisted on my Ubuntu machine, so I think that we may yet hear something from him regarding this as well.

Look yonder, you varmint!

Nevertheless, using your own Python packages under Leopard is still an uphill climb – getting the Twisted source archive, unpacking it and running sudo setup.py install by hand works, but I then have to set PYTHONPATH by hand to override the extant (and obsolete) version:

$ export PYTHONPATH=/Library/Python/2.5/site-packages

…and I really shouldn’t have to do this by now.

It’s just plain stupid, and could well have been avoided if all of Twisted Core had been included in Leopard in the first place.