Local package dependency visualizer tool
Project description
๐ฆ Local Package Dependency Visualizer (LPV)
LPV is a Python command-line tool that analyzes a projectโs import structure and builds a complete dependency graph. It detects cycles, dead code, oversized modules, risky dynamic imports, and generates ASCII or Graphviz visualizations.
This tool is designed for developers who want fast, accurate insights into Python project architecture โ ideal for refactoring, debugging, and CI automation.
๐ Features
- AST-based Parsing
- Dependency Graph Construction
- Cycle Detection (DFS)
- Dead Code Detection (BFS)
- Oversized Module Detection
- Module Split Suggestions
- Dynamic Import Warnings
- ASCII Visualization
- Graphviz Export (DOT, PNG, SVG, PDF)
- Fast & Lightweight
๐ Project Structure
lpv/
โ
โโโ parser/
โ โโโ ast_parser.py
โ โโโ import_resolver.py
โ โโโ graph_builder.py
โ โโโ dynamic_import_detector.py
โ
โโโ analyzer/
โ โโโ cycle_detector.py
โ โโโ dead_code_detector.py
โ โโโ module_analyzer.py
โ โโโ split_suggester.py
โ โโโ visualizer.py
โ
โโโ cli.py
โโโ README.md
๐ฆ Installation
Requirements
- Python 3.7+
- Optional: Graphviz
Install from PyPI:
pip install lpv
Install locally:
pip install -e .
๐ CLI Usage (Using lpv)
Basic:
lpv .
Detect cycles:
lpv . --cycles
ASCII Map:
lpv . --ascii
Graphviz Export:
lpv . --graphviz deps.dot
๐ฅ Complete CLI Command Reference (Using lpv)
Basic Analysis
lpv .
Show Summary
lpv . --summary
Detect Circular Imports
lpv . --cycles
Detect Dead Code
lpv . --dead-code
Detect Dynamic Imports
lpv . --dynamic-imports
ASCII Dependency Map
lpv . --ascii
ASCII Map With Depth Limit
lpv . --ascii --max-depth 4
Oversized Modules (default: 500 lines)
lpv . --oversized 500
Module Split Suggestions
lpv . --suggest-splits
Export Graph as DOT
lpv . --graphviz deps.dot
Export Graph as PNG
lpv . --graphviz deps.png --format png
Exclude Folders (venv, env, dist, buildโฆ)
lpv . --exclude venv env dist build
Full Project Audit
lpv . --cycles --dead-code --dynamic-imports --oversized 500 --suggest-splits --ascii --summary
๐งช Sample Project Demo
lpv tests/sample_project \
--cycles \
--dead-code \
--oversized 150 \
--suggest-splits \
--dynamic-imports \
--ascii \
--summary
Or run:
bash tests/run_sample_demo.sh
๐ Examples
Circular Dependencies
โ ๏ธ CIRCULAR DEPENDENCIES DETECTED:
Cycle 1: a.py โ b.py โ c.py โ a.py
Cycle 2: utils.py โ helpers.py โ utils.py
Oversized Modules
โ ๏ธ OVERSIZED MODULES (> 300 lines):
- parser/ast_parser.py : 450
- analyzer/visualizer.py : 380
- main.py : 320
Split Suggestions
๐ก MODULE SPLIT SUGGESTIONS:
parser/ast_parser.py:
- Suggest splitting by class groups
Reason: Contains 5 unrelated class groups
ASCII Map
lpv . --ascii --max-depth 4
PNG Export
lpv . --graphviz deps.png --format png
๐ Pre-commit Integration
Add this:
repos:
- repo: local
hooks:
- id: dependency-check
name: Check for circular dependencies
entry: lpv
language: system
args: ['.', '--cycles']
pass_filenames: false
always_run: true
โ Algorithms
| Feature | Algorithm |
|---|---|
| Cycle Detection | DFS + recursion stack |
| Dead Code Detection | BFS reachability |
| Graph Builder | Directed adjacency graph |
| Split Suggestions | Heuristic clustering |
โฑ Performance
- Time: O(V + E)
- Space: O(V + E)
- Handles hundreds of files efficiently
โ Limitations
- Dynamic imports detected but not resolved
- Dead code detection is heuristic
- External packages not resolved
- Split suggestions are heuristic
๐ License
Educational use only.
๐ฅ Authors
- Sagar Veeresh Halladakeri โ 251810700276
- Nesar Ravishankar Kavri โ 251810700211
Group 127
โ Required PyProject Configuration
Ensure your pyproject.toml includes:
[project.scripts]
lpv = "cli:main"
This enables the lpv command globally.
Project details
Release history Release notifications | RSS feed
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 local_package_visualizer-0.1.3.tar.gz.
File metadata
- Download URL: local_package_visualizer-0.1.3.tar.gz
- Upload date:
- Size: 20.0 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
a5cd76da817264a440dc90cadd8bc397faa08b8e4a2268a49a17d29ecd5ef095
|
|
| MD5 |
b52d8198da379bb22009421003bad725
|
|
| BLAKE2b-256 |
dfe2e4b03db66748e32b9d4da7a0e9b54101cf41964ec82e866b8cc56952c715
|
File details
Details for the file local_package_visualizer-0.1.3-py3-none-any.whl.
File metadata
- Download URL: local_package_visualizer-0.1.3-py3-none-any.whl
- Upload date:
- Size: 24.0 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
f507223dbcbeb8d5420c82801d8aec226d2ed4adbf61aadf3b3d4079acc5189e
|
|
| MD5 |
de25ae499b45531cda66ad466fdd3f4c
|
|
| BLAKE2b-256 |
8abd9c4b5d10ccd1de8e3cb826919ce9901ef692d8a9a4a1aea90e87d227a343
|