Can pip install from setup.cfg, as if installing from a requirements file?

Here is my workaround. I use the following command to parse the install_requires element from the setup.cfg file and install the packages using pip.

python3 -c "import configparser; c = configparser.ConfigParser(); c.read('setup.cfg'); print(c['options']['install_requires'])" | xargs pip install

Here is a more readable version of the Python script before the pipe in the above command line.

import configparser
c = configparser.ConfigParser()
c.read('setup.cfg')
print(c['options']['install_requires'])

If your setup.cfg belongs to a well-formed package, you can do e.g.:

pip install -e .[tests,dev]

(install this package in place, with given extras)

afterwards you can pip uninstall that package by name, leaving deps in place.


If you have all your dependencies and other metadata defined in setup.cfg, just create a minimal setup.py file in the same directory that looks like this:

from setuptools import setup
setup()

From now on you can run pip install and it will install all the dependencies defined in setup.cfg as if they were declared in setup.py.