Skip to content

madpah/requirements-parser

Repository files navigation

Requirements Parser

shield_pypi-version shield_rtfd shield_gh-workflow-test shield_license


This is a small Python module for parsing Pip requirement files.

The goal is to parse everything in the Pip requirement file format spec.

Installation

pip install requirements-parser

or

poetry add requirements-parser

Examples

requirements-parser can parse a file-like object or a text string.

>>> import requirements
>>> with open('requirements.txt', 'r') as fd:
...     for req in requirements.parse(fd):
...         print(req.name, req.specs)
Django [('>=', '1.11'), ('<', '1.12')]
six [('==', '1.10.0')]

It can handle most (if not all) of the options in requirement files that do not involve traversing the local filesystem. These include:

  • editables (-e git+https://github.com/toastdriven/pyelasticsearch.git]{.title-ref})
  • version control URIs
  • egg hashes and subdirectories ([\#egg=django-haystack&subdirectory=setup]{.title-ref})
  • extras ([DocParser[PDF]]{.title-ref})
  • URLs

Documentation

View the documentation here.

Python Support

We endeavour to support all functionality for all current actively supported Python versions. However, some features may not be possible/present in older Python versions due to their lack of support.

Changelog

See our CHANGELOG.

Contributing

Feel free to open issues, bugreports or pull requests.
See the CONTRIBUTING file for details.

Copyright & License

requirements-parser was originally written by @davidfischer and is now maintained by @madpah. See Authors for full details.

Permission to modify and redistribute is granted under the terms of the Apache 2.0 license.

See the LICENSE file for the full license.