pythonversionbuildout

buildout - using different python version


i have set up buildout project (django to be specific) that has to run in old machine, it works fine in my local system with python 2.7.

In production server it runs python 2.5 and i want to configure buildout that it would download and use 2.6, but only this project not system wide.

So i assume it should use some sort of recipe, but witch and how? I cannot find one. I hope to achieve it only using buildout.cfg file..


Solution

  • Buildout specifically supports this scenario. Each part in a buildout can use it's own python interpreter, or you can set one python interpreter globally for all parts. This defaults to the python used to run buildout.

    To set the python interpreter used, set the python option to the name of a part that contains an executable option. This can be a part that builds a whole new python interpreter. Here is an example:

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

    Any other parts in this buildout now will use the python 2.6 executable.

    You may want to symlink the python script into the buildout bin/ directory as well; the following part would do that for you:

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