开发者

zc.buildout is using the wrong python

开发者 https://www.devze.com 2023-04-09 08:34 出处:网络
I\'m using zc.buildout to generate a script called \"test\".I\'m using that script to call my own test runner.(The available test runners for buildout do not yet use the new \"discovery\" feature in P

I'm using zc.buildout to generate a script called "test". I'm using that script to call my own test runner. (The available test runners for buildout do not yet use the new "discovery" feature in Python 2.7.)

Anyhow, here's the relevant section in my .cfg file:

[test]
recipe = buildout_script
template = runtests.sh.in
target = test

Here is what my runtests.sh.in template looks like

#!/bin/bash

python %(directory)s/src/runtests.py

And here is the resulting output that is placed in my bin folder as bin/test.

!/bin/bash

python /Users/myname/projects/myproject/trunk/www/src/desktop/src/runtes开发者_如何学编程ts.py

When I execute this script, it's using the system Python instead of the Python in my bin folder.

The relevant section for that in my .cfg file is:

[python]
recipe = zc.recipe.egg
interpreter = python
eggs = ${buildout:eggs}

How do I get my script to use bin/python instead of the system python?


In your bash script, your are relying upon $PATH to determine which python to use. To change which python is invoked, you have several choices:

  1. Modify your environment to prefer a different version, i.e. in ~/.bashrc, add export PATH=/path/to/desired/python/bin:$PATH (of course with the appropriate substitutions

  2. Modify your bash script to explicitly state the path to python, thus avoiding using $PATH at all.

  3. Remove the explicit invocation of python, and change the sha-bang in the python script to select the appropriate version. (also, make sure the python script is marked executable).


You need to substitute the value of ${buildout:executable} into the template. I'm not sure how you refer to that using the buildout_script recipe, perhaps %(executable)s?

0

精彩评论

暂无评论...
验证码 换一张
取 消