snippetpythonCritical
How to state in requirements.txt a direct github source
Viewed 0 times
requirementsdirecthowsourcetxtgithubstate
Problem
I've installed a library using the command
which installs it directly from a Github repository. This works fine and I want to have that dependency in my
in the
The documentation of the requirements file does not mention links using the
Does anybody have a solution for my problem?
pip install git+git://github.com/mozilla/elasticutils.gitwhich installs it directly from a Github repository. This works fine and I want to have that dependency in my
requirements.txt. I've looked at other tickets like this but that didn't solve my problem. If I put something like-f git+git://github.com/mozilla/elasticutils.git
elasticutils==0.7.devin the
requirements.txt file, a pip install -r requirements.txt results in the following output:Downloading/unpacking elasticutils==0.7.dev (from -r requirements.txt (line 20))
Could not find a version that satisfies the requirement elasticutils==0.7.dev (from -r requirements.txt (line 20)) (from versions: )
No distributions matching the version for elasticutils==0.7.dev (from -r requirements.txt (line 20))The documentation of the requirements file does not mention links using the
git+git protocol specifier, so maybe this is just not supported.Does anybody have a solution for my problem?
Solution
Normally your
To specify a Github repo, you do not need the
The examples below update
Specify commit hash (
Specify branch name (
Specify tag (
Specify release (
Note that in certain versions of pip you will need to update the package version in the package's
See also the pip documentation on VCS support.
requirements.txt file would look something like this:package-one==1.9.4
package-two==3.7.1
package-three==1.0.1
...To specify a Github repo, you do not need the
package-name== convention.The examples below update
package-two using a GitHub repo. The text after @ denotes the specifics of the package.Specify commit hash (
41b95ec in the context of updated requirements.txt):package-one==1.9.4
package-two @ git+https://github.com/owner/repo@41b95ec
package-three==1.0.1Specify branch name (
main):package-two @ git+https://github.com/owner/repo@mainSpecify tag (
0.1):package-two @ git+https://github.com/owner/repo@0.1Specify release (
3.7.1):package-two @ git+https://github.com/owner/repo@releases/tag/v3.7.1Note that in certain versions of pip you will need to update the package version in the package's
setup.py, or pip will assume the requirement is already satisfied and not install the new version. For instance, if you have 1.2.1 installed, and want to fork this package with your own version, you could use the above technique in your requirements.txt and then update setup.py to 1.2.1.1.See also the pip documentation on VCS support.
Code Snippets
package-one==1.9.4
package-two==3.7.1
package-three==1.0.1
...package-one==1.9.4
package-two @ git+https://github.com/owner/repo@41b95ec
package-three==1.0.1package-two @ git+https://github.com/owner/repo@mainpackage-two @ git+https://github.com/owner/repo@0.1package-two @ git+https://github.com/owner/repo@releases/tag/v3.7.1Context
Stack Overflow Q#16584552, score: 1096
Revisions (0)
No revisions yet.