Build Python in Buildout

erstellt von Jens W. Klein — 17.07.2008 19:10

zc.buildout to build a custom python.

Python-LogoSystems Python is sometimes polluted with different packages from somewhere. This happens and deleting packages conflicting with the specific Buildout is not the clean solution.

Having a clean Python helps a lot. It can be shared between buildouts. Python is easy to build anyway, but using Buildout for this task its again easier and more predictable and reduces the affinity for mistakes. Here is my buildout.cfg for this task.

[buildout]
python = python
parts =
    python
    pythonbin

[python]
recipe = zc.recipe.cmmi
url = http://www.python.org/ftp/python/2.4.5/Python-2.4.5.tgz
executable = ${buildout:directory}/parts/python/bin/python2.4
extra_options=
    --enable-unicode=ucs4
    --with-threads
    --with-readline

[pythonbin]
recipe = plone.recipe.command
command = ln -s ${python:executable} ${buildout:bin-directory}/python

If youre on OSX you want to add MACOSX_DEPLOYMENT_TARGET=10.5 to extra_options. The python is binary-compatible (pickles, ZODB) with Debian/Ubuntus (and most others) binary - it uses the same unicode flavor.

If youre on Debian/Ubuntu you want to do first:
sudo apt-get install libreadline5-dev zlib1g-dev libbz2-dev libssl-dev libjpeg62-dev

I think its also a good idea to use this style of python-build for the new plone.org deployment setup. [UPDATE: While testing this for new.plone.org I changed pythonbin to just symlink the binary; UPDATE2: Added some information for Debian/Ubuntu]

[UPDATE3] jetzt im collective https://svn.plone.org/svn/collective/buildout/bda-naked-python/

Artikelaktionen

Nice, but...

Kommentar von https://www.google.com/accounts/o8/id?id=AItOawnL5MNGGMJfC4F7_RCpL0SixusYVmYMwvY am 09:07
Very useful.

Do not forget that a Python built in this manner most of the time does not ship the bz2, zlib, ssl, dbm modules etc...
If the dependencies needed for those modules are not found, the modules are not built, and the recipe in a way "fails silently".

To check after Python build that those modules are around, you could add a plone.command checking the following:
    bin/python2.4 -c 'import _ssl'
    bin/python2.4 -c 'import bz2'
    bin/python2.4 -c 'import dbm'
    bin/python2.4 -c 'import zlib'
        # any other requirements here

It is particularly useful as Python versions prior to 2.4 do NOT provide configure options that allow to FAIL at configure time if the dependencies are not met. See http://bugs.gentoo.org/165268 for details on the issue. The attachment on this bug partially solves the issue, if you still haven't migrated to Python >= 2.5

We use hexagonit.recipe.cmmi to apply on the fly the attachment before building Python.

Cheers,

Addendum

Kommentar von https://www.google.com/accounts/o8/id?id=AItOawnL5MNGGMJfC4F7_RCpL0SixusYVmYMwvY am 09:09
Precision: Python2.4 has this issue, but Python2.5 and onwards have better build mechanisms. My comment should have read "Python versions prior to 2.5".