Skip to content

Instantly share code, notes, and snippets.

@avli
Last active July 8, 2018 10:13
Show Gist options
  • Save avli/7684c336f72cb143b26f3bc458ef1206 to your computer and use it in GitHub Desktop.
Save avli/7684c336f72cb143b26f3bc458ef1206 to your computer and use it in GitHub Desktop.

Python Pip Git Dependencies

To add a Git dependency:

pip install git+https://github.com/account/repo@tag#egg=package_name

or

pip install git+ssh://git@github.com/account/repo@tag#egg=package_name

git+https or git+ssh means: "This is a Git repositry, access to it using https or ssh protocol respectively". See pip install VSC Support.

Note that the part after git+ and before @ is the same as if you do git clone using the HTTPS protocol and almost the same for the SSH protocol. For example, you could do:

git clone https://github.com/account/repo

Note, however, that for the SSH protocol the git clone operation looks like this:

git clone git@github.com:account/repo

Compare it with the command that pip uses and see this subtle difference: with pip you have to split the account and repo name with the slash, not the colon.

Git tag can be replaced with a branch name or commit, e.g.

pip install git+ssh://git@github.com/account/repo@master#egg=package_name

The part after pip install can be added to requirements.txt.

If you want to switch to another tag, branch, or commit, use the --upgrade (or its short form -U) flag, e.g.

pip install --upgrade git+ssh://git@github.com/account/repo@new_tag#egg=package_name

The same works for requirements.txt:

pip install --upgrade -r requirements.txt

See also:

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment