Alastair’s Place

Software development, Cocoa, Objective-C, life. Stuff like that.

When Installing Twisted on OS X Server 10.5

When installing Twisted on OS X Server 10.5, take care!

Apple’s Wiki server is using Twisted Web2, which isn’t part of the Twisted distribution that you (or easy_install) will find on PyPi. If you just blindly install a newer Twisted, you’ll get this kind of thing in your server’s system.log:

com.apple.wikid[86011]: Traceback (most recent call last):
com.apple.wikid[86011]:   File "/Library/Python/2.5/site-packages/Twisted-8.1.0-py2.5-macosx-10.5-ppc.egg/twisted/application/app.py", line 609, in run
com.apple.wikid[86011]:     config.parseOptions()
com.apple.wikid[86011]:   File "/Library/Python/2.5/site-packages/Twisted-8.1.0-py2.5-macosx-10.5-ppc.egg/twisted/application/app.py", line 589, in parseOptions
com.apple.wikid[86011]:     usage.Options.parseOptions(self, options)
com.apple.wikid[86011]:   File "/Library/Python/2.5/site-packages/Twisted-8.1.0-py2.5-macosx-10.5-ppc.egg/twisted/python/usage.py", line 226, in parseOptions
com.apple.wikid[86011]:     for (cmd, short, parser, doc) in self.subCommands:
com.apple.wikid[86011]:   File "/Library/Python/2.5/site-packages/Twisted-8.1.0-py2.5-macosx-10.5-ppc.egg/twisted/application/app.py", line 599, in subCommands
com.apple.wikid[86011]:     for plug in plugins:
com.apple.wikid[86011]: ---  ---
com.apple.wikid[86011]:   File "/Library/Python/2.5/site-packages/Twisted-8.1.0-py2.5-macosx-10.5-ppc.egg/twisted/plugin.py", line 204, in getPlugins
com.apple.wikid[86011]:     adapted = interface(plugin, None)
com.apple.wikid[86011]:   File "/System/Library/Frameworks/Python.framework/Versions/2.5/Extras/lib/python/zope/interface/interface.py", line 635, in _call_conform
com.apple.wikid[86011]:     return conform(self)
com.apple.wikid[86011]:   File "/Library/Python/2.5/site-packages/Twisted-8.1.0-py2.5-macosx-10.5-ppc.egg/twisted/plugin.py", line 68, in __conform__
com.apple.wikid[86011]:     return self.load()
com.apple.wikid[86011]:   File "/Library/Python/2.5/site-packages/Twisted-8.1.0-py2.5-macosx-10.5-ppc.egg/twisted/plugin.py", line 63, in load
com.apple.wikid[86011]:     return namedAny(self.dropin.moduleName + '.' + self.name)
com.apple.wikid[86011]:   File "/Library/Python/2.5/site-packages/Twisted-8.1.0-py2.5-macosx-10.5-ppc.egg/twisted/python/reflect.py", line 426, in namedAny
com.apple.wikid[86011]:     topLevelPackage = _importAndCheckStack(trialname)
com.apple.wikid[86011]:   File "/usr/share/wikid/lib/python/twisted/plugins/wikid.py", line 9, in 
com.apple.wikid[86011]:     from apple_utilities.tap import WikiServiceMaker
com.apple.wikid[86011]:   File "/usr/share/wikid/lib/python/apple_utilities/tap.py", line 24, in 
com.apple.wikid[86011]:     from twisted.web2.log import LogWrapperResource
com.apple.wikid[86011]: exceptions.ImportError: No module named web2.log
</pre>
</blockquote>

Worse, you can’t just check-out the Twisted trunk to get a copy containing the twisted.web2 module, because Apple’s wikid also depends on twisted.web2.dav, which was removed from the trunk in [22866]/[22867] (see #3072 for why this happened).

It turns out (see #3081) that there is a plan to re-introduce web2.dav to the Twisted trunk, the work for which is going on in svn://svn.twistedmatrix.com/svn/Twisted/branches/dav-take-two-3081-3 (Browse in Trac), so you can do e.g.

$ svn co svn://svn.twistedmatrix.com/svn/Twisted/branches/dav-take-two-3081-3 Twisted
$ cd Twisted
$ python setup.py bdist_egg
$ cd dist
$ sudo easy_install Twisted*.egg
or similar to install a version that is compatible with the Apple Wiki server. I have reported this as rdar://6694255 in case anyone else wants to refer to the bug number in their own dealings with Apple.