Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

use a relative path in requirements.txt to install a tar.gz file with pip

Tags:

python

pip

We're using a requirements.txt file to store all the external modules needed. Every module but one is gathered from internet. The other one is stored on a folder under the one holding the requirements.txt file.

BTW, this module can be easily installed with pip install

I've tried using this:

file:folder/module 

or this:

file:./folder/module 

or even this:

folder/module 

but always throws me an error. Does anyone know which is the right way to do this?

Thanks

like image 516
F.D.F. Avatar asked Mar 21 '12 17:03

F.D.F.


People also ask

Where is pip requirements txt?

Typically the requirements. txt file is located in the root directory of your project. Notice we have a line for each package, then a version number. This is important because as you start developing your python applications, you will develop the application with specific versions of the packages in mind.

What does pip install R requirements txt means?

Your intention is that pip install opens the txt and reads the packages from there. The -r allows pip install to open requirements. txt and install the packages inside of it instead. Follow this answer to receive notifications.

What is a requirements txt file?

In Python requirement. txt file is a type of file that usually stores information about all the libraries, modules, and packages in itself that are used while developing a particular project. It also stores all files and packages on which that project is dependent or requires to run. Typically this file "requirement.


1 Answers

In the current version of pip (1.2.1) the way relative paths in a requirements file are interpreted is ambiguous and semi-broken. There is an open issue on the pip repository which explains the various problems and ambiguities in greater detail:

https://github.com/pypa/pip/issues/328

Long story short the current implementation does not match the description in the pip documentation, so as of this writing there is no consistent and reliable way to use relative paths in requirements.txt.

THAT SAID, placing the following in my requirements.txt:

./foo/bar/mymodule 

works when there is a setup.py at the top level of the mymodule directory. Note the lack of the file:: protocol designation and the inclusion of the leading ./. This path is not relative to the requirements.txt file, but rather to the current working directory. Therefore it is necessary to navigate into the same directory as the requirements.txt and then run the command:

pip install -r requirements.txt 
like image 132
finn Avatar answered Oct 08 '22 05:10

finn