Skip to main content

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


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

local_package_visualizer-0.1.2.tar.gz (20.0 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

local_package_visualizer-0.1.2-py3-none-any.whl (24.0 kB view details)

Uploaded Python 3

File details

Details for the file local_package_visualizer-0.1.2.tar.gz.

File metadata

File hashes

Hashes for local_package_visualizer-0.1.2.tar.gz
Algorithm Hash digest
SHA256 900cb5ee94cbeebf59c70c0cf15f8075d235f111d79cb3f0b7870482ab3f7cb4
MD5 42e4b18459d4ea08a4e5a2bd3760596f
BLAKE2b-256 3cfafe351841f6f09f8bdbdc80c5c55ca874d321bea9d9b8fefbcc237a1c15c6

See more details on using hashes here.

File details

Details for the file local_package_visualizer-0.1.2-py3-none-any.whl.

File metadata

File hashes

Hashes for local_package_visualizer-0.1.2-py3-none-any.whl
Algorithm Hash digest
SHA256 7d0a8f09bf4aefb05e03e73d07e39da23e49ff42f3952c5cf31127e341ba4ed7
MD5 9c089b5302d6f127db605e6e16805d68
BLAKE2b-256 cd5b91d84c69397882163a3b7b11e68c6d6b602a7661fdcf97b6017c60f204ee

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page