Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

According to the setuptools documentation, setuptools version 30.3.0 (December 8, 2016) "allows using configuration files (usually setup.cfg) to define package’s metadata and other options which are normally supplied to setup() function". Similar to running pip install -r requirements.txt to install Python packages from a requirements file, is there a way to ask pip to install the packages listed in the install_requires option of a setup.cfg configuration file?

like image 498
argentpepper Avatar asked Sep 13 '17 19:09

argentpepper


People also ask

Do you need setup py If you have setup cfg?

you must have a valid setup.py file apart from setup. cfg and pyproject. toml . You can use the same dummy setup file I shared in the previous section that makes just a single call to the setup() method.

How does pip decide where to install?

It prefers binary wheels if there are any, and if they are multiple it chooses the one most specific to the install environment. These are just pip 's default preferences though—they can be configured with options like --no-binary or --prefer-binary .

Does pip depend on setuptools?

All users who install pip will get setuptools by default. Users cannot explicitly uninstall setuptools after installing pip nor exclude setuptools when installing pip. Users might op-out from installing Recommended packages by default to save space, and such users will still get setuptools with pip.


1 Answers

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.

like image 59
Jakub Kukul Avatar answered Sep 19 '22 13:09

Jakub Kukul