简体   繁体   中英

Installing selected packages from requirements.txt

I have a requirements.txt file on my development machine. I have pushed it into a git repo and cloned it on a server.

The way I push changes to the server is as follows:

I freeze the file on my development machine, then I add the file to git and pull it on the server and do pip install -r requirements.txt.

But doing this is installing all the packages again and again and I dont want that. I only want those packages to be installed which are not installed on the server.

Whats the best way of doing this? I would also like to know other efficient methods of pushing development code to server.

Use buildout , this is other method. Buildout checks for packages before installing, so it will not reinstall unneeded packages.

It is very powerfull tool. When you deploy, you just need to make git push , then on the production server you do:

git pull
bin/buildout

That's it. You can read an article about Buildout and pip+virtualenv differences

EDIT:


You can set PIP_DOWNLOAD_CACHE path in settings.py to tell pip store all downloaded packages in some directory(' packages ' for example), so it won't download them again:

import os.path

PROJECT_ROOT = os.path.normpath(os.path.dirname(__file__))
PIP_DOWNLOAD_CACHE = os.path.abspath(PROJECT_ROOT+'/packages/'),

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