Roméo Després
Roméo Després

Reputation: 2163

pip install latest release from GitHub

I know I can install the master branch with:

pip install git+https://github.com/USER/REPO

I also know I can install a specific release with:

pip install git+https://github.com/USER/REPO@RELEASE

But is there a way to install the latest release (the one GitHub returns at https://github.com/USER/REPO/releases/latest)? I've tried the following:

pip install git+https://github.com/USER/REPO@latest

but it fails:

ERROR: Command errored out with exit status 1: git checkout -q latest

EDIT: This question is not a duplicate of Pip doesn't install latest GitHub release. The latter is about how to install a specific release and/or from the master branch, but not from the latest release.

Upvotes: 9

Views: 6842

Answers (2)

Alex
Alex

Reputation: 7045

This might be a bad idea, but you can grab the latest tarball url from GitHub's rest API:

pip install \
 $(python3 -c "import urllib.request, json, sys; \
 u=json.loads(urllib.request.urlopen('https://api.github.com/repos/USER/REPO/releases/latest').read().decode()).get('tarball_url', False);\
 print(u) if u else sys.exit(1);")

Which you drop into pip install using command substitution $(..)

There should be a couple of options available, either tarball_url and zipball_url and pip should be able to download these.

Upvotes: 1

Saska Karsi
Saska Karsi

Reputation: 21

You can use the github API. Something like

pip install "git+https://github.com/USER/REPO@$(curl -s https://api.github.com/repos/USER/REPO/releases/latest | jq -r ".tag_name")"

would probably work for you. If you don't feel like installing jq, there's e.g. this gist.

Upvotes: 2

Related Questions