Buildout - using a different version of python

I installed a build project (specific to django) that should work on the old machine, it works fine on my local system with python 2.7.

On a production server, it runs python 2.5, and I want to configure buildout, which will load and use 2.6, but only this project is not a system one.

So, I guess he should use some kind of recipe, but a witch and how? I can not find him. I hope to get it only with the help of buildout.cfg file.

+6
source share
3 answers

Buildout specifically supports this scenario. Each part of the assembly can use its own python interpreter, or you can install one python interpreter globally for all parts. By default, the python used to start the build is used.

To install the python interpreter used, set the python parameter to the name of the part that contains the executable parameter. This may be the part that creates a completely 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 assembly will now use the python 2.6 executable.

You can also bind a python script to the buildout bin/ directory; The next part will do it for you:

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

Whatever python you use, run the original bootstrap.py - the one that will be used for your entire project. All paths will reference this particular python, and sitepackages packages will be used for this particular python.

This is one of the best things about creating.

This is 32 bit python 2.6:

 /Library/Frameworks/Python.framework/Versions/2.6/bin/python2.6 boostrap.py 

This is 64-bit python 2.7:

 /System/Library/Frameworks/Python.framework/Versions/2.7/bin/python bootstrap.py 

Now take a look at the bin / it created.

Then make your actual bin / buildout -c dev.cfg file and look at the scripts in the trash. For my 32 bit example:

For the first one that I see in my django file:

 #!/Library/Frameworks/Python.framework/Versions/2.6/Resources/Python.app/Contents/MacOS/Python ... '/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/site-packages', 

The accepted answer says that you need to compile all python. This is not necessary and not recommended, although it will mean that you have completely isolated sites. But there are simpler ways to tell buildout not to include site packages.

The answer from esaelPsnoroMoN is actually correct, but he / she did not describe the solution very well. (I myself ignored him)

+2
source

Typically, each build project contains a bootstrap.py script that was originally launched using the Python interpreter that you need / need for this project. Running bootstrap.py will locally create / install the assembly and everything you need. Typical usage pattern:

 svn checkout <some_url_of_a_buildout_project> cd my_project /path/to/my/python bootstrap.py bin/buildout 
-2
source

Source: https://habr.com/ru/post/886293/


All Articles