| 1 | # Requirements Parser |
| 2 | |
| 3 | [![shield_pypi-version]][link_pypi] |
| 4 | [![shield_rtfd]][link_rtfd] |
| 5 | [![shield_gh-workflow-test]][link_gh-workflow-test] |
| 6 | [![shield_license]][license_file] |
| 7 | |
| 8 | --- |
| 9 | |
| 10 | This is a small Python module for parsing [Pip](http://www.pip-installer.org/) requirement files. |
| 11 | |
| 12 | The goal is to parse everything in the [Pip requirement file format](https://pip.pypa.io/en/stable/reference/pip_install/#requirements-file-format) spec. |
| 13 | |
| 14 | ## Installation |
| 15 | |
| 16 | pip install requirements-parser |
| 17 | |
| 18 | or |
| 19 | |
| 20 | poetry add requirements-parser |
| 21 | |
| 22 | ## Examples |
| 23 | |
| 24 | `requirements-parser` can parse a file-like object or a text string. |
| 25 | |
| 26 | ``` {.python} |
| 27 | >>> import requirements |
| 28 | >>> with open('requirements.txt', 'r') as fd: |
| 29 | ... for req in requirements.parse(fd): |
| 30 | ... print(req.name, req.specs) |
| 31 | Django [('>=', '1.11'), ('<', '1.12')] |
| 32 | six [('==', '1.10.0')] |
| 33 | ``` |
| 34 | |
| 35 | It can handle most (if not all) of the options in requirement files that do not involve traversing the local filesystem. These include: |
| 36 | |
| 37 | - editables (`-e git+https://github.com/toastdriven/pyelasticsearch.git]{.title-ref}`) |
| 38 | - version control URIs |
| 39 | - egg hashes and subdirectories (`[\#egg=django-haystack&subdirectory=setup]{.title-ref}`) |
| 40 | - extras ([DocParser\[PDF\]]{.title-ref}) |
| 41 | - URLs |
| 42 | |
| 43 | ## Documentation |
| 44 | |
| 45 | View the documentation [here][link_rtfd]. |
| 46 | |
| 47 | ## Python Support |
| 48 | |
| 49 | We endeavour to support all functionality for all [current actively supported Python versions](https://www.python.org/downloads/). |
| 50 | However, some features may not be possible/present in older Python versions due to their lack of support. |
| 51 | |
| 52 | ## Changelog |
| 53 | |
| 54 | See our [CHANGELOG][chaneglog_file]. |
| 55 | |
| 56 | ## Contributing |
| 57 | |
| 58 | Feel free to open issues, bugreports or pull requests. |
| 59 | See the [CONTRIBUTING][contributing_file] file for details. |
| 60 | |
| 61 | ## Copyright & License |
| 62 | |
| 63 | `requirements-parser` was originally written by @davidfischer and is now maintained by @madpah. See [Authors][authors_file] for full details. |
| 64 | |
| 65 | Permission to modify and redistribute is granted under the terms of the Apache 2.0 license. |
| 66 | |
| 67 | See the [LICENSE][license_file] file for the full license. |
| 68 | |
| 69 | [authors_file]: https://github.com/madpah/requirements-parser/blob/main/AUTHORS.md |
| 70 | [license_file]: https://github.com/madpah/requirements-parser/blob/main/LICENSE |
| 71 | [chaneglog_file]: https://github.com/madpah/requirements-parser/blob/main/CHANGELOG.md |
| 72 | [contributing_file]: https://github.com/madpah/requirements-parser/blob/main/CONTRIBUTING.md |
| 73 | |
| 74 | [shield_gh-workflow-test]: https://img.shields.io/github/actions/workflow/status/madpah/requirements-parser/poetry.yml?branch=main&logo=GitHub&logoColor=white "build" |
| 75 | [shield_pypi-version]: https://img.shields.io/pypi/v/requirements-parser?logo=pypi&logoColor=white&label=PyPI "PyPI" |
| 76 | [shield_rtfd]: https://img.shields.io/readthedocs/requirements-parser?logo=readthedocs&logoColor=white "Read the Docs" |
| 77 | [shield_license]: https://img.shields.io/github/license/madpah/requirements-parser?logo=open%20source%20initiative&logoColor=white "license" |
| 78 | |
| 79 | [link_gh-workflow-test]: https://github.com/madpah/requirements-parser/actions/workflows/poetry.yml?query=branch%3Amain |
| 80 | [link_pypi]: https://pypi.org/project/requirements-parser/ |
| 81 | [link_rtfd]: https://requirements-parser.readthedocs.io/en/latest/ |