Search code examples
pythonsetuptoolspackagingsetup.py

Is there complete documentation for `setup.cfg`?


The Python Packaging Tutorial recommends that "Static metadata (setup.cfg) should be preferred. Dynamic metadata (setup.py) should be used only as an escape hatch when absolutely necessary. setup.py used to be required, but can be omitted with newer versions of setuptools and pip."

The guide to packaging and distributing projects explains that "setup.cfg is an ini file that contains option defaults for setup.py commands. For an example, see the setup.cfg in the PyPA sample project."

That example is entirely useless, and there doesn't appear to be a lot of other helpful information. The examples in the tutorial suggest that some, or perhaps all, valid arguments to setuptools.setup() can be listed in setup.cfg, but there is no real explanation to this effect. In particular, it's not clear how to translate a list argument, like that for the very common and important install_requires parameter, into lines in setup.cfg.

The proper way to do this, as I've determined by deduction and experimentation, appears to be as follows:

[options]
install_requires =
    dependency_1
    dependency_2

Obviously it would be better for this to be properly documented somewhere so that new package creators do not have to undergo a similar process just to specify their projects' dependencies.

Does such documentation exist?


Solution

  • Yes, in the documentation of the setuptools. Here it is: https://setuptools.readthedocs.io/en/latest/userguide/declarative_config.html