Analyze Python import dependencies.
Project description
DigDep
A lightweight Python dependency analyzer that scans Python projects and visualizes import relationships.
Installation
pip install digdep
Quick Start (CLI)
List all imported packages:
digdep packages ./myproject
Show the File → Dependency tree:
digdep file-tree ./myproject
Show the Dependency → File tree:
digdep dep-tree ./myproject
Sample Output
File → Dependency Tree
Root (/projects/example)
├── main.py → requests, pathlib
├── config.py → json
│
├── modules/
│ ├── logger.py → logging
│ ├── parser.py → re, typing
│
└── utils/
└── helpers.py → functools
Dependency → File Tree
requests
├── main.py
re
├── modules/
│ └── parser.py
logging
├── modules/
│ └── logger.py
Filtering
Filter dependencies by type.
Show only standard library imports:
digdep file-tree ./myproject --type stdlib
Show both standard library and third-party imports:
digdep file-tree ./myproject --type stdlib,third-party
Show only local imports:
digdep file-tree ./myproject --type local
Ignoring Files and Directories
Skip directories or files while scanning:
digdep file-tree ./myproject --ignore venv __pycache__ tests
Redirecting Output
Save the generated tree to a file:
digdep dep-tree ./myproject > dependencies.txt
Commands
| Command | Description |
|---|---|
packages |
List all imported packages |
file-tree |
Show the File → Dependency tree |
dep-tree |
Show the Dependency → File tree |
Run digdep <command> --help for command-specific options.
Using as a Python Library
from digdep import DepAnalyzer, DepType
analyzer = DepAnalyzer()
# Ignoring directories
analyzer.ignore([
"__pycache__",
"venv",
"build",
"tests"
])
analyzer.scan("./myproject")
# List imported packages
packages = analyzer.get_packages()
# Get the File -> Dependency tree
filedep_tree = analyzer.get_filedep_tree()
# Get the Dependency -> File tree
depfile_tree = analyzer.get_depfile_tree()
Filter dependencies by type:
from digdep import DepAnalyzer, DepType
analyzer = DepAnalyzer()
analyzer.scan("./myproject")
# Show only standard library imports
filedep_tree = analyzer.get_filedep_tree(
filters=DepType.STDLIB
)
# Show standard library and third-party imports
depfile_tree = analyzer.get_depfile_tree(
filters=DepType.STDLIB | DepType.THIRD_PARTY
)
Roadmap
- Local module detection
- Dependency statistics
- JSON export
- Circular dependency detection
- Unused dependency detection
Requirements
- Python 3.11+
License
Released under the MIT License.
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file digdep-0.0.3.tar.gz.
File metadata
- Download URL: digdep-0.0.3.tar.gz
- Upload date:
- Size: 9.6 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/7.0.0 CPython/3.11.9
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
dc28a9c3f4b9da3b499888fb52cd18604611b718aa2a8920efa4e43a1df7ad18
|
|
| MD5 |
abb6cd6aee8234e969e86c4d5dad112a
|
|
| BLAKE2b-256 |
fd88f8d875988eaab99dfe0845aea3f552375c2ad5e2ffb8b895a3631ee8bb63
|
File details
Details for the file digdep-0.0.3-py3-none-any.whl.
File metadata
- Download URL: digdep-0.0.3-py3-none-any.whl
- Upload date:
- Size: 11.8 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/7.0.0 CPython/3.11.9
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
2966a8c2f72e0f071096bb7e986b317866bb451b84b3d5f5f050a6230e6b74a6
|
|
| MD5 |
01a6475260970b06494a147093d58c34
|
|
| BLAKE2b-256 |
537e94ffe3af477c7474989e4cf059863ad7ece846d8c5d52f8dfadcd9227d64
|