Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do I force pip to install from the last commit of a branch in a repo?

Tags:

python

pip

I want pip to install from the latest commit on a master branch of my github repository. I tried many options mentioned here on StackOverflow, none helped. For instance, that does not work:

pip install --upgrade --force-reinstall pathToGithubRepo
like image 408
skov Avatar asked Nov 24 '17 20:11

skov


1 Answers

Using numpy's repository as an example.

If you know the hash of the commit you are interested in, you can use the following command:

$ pip install -e git+https://github.com/numpy/numpy.git@75b2d5d427afdb1392f2a0b2092e0767e4bab53d#egg=numpy

where 75b2d5d427afdb1392f2a0b2092e0767e4bab53d is the latest commit for the numpy repository, and numpy is the project name used by egg for pip to figure out dependencies.


If you want to also automatically get the latest commit hash, you can use the command:

$ git ls-remote  [email protected]:numpy/numpy.git | head -1 | awk '{print $1;}'
75b2d5d427afdb1392f2a0b2092e0767e4bab53d

Unix wasn't invented for nothing, let's combine it into one big command:

$ pip install -e git+https://github.com/numpy/numpy.git@$(git ls-remote  [email protected]:numpy/numpy.git | head -1 | awk '{print $1;}')#egg=numpy

Replace numpy with your repository url and project name, and you're set.

like image 191
vasia Avatar answered Oct 11 '22 13:10

vasia