<p>I recently had to work on a project that needed Python 2.4. "Not a problem", I thought, "I'll just compile a Python and be on my way". However the bz2 module wasn't available. Strange, since the libbz2-dev package was definitely installed. Eventually 2 things dawned on me:</p>
<ul>
<li>The hazy memory of me sitting, beer in hand, deciding "Yeah, I'll go multiarch, it'll all work fine I'm sure"</li>
<li>That modifying LDFLAGS isn't enough, there's all sorts of magic going on in setup.py.</li>
</ul>
<p>setup.py basically looks in hardcoded paths for libraries, and because I'd gone multiarch the library was now in <code>/lib/x86_64-linux-gnu/libbz2.so.1</code>. By the time mutiarch came about, <a class="external-link" href="http://bugs.python.org/issue11715" target="_self" title="">python 2.4 was too old for people to want to patch it</a>.</p>
<p>However, given cmmi lets you patch files before you build, I took <a class="external-link" href="http://stackoverflow.com/questions/5726289/buildout-using-different-python-version" target="_self" title="">Martijn Pieters' example off stackoverflow</a> and came up with:</p>
<pre>[buildout]<br />python = python<br />parts +=<br /> python<br /> pythonbin<br /><br />[python]<br />recipe = zc.recipe.cmmi<br />url = http://www.python.org/ftp/python/2.4.6/Python-2.4.6.tgz<br />executable = ${buildout:directory}/parts/python/bin/python2.4<br />patch = http://files.shuttlethread.com/patches/python2.4-addmultiarch.patch<br />patch_options = -p1<br />extra_options=<br /> --enable-unicode<br /> --with-threads<br /> --with-readline<br /><br />[pythonbin]<br />recipe = plone.recipe.command<br />command = ln -s ${python:executable} ${buildout:bin-directory}/python</pre>
<p>Don't look too closely at the patch in question though. It's a bit ugly, and I couldn't be bothered to tidy it. You get a working Python though, which is the main thing.</p>
Image may be NSFW.
Clik here to view.
Clik here to view.
