0

我正在使用 zc.buildout 生成一个名为“test”的脚本。我正在使用该脚本来调用我自己的测试运行器。(用于构建的可用测试运行器尚未使用 Python 2.7 中的新“发现”功能。)

无论如何,这是我的 .cfg 文件中的相关部分:

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

这是我的 runtests.sh.in 模板的样子

#!/bin/bash

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

这是放置在我的 bin 文件夹中的结果输出bin/test

!/bin/bash

python /Users/myname/projects/myproject/trunk/www/src/desktop/src/runtests.py

当我执行这个脚本时,它使用的是系统 Python 而不是我 bin 文件夹中的 Python。

我的 .cfg 文件中的相关部分是:

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

如何让我的脚本使用 bin/python 而不是系统 python?

4

2 回答 2

0

在您的 bash 脚本中,您依赖于$PATH确定要​​使用的 python。要更改调用哪个 python,您有几个选择:

  1. 修改您的环境以更喜欢不同的版本,即在 ~/.bashrc 中,添加export PATH=/path/to/desired/python/bin:$PATH(当然有适当的替换

  2. 修改您的 bash 脚本以显式声明 python 的路径,从而$PATH完全避免使用。

  3. 去掉python的显式调用,修改python脚本中的sha-bang来选择合适的版本。(另外,确保 python 脚本被标记为可执行)。

于 2011-09-30T14:54:14.493 回答
0

您需要将 的值替换${buildout:executable}到模板中。我不确定您如何使用 buildout_script 配方来引用它,也许%(executable)s

于 2011-09-30T14:58:39.670 回答