[Distutils] fix setup_requires by allowing it in setup.cfg or a setup_requires.txt

Daniel Holth dholth at gmail.com
Thu May 15 19:21:23 CEST 2014


Glyph has suggested something that I've been wanting to do for a long
time. "let me use setup_requires somehow so I can have abstractions in
setup.py".

setup.py allows you to pass setup_requires = [] to the setup() call.
Unfortunately, since setup.py needs setup_requires to be installed
before it can run, this feature is crap. It also has the unfortunate
side effect of recursively calling easy_install and installing the
listed packages even when pip or no installer is being used.

Instead, I'd like to allow a list of requirements in setup.cfg:

[a section name]
setup-requires = somepackage > 4.0
   anotherpackage >= 3.2.1

As an alternative we could look for a file setup-requires.txt which
would be the same as a pip-format requirements file.

I prefer doing it in setup.cfg because people are used to that file,
and because it only accepts package names and not general pip or
easy_install command line arguments.

This would be simple and a tremendous boon to anyone considering
implementing a setup.py-emulating distutils replacement, or to anyone
who just likes abstractions.

Metadata 2.0 is not a solution for this problem. It's late, it's more
complicated, and for any "legacy" packages setup.py is the thing that
generates metadata.json - not something that can only run if you parse
a skeletal metadata.json, do what it says, and then overwrite
metadata.json when dist_info is called.

Daniel


More information about the Distutils-SIG mailing list