Visualize internal Python import dependencies
Project description
depsgraph is a minimal command-line tool that shows which Python modules a single file depends on within your project. It ignores stdlib and third-party imports by default, so you see only your own code’s coupling.
Features
- Static analysis via AST (fast, no imports executed)
- ASCII tree printed to stdout
- Mermaid mindmap generated as
.mmdand self-contained.html - Configurable recursion depth and ignore patterns
- Detects import cycles and marks them
Install
pip install depsgraph
Usage
depsgraph path/to/file.py --project-dir /path/to/project
Example:
$ depsgraph src/handlers/api.py --project-dir . src/handlers/api.py +-- src/models/user.py +-- src/utils/auth.py | +-- src/config.py +-- src/db/conn.py +-- src/config.py
The command also creates deps_graph.html in the project directory; open it in a browser to view an interactive Mermaid mindmap.
Options
- --project-dir: root of the project to scan (default ".")
- --max-depth: limit graph depth (default 50)
- --show-missing: list unresolved imports (stdlib, missing files)
- --no-mermaid: skip Mermaid file generation
- --ignored-dir: repeatable, e.g.
--ignored-dir generated
Requirements
Python 3.9+
License
MIT
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 depsgraph-0.1.3.tar.gz.
File metadata
- Download URL: depsgraph-0.1.3.tar.gz
- Upload date:
- Size: 5.5 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.13.5
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
75861fbc50be7e1901a71a8d38028b505a47be3b9a4661a272467528abdea0c4
|
|
| MD5 |
52fa69f75905b6797e5857b9fdae2f99
|
|
| BLAKE2b-256 |
6f8bf2be1169f04dd42d83e8106f730e60b80d9c2fa91f034772d78a3cf7302b
|
File details
Details for the file depsgraph-0.1.3-py3-none-any.whl.
File metadata
- Download URL: depsgraph-0.1.3-py3-none-any.whl
- Upload date:
- Size: 5.8 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.13.5
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
3973bb23510ab2c56b5d3602d9063195ac4e5575efe615f461c8b0bee78b8c25
|
|
| MD5 |
1c493e2f4d9c98cb5e4ebe60280ce909
|
|
| BLAKE2b-256 |
cf85caa32365a60114e7a71e977ed01d7b01209b571531a13bb44e950111a79a
|