[Distutils] A setup-requires implementation

Erik Bray erik.m.bray at gmail.com
Thu May 29 17:55:00 CEST 2014


On Mon, May 19, 2014 at 9:24 PM, Daniel Holth <dholth at gmail.com> wrote:
> 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.

Thanks, I like the approach this takes of using pip instead of
easy-install, and caching all the setup_requires packages in the
setup-requires directory without cluttering the source root with eggs.
 I'm not crazy about having to launch a separate process to do
this--do you think it can be done without that, by just importing pip
and using its API?  Or did you find that to be too problematic?

I'm also not crazy about putting the real setup.py in a separate file,
but only because, in my case, I think it's likely to confuse some of
my co-developers.  That said, I think that this approach could be
adapted to suit my needs.

Erik


More information about the Distutils-SIG mailing list