Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How can I define multiple requirement files?

How can I do define multiple requirements files in my requirements.txt file.

-r base.txt
-r test.txt

The current behavior is that pip only installs packages from test.txt. I'd expect pip to install packages found in both base.txt and test.txt. I could have sworn I've seen someone do this in the past, but I can't find any examples.

like image 242
self. Avatar asked Apr 20 '16 12:04

self.


People also ask

How do you file requirements?

A Beginner's Guide to PipA requirements file is a list of all of a project's dependencies. This includes the dependencies needed by the dependencies. It also contains the specific version of each dependency, specified with a double equals sign ( == ). pip freeze will list the current projects dependencies to stdout .

What is requirements Dev txt?

txt. This is a safeguard against typos when running pip install -r requirements-dev. txt. If you leave out the -r by accident, this package will cause your installation to abort.


3 Answers

pip accepts multiple -r arguments:

pip install -r reqs1.txt -r reqs2.txt

The help for pip install says:

-r, --requirement
Install from the given requirements file. This option can be used multiple times.

like image 60
snakecharmerb Avatar answered Oct 16 '22 22:10

snakecharmerb


You can have one file "include" the other; for example, if you put this in file2.txt:

-r file1.txt
Django
Flask
etc.

Then when you do pip install -r file2.txt, it will also install things from file1.txt.

I often use this strategy to have a "base" requirements file, and then only specify those things that are required at each stage (development, testing, staging, production, etc.)

like image 33
Burhan Khalid Avatar answered Oct 16 '22 21:10

Burhan Khalid


I have many requirements in different directories and solve this problem as:

sudo find . -name "requirement*" -type f -exec pip3 install -r '{}' ';'
like image 4
storenth Avatar answered Oct 16 '22 21:10

storenth