When it comes to packages probably every Python developer thinks of pypi. This is the most common way of distribution them in the ecosystem.
But there are several cases where packages are in a progress or pre alpha state in which a package maintainer considers a release is too early. Or in other cases packages are only meant to be used internally. One solution is to install such packages is via git.
Please be aware that the strings used after pip install
can be used directly inside the requirements.txt
file.
Install via SSH
This is useful for projects located inside an internal git server or for projects that are not public and require ssh authentication.
pip install git+ssh://git@git.tld/<owner>/<project>
Example: pip install git+ssh://git@github.com/nezhar/django-model-prefix
Install via HTTPS
Probably the most common use case is testing new features in open source repositories and installing modules that are not released on pypi.
pip install git+https://git.tld/<owner>/<project>
Example: pip install git+https://github.com/nezhar/django-model-prefix
Installing a branch, tag or commit
The above commands will only install what is available in the default branch. In most of the cases you want to target a
specific branch, tag or maybe even a commit. This can be achieved by providing @
argument to the git string.
Example: pip install git+https://github.com/nezhar/django-model-prefix@a5cabf1ac210b6358ea358b1d268d802114d85d4
Providing options for extras_require
Some packages provide extras_require
inside setup.py
or setup.cfg
. In order to target them during the
installation process, the #egg
argument must be provided. As a value in contains the name of the package and the option for the extras_require
Example: pip install git+https://github.com/anexia-it/jsonschema@draft2020-12#egg=jsonschema[format]