A lightweight Python dependency analyzer
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 Directories
Ignore from command line
digdep file-tree ./myproject --ignore venv __pycache__ tests
Ignore from a file
Create a text file (for example, ignore.txt):
venv
.git
build
__pycache__
tests
Then run:
digdep . --ignore-file ignore.txt
Each non-empty line in the file is treated as a directory to ignore.
The --ignore and --ignore-file options can be used together.
Write Output to a File
Use the -o (--output) option to write command output to a file. Currently, DigDep supports JSON output.
Export the dependency list
digdep deps . -o deps.json
Output:
{
"dependencies": [
"argparse",
"ast",
"json",
"pathlib",
"rich"
]
}
Export the file-dependency tree
digdep file-tree . -o file-tree.json
Export the dependency-file tree
digdep dep-tree . -o dep-tree.json
The output format is determined by the file extension. Currently, only .json is supported.
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.5.tar.gz.
File metadata
- Download URL: digdep-0.0.5.tar.gz
- Upload date:
- Size: 10.0 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/7.0.0 CPython/3.11.9
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
4b485919746d8f49ef85aebf3b195cd924a0d5f0264d9fee97994354c2ad1969
|
|
| MD5 |
70d4a50ea11a6ad4537b15b41784179f
|
|
| BLAKE2b-256 |
664bbfe6c9989b80f2e1b2d7c131351b3964ded27e01c4c779a126bc51800c7c
|
File details
Details for the file digdep-0.0.5-py3-none-any.whl.
File metadata
- Download URL: digdep-0.0.5-py3-none-any.whl
- Upload date:
- Size: 11.0 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 |
e3a9a37b4e222bec7d91bbf511b42cd7c68ee0288ea8f5e1af35825d4baf3eda
|
|
| MD5 |
ad77f190abcc5ea24d749beeb1c4c5a8
|
|
| BLAKE2b-256 |
ab513b0644a9df6a7eb3cd9bf826baa2d5072325551e82ca3be7fb128ac62700
|