buildout - using different python version

2024/10/7 14:28:43

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..

Answer

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
https://en.xdnf.cn/q/70232.html

Related Q&A

Receive an error from lingnutls/Hogweed when importing CV2

Ive never seen an error like this and dont know where to start. I installed opencv with conda install opencvand am running Ubuntu Linux 18.04 using a conda environment named fpn. How should I even appr…

Understanding django admin readonly_fields

I created some code to differentiate between two usergroups in Django admin, resulting in showing all fields readonly or only some of them, which are set directly in the ModelAdmin class.At first here …

The seaborn styles shipped by Matplotlib are deprecated since 3.6

The seaborn styles shipped by Matplotlib are deprecated since 3.6, as they no longer correspond to the styles shipped by seaborn. However, they will remain available as seaborn-v0_8-<style>. Alte…

Python: Can the pydoc module output HTML docs with relative paths?

I am using the pydoc module to output documentation for some types which I have defined with the C API. The types I want to document dont exist until the interpreter has been embedded inside my C progr…

How to generate coverage report for http based integration tests?

I am writing integration tests for a project in which I am making HTTP calls and testing whether they were successful or not.Since I am not importing any module and not calling functions directly cover…

Does Webdriver support pagefactory for Python?

I was reading about page objects and design patterns on the Webdriver project site and came across pagefactory. It doesnt look like the Webdriver for Python API includes pagefactory. Is this true?

Truncated versus floored division in Python

To establish context, Im talking about integer arithmetic only, on large integers so going via floating point isnt an option, and using negative numbers so the difference between floored and truncated …

when restoring from a checkpoint, how can I change the data type of the parameters?

I have a pre-trained Tensorflow checkpoint, where the parameters are all of float32 data type.How can I load checkpoint parameters as float16? Or is there a way to modify data types of a checkpoint?F…

Opencv Python open dng format

I cant figure out how to open a dng file in opencv. The file was created when using the pro options of the Samsung Galaxy S7. The images that are created when using those options are a dng file as well…

VSCode: Set environment variables via script

I have a shell script env.sh containing statements like export ENV_VAR1 = 1. On Linux terminal, I can use . env.sh or source env.sh to set the environment variables. How to set the environment variable…