DZone
Thanks for visiting DZone today,
Edit Profile
  • Manage Email Subscriptions
  • How to Post to DZone
  • Article Submission Guidelines
Sign Out View Profile
  • Post an Article
  • Manage My Drafts
Over 2 million developers have joined DZone.
Log In / Join
Refcards Trend Reports Events Over 2 million developers have joined DZone. Join Today! Thanks for visiting DZone today,
Edit Profile Manage Email Subscriptions Moderation Admin Console How to Post to DZone Article Submission Guidelines
View Profile
Sign Out
Refcards
Trend Reports
Events
Zones
Culture and Methodologies Agile Career Development Methodologies Team Management
Data Engineering AI/ML Big Data Data Databases IoT
Software Design and Architecture Cloud Architecture Containers Integration Microservices Performance Security
Coding Frameworks Java JavaScript Languages Tools
Testing, Deployment, and Maintenance Deployment DevOps and CI/CD Maintenance Monitoring and Observability Testing, Tools, and Frameworks
Partner Zones AWS Cloud
by AWS Developer Relations
Culture and Methodologies
Agile Career Development Methodologies Team Management
Data Engineering
AI/ML Big Data Data Databases IoT
Software Design and Architecture
Cloud Architecture Containers Integration Microservices Performance Security
Coding
Frameworks Java JavaScript Languages Tools
Testing, Deployment, and Maintenance
Deployment DevOps and CI/CD Maintenance Monitoring and Observability Testing, Tools, and Frameworks
Partner Zones
AWS Cloud
by AWS Developer Relations
  1. DZone
  2. Testing, Deployment, and Maintenance
  3. Deployment
  4. Using Pip and Requirements.txt to Install From the Head of Github Branch

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

David Winterbottom user avatar by
David Winterbottom
·
May. 10, 12 · Interview
Like (0)
Save
Tweet
Share
10.01K Views

Join the DZone community and get the full member experience.

Join For Free

Problem

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.

Solution

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

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

to

-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

Discussion

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.

 

GitHub Branch (computer science)

Published at DZone with permission of David Winterbottom, DZone MVB. See the original article here.

Opinions expressed by DZone contributors are their own.

Popular on DZone

  • Required Knowledge To Pass AWS Certified Solutions Architect — Professional Exam
  • A First Look at Neon
  • What To Know Before Implementing IIoT
  • Top 5 Data Streaming Trends for 2023

Comments

Partner Resources

X

ABOUT US

  • About DZone
  • Send feedback
  • Careers
  • Sitemap

ADVERTISE

  • Advertise with DZone

CONTRIBUTE ON DZONE

  • Article Submission Guidelines
  • Become a Contributor
  • Visit the Writers' Zone

LEGAL

  • Terms of Service
  • Privacy Policy

CONTACT US

  • 600 Park Offices Drive
  • Suite 300
  • Durham, NC 27709
  • support@dzone.com
  • +1 (919) 678-0300

Let's be friends: