Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

pip: how to install a git pull request

Tags:

python

pip

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.

like image 327
guettli Avatar asked Nov 26 '12 09:11

guettli


People also ask

Can I install Git through pip?

You can use pip to install directly from a git repository. To install flask the shortest version of the command is pip install git+https://github.com/pallets/flask.git .

How do I enable a pull request?

To accept the pull request, click the Pull Requests tab to see a summary of pending pull requests. If you are happy with the changes, click Merge Pull request to accept the pull request and perform the merge. You can add in a comment if you want. Once you click Merge Pull request, you will see a button Confirm merge.


2 Answers

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/repo.git@refs/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/repo.git@refs/pull/123/head 
like image 36
Audrey Dutcher Avatar answered Sep 19 '22 13:09

Audrey Dutcher


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

pip install git+https://github.com/other-repository/project.git@remote_branch_name 

example:

pip install --user git+https://github.com/d1b/pip.git@fix_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/pip.git@d89b5803db2b520e754b9b26b771d22121738637 
like image 139
guettli Avatar answered Sep 19 '22 13:09

guettli