I work at Tangent Labs, a digital agency, writing applications in python and django. I spend most of my free time hacking. I run commandlinefu.com and am the author of the e-commerce framework django-oscar amongst other things. I used to be a mathematician; I have a PhD in Mathematics from the University of Nottingham and an associated interest in cryptic crosswords, chess and playing devil's advocate. David is a DZone MVB and is not an employee of DZone and has posted 25 posts at DZone. You can read more from them at their website. View Full User Profile

Using Pip and Requirements.txt to Install From the Head of Github Branch

  • submit to reddit

The python package installer pip can be used to install directly from Github, like so:

$ pip install git+git://github.com/tangentlabs/django-oscar.git#egg=django-oscar

This will install from the HEAD of the master branch. However, when you use pip freeze to export your dependencies (usually to a requirements.txt file), pip will fix the reference to a specific commit by including its ID within the URL:

$ pip freeze | grep oscar
-e git://github.com/tangentlabs/django-oscar.git@d636b803d98cd1d3edd01821d4fb2a01ce215ee4#egg=django_oscar-dev

Hence running pip install -r requirements.txt will not pick any commits after d636b803 until requirements.txt is updated.

This isn't always the desired behaviour; in some circumstances, you would prefer for pip install -r requirements.txt to always install the latest version from Github.


Simply delete the commit ID from URL - that is, change:

-e git://github.com/tangentlabs/django-oscar.git@d636b803d98cd1d3edd01821d4fb2a01ce215ee4#egg=django-oscar


-e git://github.com/tangentlabs/django-oscar.git#egg=django-oscar

This can be done by hand once you've used

pip freeze > requirements.txt

to create your requirements file, or by using sed:

$ pip freeze | sed 's/@[a-z0-9]\+//' > requirements.txt

The text between @ and # in the github URL specifies the commit to install from. Rather than a commit ID, a branch or tag name can be used also. Hence:

pip install -e git://github.com/tangentlabs/django-oscar.git@0.1#egg=django-oscar

will install the 0.1 tag, while:

pip install -e git://github.com/tangentlabs/django-oscar.git@releases/0.1#egg=django-oscar

will install from the HEAD of the releases/0.1 branch.


Published at DZone with permission of David Winterbottom, author and DZone MVB. (source)

(Note: Opinions expressed in this article and its replies are the opinions of their respective authors and not those of DZone, Inc.)