pip: how to install a git pull request

I want to install a git pull request with pip for testing in my local virtualenv. I want to install it directly from github, without creating a local git repository.

Answers:

Thank you for visiting the Q&A section on Magenaut. Please note that all the answers may not help you solve the issue immediately. So please treat them as advisements. If you found the post helpful (or not), leave a comment & I’ll get back to you as soon as possible.

Method 1

A neat feature that github gives you is that it preemptively merges pull requests and makes them available as a hidden ref you can fetch specially. This is great if you’re building a CI system to test pull requests.

Up until recently, pip didn’t support specifying these hidden refs, but in the last month, support has landed in pip (confirmed working in 10.0.1) for this.

The following command will install the merged version of pull request 123 for user/repo:

pip install git+https://github.com/user/<a href="https://getridbug.com/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="d2a0b7a2bdfcb5bba692a0b7b4a1">[email protected]</a>/pull/123/merge

Additionally, to install the unmerged version of pull request 123 (without messing with the github API to track down the original branch!):

pip install git+https://github.com/user/<a href="https://getridbug.com/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="572532273879303e231725323124">[email protected]</a>/pull/123/head

Method 2

You can add the exact commit to the URL by appending the hash:

pip install git+https://github.com/other-repository/<a href="https://getridbug.com/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="aededcc1c4cbcdda80c9c7daeedccbc3c1dacb">[email protected]</a>_branch_name

example:

pip install --user git+https://github.com/d1b/<a href="https://getridbug.com/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="6b1b021b450c021f2b0d0213">[email protected]</a>_pip_build_directory

Or to a single commit. But this does not get updated, if the pull request (remote branch) gets updated:

pip install --user git+https://github.com/d1b/<a href="https://getridbug.com/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="710118015f1618053115494813444941421513431344434114464445134813434713464640154343404340464249474246">[email protected]</a>


All methods was sourced from stackoverflow.com or stackexchange.com, is licensed under cc by-sa 2.5, cc by-sa 3.0 and cc by-sa 4.0

0 0 votes
Article Rating
Subscribe
Notify of
guest

0 Comments
Oldest
Newest Most Voted
Inline Feedbacks
View all comments
0
Would love your thoughts, please comment.x
()
x