Registry / devops / dparse2

dparse2

JSON →
library0.7.0pypypi✓ verified 90d ago

A robust fork of the original dparse library with up-to-date dependency file parsing (pip requirements, Pipfile, conda env yml, poetry, setup.cfg). Version 0.7.0 supports Python 3.6+. Maintained by nexB.

pip install dparse2
INSTALL
IMPORT
SIG · DPARSE2
D
dparse2
devopspythonv0.7.0
Install
1.9s avg
Import
543ms
Disk
20MB
Pass rate
10/ 10
Env Coverage10 / 10
glibc
3.9–3.13
musl
3.9–3.13
Install & Compatibility
Where this runs
tested against v0.7.0 · pip install
no network on importno background threads
Install × environment matrix
Each cell = how many times install + import succeeded across repeated harness runs. Partial = flaky.
glibc = Debian/Ubuntu slim · musl = Alpine Linux
musl
py 3.10–3.95 runs
installs and imports cleanly · install 0.0s · import 0.566s · 21.3MB
glibc
py 3.10–3.95 runs
installs and imports cleanly · install 1.9s · import 0.520s · 23MB
20MB installed
● package 20MB
Code
Verified usage

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

parse
✓ from dparse2 import parse
Original dparse used 'from dparse import parse'. The module is now dparse2.
filetypes
✓ from dparse2.filetypes import RequirementsFile
✗ from dparse import filetypes
Package name changed from dparse to dparse2.
dparse2
✓ import dparse2
Top-level package is dparse2, not dparse.

Parses a requirements.txt file and prints each dependency name and version specifier.

from dparse2 import parse from dparse2.filetypes import RequirementsFile with open('requirements.txt') as f: content = f.read() parsed = parse(content, RequirementsFile) for dep in parsed.dependencies: print(dep.name, dep.specs)
Debug
Known issues
breakingPackage renamed from dparse to dparse2. All imports must use dparse2.
fix
Replace 'import dparse' with 'import dparse2'.
affects: all
breakingPython 2.7 support dropped after 0.5.0.1. Versions 0.6+ require Python 3.6+.
fix
Upgrade to Python 3.6+ or use dparse2==0.5.0.1.
affects: >=0.6.0
gotchaparse() returns a ParsedFile object; dependencies can be empty if file is malformed. Always check dependencies before iteration.
fix
Use 'if parsed.dependencies: for dep in parsed.dependencies: ...'
affects: all
gotchaRequirementsFile parser expects base directory (default: '.'). Relative paths in requirements.txt are resolved against the base dir.
fix
Pass base_dir parameter to parse() to control relative path resolution.
affects: all
Errors
Common errors & fixes
ModuleNotFoundError: No module named 'dparse'
Package renamed to dparse2; old import fails.
fix
Run 'pip install dparse2' and change imports to 'import dparse2'.
AttributeError: module 'dparse2' has no attribute 'parse'
Wrong import path; parse is a function, not a module attribute when using 'import dparse2'.
fix
Use 'from dparse2 import parse' or 'dparse2.parse(...)'.
TypeError: parse() missing 1 required positional argument: 'file_type'
parse() requires a file type class as second argument.
fix
Provide a file type, e.g., 'from dparse2.filetypes import RequirementsFile' and call 'parse(content, RequirementsFile)'.
Upgrade
Version history
0.7.0latest on PyPI · released Dec 23, 2022
Audit
Dependencies
packagingrequiredversion comparison
tomlrequiredparsing Pipfile and poetry files
pyyamlrequiredparsing conda yml files
Agent activity
11 hits · last 30 days
node
10
Amazon
1
Resources
dparse2 — pip install dparse2 · libregistry