7

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
skov
  • 121
  • 2
  • 4
  • Have you tried the solution in [this question](https://stackoverflow.com/questions/13685920/install-specific-git-commit-with-pip)? I think if you pip from a git branch it uses the last commit on that branch by default. – ConorSheehan1 Nov 24 '17 at 20:43

2 Answers2

7

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  git@github.com: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  git@github.com:numpy/numpy.git | head -1 | awk '{print $1;}')#egg=numpy

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

vasia
  • 1,093
  • 7
  • 18
0

You could use the flag --no-cache-dir to temporarily disable the cache and avoid installing from an already cached download, instead forcing a download of the most recent commit. (link to documentation)

This would look like

pip install --upgrade --no-cache-dir [path to package location]

Using the Chardet package as an example, this could look like:

pip install --upgrade --no-cache-dir https://github.com/chardet/chardet/archive/refs/heads/master.zip
n-l-i
  • 155
  • 6