1

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.

H H H
  • 489
  • 1
  • 7
  • 20
  • I'm a little confused, because my impression (and experience) has always been that pip does this already. When I do `pip install -r requirements.txt`, for stuff that is already installed it simply prints `Requirement already satisfied` message and doesn't bother installing it again. – Ludwik Trammer Nov 14 '13 at 13:54
  • Thats not happening for me. Its installing all the packages again and then deactivating the same packages all and keeping one of them active. – H H H Nov 14 '13 at 13:58
  • Which version of pip do you use? – Ludwik Trammer Nov 14 '13 at 14:02
  • the version is 1.4.1. Any idea whats happening? – H H H Nov 14 '13 at 14:09
  • 1
    I run the same version on Ubuntu and CentOS and never had this problem. – Ludwik Trammer Nov 14 '13 at 14:11
  • I think you have an error while installing one of those packages, and in the end the whole operation considered to be failure because of that error. Check the pip install log, and correct the errors. – Csaba Toth Apr 14 '15 at 14:30

1 Answers1

1

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/'),
Feanor
  • 3,568
  • 5
  • 29
  • 49
  • Helpful information but Im really looking to use pip with this project and because Im still learning I dont want to experiment with the server at this time. Is there any command to tell pip to install selected packages from requirements.txt? – H H H Nov 14 '13 at 14:14
  • get look at http://stackoverflow.com/questions/10336308/how-to-cache-downloaded-pip-packages It seems similar to your problem. You need to cache downloaded packages to prevent pip from reinstalling them – Feanor Nov 14 '13 at 14:45