You can use the pip install protocol+location[@tag][#egg=Dependency]
format to install directly from source using pip.
Git
pip install git+https://github.com/username/repo.git
pip install git+https://github.com/username/repo.git@MyTag
pip install git+https://github.com/username/repo.git@MyTag#egg=ProjectName
Mercurial
pip install hg+https://hg.myproject.org/MyProject/
SVN
pip install svn+svn://svn.myproject.org/svn/MyProject
Bzr
pip install bzr+http://bzr.myproject.org/MyProject/trunk
The following protocols are supported: [+git, +svn, +hg, +bzr]
Versions
@tag
lets you specify a specific version/tag to check out.
#egg=name
lets you specify what the project is as a dependency for others.
The order must always be @tag#egg=name
.
Private Repositories
You can also install from private repositories by changing the protocol to SSH (ssh://
) and adding an appropriate user (git@
):
git+ssh://git@github.com/username/my_private_repo
You can also install from private repositories with a username / password.
git+https://<username>:<password>@github.com/<user>/<repo>.git
Github provides the ability to create personal OAuth tokens which can be cycled
git+https://<oauth token>:x-oauth-basic@github.com/<user>/<repo>.git
requirements.txt
requirements.txt
is used to specify project dependencies:
requirements.txt
package1
package2==1.0.2
package3>=0.0.4
git+https://github.com/username/repo.git
These are not installed automatically with the package and must be installed with the command pip -r requirements.txt
.
Including requirements files
Requirements files can include other requirements files:
requirements-docs.txt
sphinx
-r requirements-dev.txt
requirements-dev.txt
some-dev-tool
-r requirements.txt
requirements.txt
package1
package2==1.0.2
package3>=0.0.4
git+https://github.com/username/repo.git
setup.py
Requirements files can install dependencies specified in setup.py
with the following command:
-e .
setup.py
can also install from repositories using the same syntax as above, but using the dependency_links
value as mentioned in this answer.
References:
https://pip.pypa.io/en/latest/user_guide.html#installing-packages
https://pip.pypa.io/en/latest/reference/pip_install.html