tox如何通过需求文件安装模块?

2024-04-19 07:51:12 发布

您现在位置:Python中文网/ 问答频道 /正文

我们的python项目有一个requirements.txt文件,其中列出了一些依赖模块。我们曾经用

pip install -r requirements.txt

安装这些依赖项。我们现在用毒物来建立测试环境。我的问题是如何通过requirements.txt直接安装模块。

以下是我们的tox.ini和requirements.txt:

毒性指数:

[tox]
envlist=py27
[testenv]
deps=pytest
     boto
commands=py.test

rquirements.txt文件:

boto

是不是可以从tox.ini中删除“boto”并添加如下内容

deps_files=requirements.txt

Tags: 模块installpip文件项目depstxttox
3条回答
 deps = -r{toxinidir}/tools/pip-requires
        -r{toxinidir}/tools/test-requires

我已经按照上面接受的答案设置了依赖项,但是没有像第一次运行tox时那样安装任何新的依赖项。要在virtualenv中安装新的依赖项,我必须强制tox重新创建环境,如下所示:

tox --recreate -e py27

帮助我的是以下几点(另一个解决方案对我不起作用):

deps=
    pytest
    -rrequirements.txt

如果将requirements.txt添加到MANIFEST.in中,并且使用相对较新的“tox(>;=1.6.1)版本(see here),则此方法至少有效。

相关问题 更多 >