在pip中分割需求文件 [英] Split requirements files in pip

查看:123
本文介绍了在pip中分割需求文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

要创建Python虚拟环境,我使用virtualenv和pip.工作流程非常简单:

To create Python virtual environments I use virtualenv and pip. The workflow is very simple:

$ virtualenv project
$ cd project
$ . bin/activate
$ pip install -r /path/to/requirements/req1.txt
$ pip install -r /path/to/requirements/req2.txt

不同需求文件的数量可以增长到足以方便使用的方式,使其可以一次包含它们,所以我宁愿说:

The number of different requirement files can grow enough to make handy to have a way to include them at once, so I'd rather prefer to say:

$ pip install -r /path/to/requirements/req1_req2.txt

其中req1_req2.txt包含以下内容:

include /path/to/requirements/req1.txt
include /path/to/requirements/req2.txt

否则:

$ pip install -r /path/to/requirements/*.txt

这些都不起作用,而且不管它多么简单,我都不知道该怎么做.

None of that works and however much simple it could be, I can't figure out how to do what I want.

有什么建议吗?

推荐答案

-r标志不仅限于命令行使用,它还可以在需求文件中使用.因此,当req-1-and-2.txt包含以下内容时,运行pip install -r req-1-and-2.txt:

The -r flag isn't restricted to command-line use only, it can also be used inside requirements files. So running pip install -r req-1-and-2.txt when req-1-and-2.txt contains this:

-r req-1.txt
-r req-2.txt

将安装req-1.txt和req-2.txt中指定的所有内容.

will install everything specified in req-1.txt and req-2.txt.

这篇关于在pip中分割需求文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆