pip-requirements-parser is a Python library designed for robustly parsing `pip` requirement files. It distinguishes itself by leveraging `pip`'s own internal parsing logic, ensuring high accuracy in handling the diverse and often complex `pip` requirement format. The library provides a stable, offline API for parsing, making it suitable for environments where network access is restricted or where precise `pip`-compatible parsing is critical. It is currently at version 32.0.1 and aims for a stable API for its users, despite the inherent complexities of `pip`'s internal requirement file format.
pip install pip-requirements-parserVerified import paths — ran on the pinned version, not inferred.
This quickstart demonstrates how to parse a string containing pip-style requirements using `requirements.parse()`. Each parsed requirement object provides attributes like `name`, `specs` (version specifiers), `vcs` (Version Control System information), and `url` for detailed analysis. The library also supports parsing directly from file-like objects.
Rely on `pip-requirements-parser`'s documented API. If issues arise with new `pip` requirement syntaxes, ensure you are using the latest version of `pip-requirements-parser` as it tracks `pip`'s internal changes.
For package distribution, define dependencies in `pyproject.toml` (PEP 508). Use `pip-requirements-parser` only when you explicitly need to read and interpret the `requirements.txt` format itself, for example, in tools that analyze application environments.
This is generally a feature for isolation and speed. If you require resolution of network-based requirements (e.g., installing packages from custom URLs or VCS), you will need to use `pip` directly or another tool that handles network operations.
Ensure `pip-requirements-parser` is installed in your Python environment by running `pip install pip-requirements-parser`. If you are using a virtual environment, make sure it is activated before installation.
Ensure `pip-requirements-parser` is installed in your Python environment. You can typically install it using `pip install pip-requirements-parser`.