简体   繁体   中英

pip group packages in requirements.txt

On local machive(development) and production server i have some changes in requirements.txt.

For example i want to ignore the psycopg2 for development, but use it for production.

I use pip freeze > requirements.txt, then manually add the needed one and then push it to server. Is there a way to do this like in gem bundle install? I mean like

bundle install --without production

or something like that for pip to don't do this every time manually.

You could have two separated pip files, dev_req.txt and 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.

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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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