使用 tox 的虚拟环境 PYTHONPATH
virtual env PYTHONPATH using tox
我有一个 tox.ini 文件
[testenv:py27]
deps= -r{toxinidir}/requirements.txt
setenv =
PYTHONPATH = {toxinidir}{:}{toxinidir}/helpers
我 运行 命令 tox
并且在 .tox/py27
中创建了 virtualenv
当我激活py27环境时
cd .tox/py7/bin
source activate
py27 $ echo $PYTHONPATH < gives null>
PYTHONPATH
是空的,尽管 tox.ini 有 setenv
并且 PYTHONPATH
显式设置
为什么 PYTHONPATH 将自身设置为空?
您是否希望 tox 像 here 中描述的那样修改 activate
脚本?
If you want to change the PYTHONPATH
used in a virtualenv, you can add the following line to your virtualenv's bin/activate
file:
export PYTHONPATH="/the/path/you/want"
This way, the new PYTHONPATH
will be set each time you use this virtualenv.
如果是:tox 不会做那样的事情 - 它会创建一个 vanilla virtualenv(如果安装了 tox-venv,则创建 venv)。
因此,setenv
中定义的内容只会在您 运行 有毒环境(参见 code)时发生。
我有一个 tox.ini 文件
[testenv:py27]
deps= -r{toxinidir}/requirements.txt
setenv =
PYTHONPATH = {toxinidir}{:}{toxinidir}/helpers
我 运行 命令 tox
并且在 .tox/py27
当我激活py27环境时
cd .tox/py7/bin
source activate
py27 $ echo $PYTHONPATH < gives null>
PYTHONPATH
是空的,尽管 tox.ini 有 setenv
并且 PYTHONPATH
显式设置
为什么 PYTHONPATH 将自身设置为空?
您是否希望 tox 像 here 中描述的那样修改 activate
脚本?
If you want to change the
PYTHONPATH
used in a virtualenv, you can add the following line to your virtualenv'sbin/activate
file:export PYTHONPATH="/the/path/you/want"
This way, the new
PYTHONPATH
will be set each time you use this virtualenv.
如果是:tox 不会做那样的事情 - 它会创建一个 vanilla virtualenv(如果安装了 tox-venv,则创建 venv)。
因此,setenv
中定义的内容只会在您 运行 有毒环境(参见 code)时发生。