Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to state in requirements.txt a direct github source

I've installed a library using the command

pip install git+git://github.com/mozilla/elasticutils.git 

which 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.dev 

in 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?

like image 742
Alfe Avatar asked May 16 '13 10:05

Alfe


People also ask

Can I put pip in requirements txt?

The most common command is pip freeze > requirements. txt , which records an environment's current package list into requirements. txt. If you want to install the dependencies in a virtual environment, create and activate that environment first, then use the Install from requirements.

Does requirements txt update automatically?

txt file and it will auto update all your high-level packages to the latest versions, keeping your original formatting and comments in-place. For example, running pur on the example requirements. txt updates the packages to the currently available latest versions: $ pur -r requirements.


1 Answers

Normally your 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 between @ and # denotes the specifics of the package.

Specify commit hash (41b95ec in the context of updated requirements.txt):

package-one==1.9.4 git+https://github.com/path/to/package-two@41b95ec#egg=package-two package-three==1.0.1 

Specify branch name (master):

git+https://github.com/path/to/package-two@master#egg=package-two 

Specify tag (0.1):

git+https://github.com/path/to/[email protected]#egg=package-two 

Specify release (3.7.1):

git+https://github.com/path/to/package-two@releases/tag/v3.7.1#egg=package-two 

Note that #egg=package-two is not a comment here, it is to explicitly state the package name

This blog post has some more discussion on the topic.

like image 172
YPCrumble Avatar answered Nov 21 '22 18:11

YPCrumble