{"id":2010,"library":"dparse","title":"dparse - Python Dependency File Parser","description":"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.","status":"active","version":"0.6.4","language":"en","source_language":"en","source_url":"https://github.com/pyupio/dparse","tags":["dependency parsing","requirements.txt","pipfile","poetry.lock","setup.py","pyproject.toml"],"install":[{"cmd":"pip install dparse","lang":"bash","label":"Install stable version"}],"dependencies":[{"reason":"Used for parsing and comparing version specifiers.","package":"packaging"},{"reason":"Used internally for parsing setup.py/setup.cfg files.","package":"setuptools"}],"imports":[{"note":"The `parse` function is the primary entry point for parsing dependency strings or file-like objects.","symbol":"parse","correct":"from dparse import parse"}],"quickstart":{"code":"from dparse import parse\n\nrequirements_content = \"\"\"\nflask>=2.0.0\nrequests==2.28.1; python_version < \"3.9\"\ndjango\n\"\"\"\n\ndependencies = parse(requirements_content, filename='requirements.txt')\n\nprint(f\"Parsed {len(dependencies.dependencies)} dependencies:\")\nfor dep in dependencies.dependencies:\n    print(f\"- {dep.name}: {dep.specifier} (line {dep.line_number})\")\n\n# Example for a specific file type (e.g., Pipfile.lock)\npipfile_lock_content = \"\"\"\n{'_meta': {'hash': {'sha256': '...'}},\n 'default': {\n  'requests': {'hashes': [...], 'version': '==2.28.1'}}\n}\n\"\"\"\ndep_from_lock = parse(pipfile_lock_content, filename='Pipfile.lock')\nprint(f\"\\nParsed {len(dep_from_lock.dependencies)} from Pipfile.lock:\")\nfor dep in dep_from_lock.dependencies:\n    print(f\"- {dep.name}: {dep.specifier}\")","lang":"python","description":"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."},"warnings":[{"fix":"Upgrade your Python interpreter to version 3.7 or newer, or pin `dparse<0.6.0` if unable to upgrade Python.","message":"Python 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.","severity":"breaking","affected_versions":">=0.6.0"},{"fix":"Migrate to using the main `dparse.parse` function, which now encapsulates the parsing logic for various file types and is the recommended entry point.","message":"The `dparse.pyup_parser` module was removed in version 0.4.0. Direct imports from this module will fail.","severity":"breaking","affected_versions":">=0.4.0"},{"fix":"For projects relying heavily on `setup.py` for dependency definition, consider migrating to `pyproject.toml` or `setup.cfg` for more reliable and static dependency declaration. Always verify the parsed output for `setup.py` files.","message":"`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.","severity":"gotcha","affected_versions":"All versions"},{"fix":"Do not expect `dparse` to perform dependency resolution or installation. Use tools like `pip`, `Poetry`, or `Pipenv` for those tasks after parsing.","message":"`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.","severity":"gotcha","affected_versions":"All versions"}],"env_vars":null,"last_verified":"2026-04-09T00:00:00.000Z","next_check":"2026-07-08T00:00:00.000Z"}