[Distutils] A setup-requires implementation

Daniel Holth dholth at gmail.com
Tue May 20 03:24:24 CEST 2014


Here's a short setup.py replacement that makes setup-requires work:
https://bitbucket.org/dholth/setup-requires/src/ . I'd appreciate a
code review.

Use by renaming your own package's setup.py to real-setup.py and
copying this setup.py in its place.

List only the requirements setup.py itself needs to run in the
`setup-requires =` key of the `[metadata]` section of setup.cfg,
one per line::

    [metadata]
    setup-requires = cffi
        pip
        pycparser >= 2.10

(Only the name and required versions are allowed, not the full pip
syntax of URLs to specific repositories. Instead, install internal
setup-requires dependencies manually or set PIP_FIND_LINKS=... to point
to the necessary repositories.)

When run, setup-requires' setup.py checks that each distribution
listed in setup-requires is installed; if not, it installs them into
the ./setup-requires directory in a pip subprocess. Then real-setup.py
continues to execute with the same arguments.

Why a custom section in setup.cfg? Users are accustomed to editing
setup.cfg to configure random things like unit tests, bdist_wheel
etc.; this just adds a field instead of a new file. Unlike a .txt file
it should be more intuitive that setup.cfg does not support the full
pip requirements syntax.

Please note that not every package installs correctly with pip -t.

Now let's see some setup.py helper packages.

Daniel Holth


More information about the Distutils-SIG mailing list