[Distutils] How setuptools reads requirements

Erik Bray erik.m.bray at gmail.com
Mon Dec 2 20:48:58 CET 2013

On Tue, Nov 19, 2013 at 1:56 PM, Kura <kura at kura.io> wrote:
> Hey guys
> I'm trying to dig in to how setuptools/distutils reads the
> [install_]requires keyword and how requirements.txt is handled.
> I've tried running setup.py --requires but get an empty response back, this
> also fails when using >=x.x,<=x.y and causes a Python stack trace.
> Was wondering if someone on here could shed some light on the topic for me.

`setup.py --requires` is mostly useless.  It only reports back entries
from the `requires=` argument to setup() supported by distutils.  This
only tracks the names of other modules that a module needs to import,
and is being phased out as not particularly useful.  It's not in any
way tied to `install_requires` which is a feature added by setuptools.

As for "requirements.txt", you might mean "requires.txt" which is a
file added to the .egg_info directory when you run the `setup.py
egg_info` command on a setuptools-enabled package.  Pip has its own
code for reading information from files out of .egg_info.  I believe
there are other libraries like pkginfo [1] that do this.

> It's for a Python dependency management/monitoring system I am writing so
> hopefully would benefit the overall community.

Sounds intriguing!

[1] https://pypi.python.org/pypi/pkginfo

More information about the Distutils-SIG mailing list