Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

pip install from git repo branch

Tags:

git

python

pip

Trying to pip install a repo's specific branch. Google tells me to

pip install https://github.com/user/repo.git@branch 

The branch's name is issue/34/oscar-0.6 so I did pip install https://github.com/tangentlabs/django-oscar-paypal.git@/issue/34/oscar-0.6 but its returning a 404.

How do I install this branch?

like image 419
goh Avatar asked Nov 20 '13 16:11

goh


People also ask

Can you pip install from a github repo?

Pip is a package manager of python. You can download Python libraries from some Python repositories like PyPI . You can also download libraries from a git repository.


2 Answers

Prepend the url prefix git+ (See VCS Support):

pip install git+https://github.com/tangentlabs/django-oscar-paypal.git@issue/34/oscar-0.6 

And specify the branch name without the leading /.

like image 128
falsetru Avatar answered Sep 30 '22 10:09

falsetru


Using pip with git+ to clone a repository can be extremely slow (test with https://github.com/django/django@stable/1.6.x for example, it will take a few minutes). The fastest thing I've found, which works with GitHub and BitBucket, is:

pip install https://github.com/user/repository/archive/branch.zip 

which becomes for Django master:

pip install https://github.com/django/django/archive/master.zip 

for Django stable/1.7.x:

pip install https://github.com/django/django/archive/stable/1.7.x.zip 

With BitBucket it's about the same predictable pattern:

pip install https://bitbucket.org/izi/django-admin-tools/get/default.zip 

Here, the master branch is generally named default. This will make your requirements.txt installing much faster.

Some other answers mention variations required when placing the package to be installed into your requirements.txt. Note that with this archive syntax, the leading -e and trailing #egg=blah-blah are not required, and you can just simply paste the URL, so your requirements.txt looks like:

https://github.com/user/repository/archive/branch.zip 
like image 29
Steve K Avatar answered Sep 30 '22 10:09

Steve K