[Distutils] Parsing requirements, pip has no API ...

Marcus Smith qwcode at gmail.com
Fri Feb 13 22:59:59 CET 2015


> In general, requirements.txt seems to be an
> anti-pattern. You either have to use likely to break tooling or you'll
> have to reinvent that from scratch. You're better off putting it
> directly in setup.py and using setup.py to install dependencies in a
> virtualenv instead of requirements.txt
>

I don't know your context for calling it an anti-pattern, but there are
valid use cases for requirements.txt vs install_requires.
here's what the "Python Packaging User Guide" has on the distinction

https://packaging.python.org/en/latest/requirements.html

skipping to the distinctions, it lists four:

Whereas install_requires defines the dependencies for a single
project, *Requirements
Files* <https://pip.pypa.io/en/latest/user_guide.html#requirements-files>
are often used to define the requirements for a complete python environment.
Whereas install_requires requirements are minimal, requirements files often
contain an exhaustive listing of pinned versions for the purpose of
achieving *repeatable installations*
<https://pip.pypa.io/en/latest/user_guide.html#repeatability> of a complete
environment.

Whereas install_requires requirements are “Abstract”, requirements files
often contain pip options like --index-url or --find-links to make
requirements “Concrete”. [1]
<https://packaging.python.org/en/latest/requirements.html#id4>

Whereas install_requires metadata is automatically analyzed by pip during
an install, requirements files are not, and only are used when a user
specifically installs them using pip install -r.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/distutils-sig/attachments/20150213/4bb96eb8/attachment.html>


More information about the Distutils-SIG mailing list