简体   繁体   English

Requirements.txt中的点子分组

[英]pip group packages in requirements.txt

On local machive(development) and production server i have some changes in requirements.txt. 在本地machive(开发)和生产服务器上,我对requirements.txt进行了一些更改。

For example i want to ignore the psycopg2 for development, but use it for production. 例如,我想忽略psycopg2进行开发,而将其用于生产。

I use pip freeze > requirements.txt, then manually add the needed one and then push it to server. 我使用pip Frozen> requirements.txt,然后手动添加所需的,然后将其推送到服务器。 Is there a way to do this like in gem bundle install? 有没有办法像在gem bundle install中那样? I mean like 我的意思是

bundle install --without production

or something like that for pip to don't do this every time manually. 或类似的操作,使pip不必每次都手动执行此操作。

You could have two separated pip files, dev_req.txt and prod_req.txt 您可能有两个单独的pip文件dev_req.txt和prod_req.txt

In the prod_req.txt you can add '-r dev_req.txt' and when you install production requirements it will also install the dev requirements but when installing the dev requirements it wont install the production ones. 在prod_req.txt中,您可以添加“ -r dev_req.txt”,当您安装生产需求时,它也会安装开发需求,但是在安装开发需求时,它不会安装生产需求。

With fabric http://www.fabfile.org/ you can make a task for deploying and can have two profiles (pre and prod) and then depending on the role you are deploying it choose one or other pip requirement file. 使用结构http://www.fabfile.org/可以执行部署任务,并且可以具有两个配置文件(pre和prod),然后根据要部署的角色选择一个或其他pip要求文件。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM