Registry / devops / dparse

dparse

JSON →
library0.6.4pypypi✓ verified 35d ago

dparse is a Python library designed to parse various Python dependency file formats such as `requirements.txt`, `Pipfile`, `Pipfile.lock`, `poetry.lock`, `setup.py`, `setup.cfg`, and `pyproject.toml`. It extracts dependency information, including names, versions, and extras, into a structured format. The current version is 0.6.4, with releases occurring on an irregular but active basis.

devopsserializationdata
Install & Compatibility
Where this runs

No compatibility data collected yet for this library.

Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

The `parse` function is the primary entry point for parsing dependency strings or file-like objects.

from dparse import parse

This quickstart demonstrates how to use `dparse.parse` to extract dependencies from a string representing a `requirements.txt` file and a `Pipfile.lock`. The `filename` argument helps `dparse` identify the correct parsing strategy. The output shows the name and version specifier for each detected dependency.

from dparse import parse requirements_content = """ flask>=2.0.0 requests==2.28.1; python_version < "3.9" django """ dependencies = parse(requirements_content, filename='requirements.txt') print(f"Parsed {len(dependencies.dependencies)} dependencies:") for dep in dependencies.dependencies: print(f"- {dep.name}: {dep.specifier} (line {dep.line_number})") # Example for a specific file type (e.g., Pipfile.lock) pipfile_lock_content = """ {'_meta': {'hash': {'sha256': '...'}}, 'default': { 'requests': {'hashes': [...], 'version': '==2.28.1'}} } """ dep_from_lock = parse(pipfile_lock_content, filename='Pipfile.lock') print(f"\nParsed {len(dep_from_lock.dependencies)} from Pipfile.lock:") for dep in dep_from_lock.dependencies: print(f"- {dep.name}: {dep.specifier}")
Debug
Known footguns
breakingPython 3.6 support was dropped in `dparse` version 0.6.0. Users on Python 3.6 or older must upgrade their Python environment to at least 3.7 to use versions 0.6.0 and later.
breakingThe `dparse.pyup_parser` module was removed in version 0.4.0. Direct imports from this module will fail.
gotcha`dparse` provides heuristic parsing for `setup.py` files. Due to the dynamic nature of `setup.py`, complex or non-standard setups might not be fully or accurately parsed.
gotcha`dparse` is solely a *parser* of dependency files. It does not resolve dependencies, install packages, or interact with package indexes. Its output is a structured representation of the dependencies as declared in the input file.
Upgrade
Version history

Breaking-change detection hasn't run for this library yet.

Audit
Security & dependencies

CVE tracking and dependency tree are planned for a later release.

Agent activity
0 hits · last 30 days

No traffic data recorded yet.

Resources