pyproject-dependencies
raw JSON → 1.3.2 verified Fri May 01 auth: no python
A tool to extract dependencies from pyproject.toml files in a robust way. Supports both static and dynamic dependency resolution, including optional dependencies (extras). Compatible with Python 3.7+. Current version: 1.3.2. Release cadence: irregular.
pip install pyproject-dependencies Common errors
error ModuleNotFoundError: No module named 'pyproject_dependencies' ↓
cause Trying to import the module without installing it or using wrong import name.
fix
Install the package: pip install pyproject-dependencies. Import using: from pyproject_dependencies import get_dependencies
error KeyError: 'dependencies' ↓
cause The pyproject.toml may not have a [project] table with dependencies, or the tool fails to parse them.
fix
Check that the pyproject.toml follows PEP 621. If using a build backend that doesn't expose deps statically, consider using a different approach.
error ValueError: Could not parse pyproject.toml: <path> ↓
cause The file is not a valid TOML file or missing required sections.
fix
Validate the pyproject.toml with a TOML validator.
Warnings
gotcha Optional dependencies are not included in 'dependencies' key; they are in 'extras' dict. ↓
fix Access results['extras'] to get optional dependency groups.
breaking In v1.3, optional dependencies were no longer printed by the CLI. The API behavior changed: extras are only returned as a separate dict key. ↓
fix If using CLI, use --extras flag to see optional dependencies. For API, use results['extras'].
gotcha Dynamic version fields (e.g., from setuptools-scm) can cause resolution failures. v1.3.1 fixed some issues but dynamic deps may still fail. ↓
fix Ensure the project can be resolved (e.g., run pip install -e .) before calling get_dependencies, or pre-compute static dependencies.
Imports
- get_dependencies wrong
from pyproject_dependencies import dependenciescorrectfrom pyproject_dependencies import get_dependencies - extras
from pyproject_dependencies import extras
Quickstart
import os
from pyproject_dependencies import get_dependencies
# Assuming pyproject.toml is in the current directory
results = get_dependencies()
print('Main dependencies:', results.get('dependencies', []))
print('Optional groups:', results.get('extras', {}))
# For a specific directory
results = get_dependencies('path/to/project')
print('Dependencies from path:', results.get('dependencies', []))