Skip to main content

A Python dependency tree analyzer with rich terminal output

Project description

PyDepTree

PyPI version Python Support License: MIT

A powerful Python dependency analyzer that visualizes module dependencies in your Python projects as a beautiful tree structure. Built with Rich for colorful terminal output.

PyDepTree Enhanced Demo

๐Ÿ“ธ Alternative Demo (Click to expand)

Enhanced Output

โœจ Enhanced CLI Demo: The screenshot above shows PyDepTree's enhanced features including color-coded file types, file statistics, lint detection, and summary tables.

Features

Core Features

  • ๐ŸŽฏ Smart Import Detection: Uses AST parsing to accurately find all imports
  • ๐ŸŒณ Beautiful Tree Visualization: Rich-powered colorful dependency trees
  • ๐Ÿ” Configurable Depth: Control how deep to analyze dependencies
  • ๐Ÿš€ Fast & Efficient: Skips standard library and external packages
  • ๐ŸŽจ Import Preview: See actual import statements with --show-code
  • ๐Ÿ“Š Progress Tracking: Real-time progress for large codebases
  • ๐Ÿ”„ Circular Dependency Detection: Identifies and handles circular imports

Enhanced Features โœจ

  • ๐ŸŽจ Color-coded File Types: Models (๐Ÿ“Š), Services (๐ŸŒ), Utils (๐Ÿ”ง), Tests (๐Ÿงช), Main (๐Ÿš€)
  • ๐Ÿ“ˆ File Statistics: Size, line count, and import count badges for each file
  • ๐Ÿ” Lint Integration: Automatic error/warning detection using ruff (when available)
  • ๐Ÿ“Š Summary Tables: Aggregate statistics by file type with quality metrics
  • ๐ŸŽฏ Enhanced Visualization: Rich terminal output with progress indicators and legends

Advanced Features ๐Ÿš€ (v0.3.0+)

  • ๐Ÿ”Ž Search/Grep Integration: Search for classes, functions, imports, or any text pattern
  • ๐Ÿ“ Complexity Metrics: Cyclomatic complexity analysis with visual indicators
  • ๐Ÿ“Œ TODO/FIXME Detection: Automatically finds and displays TODO comments
  • ๐Ÿ—๏ธ Code Structure Metrics: Function and class counts per file
  • ๐Ÿ”„ Git Integration: Shows file modification status in version control
  • ๐Ÿ“„ Requirements Generation: Automatically generate requirements.txt from detected dependencies

Installation

Using pip

pip install pydeptree

Using pipx (recommended)

pipx install pydeptree

From source

git clone https://github.com/tfaucheux/pydeptree.git
cd pydeptree
pip install -e .

Enhanced Features Installation

For lint checking capabilities, install with enhanced dependencies:

pip install -e ".[enhanced]"

This installs ruff for code quality analysis.

Usage

Basic Usage

Analyze a Python file and see its direct dependencies:

pydeptree myapp.py

Enhanced Usage

Use the enhanced CLI for additional features:

pydeptree-enhanced myapp.py --depth 2

The enhanced version provides color-coded file types, lint checking, and detailed statistics.

Advanced Usage (v0.3.0+)

Use the advanced CLI for search, complexity analysis, and more:

pydeptree-advanced myapp.py --search "APIClient" --search-type class

The advanced version includes all enhanced features plus search capabilities, complexity metrics, TODO detection, and git integration.

Advanced Options

# Analyze dependencies up to 3 levels deep
pydeptree myapp.py --depth 3

# Show import statements from each file  
pydeptree myapp.py --show-code

# Specify a custom project root
pydeptree myapp.py --project-root /path/to/project

Enhanced CLI Example Output

python -m pydeptree.cli_enhanced sample_project/main.py --depth 2
โ•ญโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€ Analysis Settings โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ•ฎ
โ”‚ Enhanced Python Dependency Analyzer โ”‚
โ”‚                                     โ”‚
โ”‚ File: sample_project/main.py        โ”‚
โ”‚ Project root: sample_project        โ”‚
โ”‚ Max depth: 2                        โ”‚
โ”‚ Lint checking: enabled              โ”‚
โ•ฐโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ•ฏ

Legend:
๐Ÿ“Š Models | ๐ŸŒ Services | ๐Ÿ”ง Utils | ๐Ÿงช Tests | ๐Ÿš€ Main | Size | Lines | 
Importsโ†“ | E:Errors | W:Warnings

โ•ญโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€ Dependency Tree โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ•ฎ
โ”‚ ๐Ÿš€ main.py 741B 31L 2โ†“ W:5                          โ”‚
โ”‚ โ”œโ”€โ”€ ๐ŸŒ services/api.py 2.1KB 71L 5โ†“ W:13            โ”‚
โ”‚ โ”‚   โ”œโ”€โ”€ ๐Ÿ“Š models/response.py 1.4KB 54L 3โ†“ W:5      โ”‚
โ”‚ โ”‚   โ””โ”€โ”€ ๐Ÿ”ง utils/http.py 1.8KB 55L 3โ†“ E:2 W:14      โ”‚
โ”‚ โ””โ”€โ”€ ๐Ÿ”ง utils/config.py 1.4KB 53L 5โ†“ W:13            โ”‚
โ”‚     โ”œโ”€โ”€ ๐Ÿ“Š models/settings.py 1.1KB 47L 2โ†“ W:4      โ”‚
โ”‚     โ””โ”€โ”€ ๐Ÿ”ง utils/validators.py 1.0KB 39L 2โ†“ E:1 W:3 โ”‚
โ•ฐโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ•ฏ

                      File Statistics Summary                       
โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”ณโ”โ”โ”โ”โ”โ”โ”โ”ณโ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”ณโ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”ณโ”โ”โ”โ”โ”โ”โ”โ”โ”ณโ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”“
โ”ƒ Type       โ”ƒ Count โ”ƒ Total Lines โ”ƒ Avg Lines โ”ƒ Errors โ”ƒ Warnings โ”ƒ
โ”กโ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ•‡โ”โ”โ”โ”โ”โ”โ”โ•‡โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ•‡โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ•‡โ”โ”โ”โ”โ”โ”โ”โ”โ•‡โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”ฉ
โ”‚ ๐Ÿš€ main    โ”‚     1 โ”‚          31 โ”‚        31 โ”‚      - โ”‚        5 โ”‚
โ”‚ ๐Ÿ“Š model   โ”‚     2 โ”‚         101 โ”‚        50 โ”‚      - โ”‚        9 โ”‚
โ”‚ ๐ŸŒ service โ”‚     1 โ”‚          71 โ”‚        71 โ”‚      - โ”‚       13 โ”‚
โ”‚ ๐Ÿ”ง utils   โ”‚     3 โ”‚         147 โ”‚        49 โ”‚      3 โ”‚       30 โ”‚
โ”œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ผโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ผโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ผโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ผโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ผโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ค
โ”‚ Total      โ”‚     7 โ”‚         350 โ”‚        50 โ”‚      3 โ”‚       57 โ”‚
โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ดโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ดโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ดโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ดโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ดโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜

Advanced CLI Example Output

python -m pydeptree.cli_advanced sample_project/main.py --depth 2 --search "validate" --search-type function
โ•ญโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€ Analysis Settings โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ•ฎ
โ”‚ Advanced Python Dependency Analyzer                                          โ”‚
โ”‚                                                                              โ”‚
โ”‚ File: sample_project/main.py                                                 โ”‚
โ”‚ Project root: sample_project                                                 โ”‚
โ”‚ Max depth: 2                                                                 โ”‚
โ”‚ Lint checking: enabled                                                       โ”‚
โ”‚ Git status: enabled                                                          โ”‚
โ”‚ Search: validate (type: function)                                            โ”‚
โ•ฐโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ•ฏ

Legend:
๐Ÿ“Š Models | ๐ŸŒ Services | ๐Ÿ”ง Utils | ๐Ÿงช Tests | ๐Ÿš€ Main | Size | Lines | 
Importsโ†“ | C:Complexity | [Nc/Nf] | E:Errors | W:Warnings | ๐Ÿ“ŒTODOs | ๐Ÿ”:Matches

โ•ญโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€ Dependency Tree โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ•ฎ
โ”‚ ๐Ÿš€ main.py 741B 31L 2โ†“ C:4 [0c/1f] W:5                                       โ”‚
โ”‚ โ”œโ”€โ”€ ๐ŸŒ services/api.py 2.1KB 71L 5โ†“ C:4 [2c/4f] W:13                         โ”‚
โ”‚ โ”‚   โ”œโ”€โ”€ ๐Ÿ“Š models/response.py 1.4KB 54L 3โ†“ C:2 [2c/3f] W:5                   โ”‚
โ”‚ โ”‚   โ””โ”€โ”€ ๐Ÿ”ง utils/http.py 1.8KB 55L 3โ†“ C:6 [2c/5f] E:2 W:14                   โ”‚
โ”‚ โ””โ”€โ”€ ๐Ÿ”ง utils/config.py 1.4KB 53L 5โ†“ C:6 [0c/2f] W:13 ๐Ÿ”1                     โ”‚
โ”‚     โ”œโ”€โ”€   โ””โ”€ Line 27: def validate_config(config: Dict[str, Any]) -> bool:   โ”‚
โ”‚     โ”œโ”€โ”€ ๐Ÿ“Š models/settings.py 1.1KB 47L 2โ†“ C:3 [3c/3f] W:4 ๐Ÿ“Œ1 ๐Ÿ”1           โ”‚
โ”‚     โ”‚   โ””โ”€โ”€   โ””โ”€ Line 44: def validate(self) -> bool:                        โ”‚
โ”‚     โ””โ”€โ”€ ๐Ÿ”ง utils/validators.py 1.0KB 39L 2โ†“ C:6 [0c/4f] E:1 W:3 ๐Ÿ”4          โ”‚
โ”‚         โ”œโ”€โ”€   โ””โ”€ Line 8: def validate_url(url: str) -> bool:                 โ”‚
โ”‚         โ”œโ”€โ”€   โ””โ”€ Line 17: def validate_api_key(api_key: str) -> bool:        โ”‚
โ”‚         โ””โ”€โ”€   โ””โ”€ Line 28: def validate_timeout(timeout: int) -> bool:        โ”‚
โ•ฐโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ•ฏ

Found 7 files with 22 total dependencies

Search Results: Found 6 matches for 'validate'

Quick Start Examples

Basic Usage

# Analyze a Python file with the original CLI
pydeptree myapp.py

# Use the enhanced version with additional features
pydeptree-enhanced myapp.py --depth 2

Enhanced Features Examples

# Disable lint checking
pydeptree-enhanced myapp.py --no-check-lint

# Disable statistics table
pydeptree-enhanced myapp.py --no-show-stats

# Show detailed import statements
pydeptree-enhanced myapp.py --show-code --depth 3

Advanced Features Examples

# Search for a specific class
pydeptree-advanced myapp.py --search "UserModel" --search-type class

# Search for functions containing 'validate'
pydeptree-advanced myapp.py --search "validate" --search-type function --depth 3

# Find all TODO comments
pydeptree-advanced myapp.py --search "TODO|FIXME|HACK" --depth 2

# Minimal output with just file structure
pydeptree-advanced myapp.py --no-show-metrics --no-check-lint --no-show-stats

# Focus on complexity issues
pydeptree-advanced myapp.py --no-show-todos --no-check-git

# Generate requirements.txt from dependencies
pydeptree-advanced myapp.py --generate-requirements --depth 3

# Generate requirements without versions
pydeptree-advanced myapp.py --generate-requirements --no-versions --no-interactive

# Generate requirements to specific file
pydeptree-advanced myapp.py -R -o my-requirements.txt

# Show detailed dependency analysis like johnnydep
pydeptree-advanced myapp.py --generate-requirements --analyze-deps

# Deep dependency analysis
pydeptree-advanced myapp.py --analyze-deps --dep-depth 3

Testing the Enhanced Features

# Run the interactive demo
python demo_enhanced.py

# Try on the sample project (contains intentional lint errors for demo)
pydeptree-enhanced sample_project/main.py --depth 2

# Try the advanced features
pydeptree-advanced sample_project/main.py --search "validate" --search-type function

# Compare all three CLIs
pydeptree sample_project/main.py --depth 2          # Basic
pydeptree-enhanced sample_project/main.py --depth 2  # Enhanced
pydeptree-advanced sample_project/main.py --depth 2  # Advanced

Demo and Sample Project

PyDepTree includes a comprehensive sample project to demonstrate its enhanced features.

โš ๏ธ Note about Sample Project: The sample_project/ directory contains intentional code quality issues (linting errors, warnings, and code smells) to demonstrate the enhanced PyDepTree's lint checking capabilities. These are not bugs but deliberate examples that showcase how the tool can help identify code quality problems in real projects.

The sample project includes realistic examples of:

  • Missing imports and type hints
  • Unused variables
  • Long lines exceeding style guidelines
  • Inefficient code patterns
  • Complex conditions that could be simplified

This allows you to see how PyDepTree Enhanced detects and reports these issues with color-coded badges and summary statistics.

Command Line Options

Basic CLI (pydeptree)

  • FILE_PATH: Path to the Python file to analyze (required)
  • -d, --depth INTEGER: Maximum depth to traverse (default: 1)
  • -r, --project-root PATH: Project root directory (default: file's parent)
  • -c, --show-code: Display import statements from each file
  • --help: Show help message and exit

Enhanced CLI (pydeptree-enhanced)

All basic options plus:

  • -l, --check-lint / --no-check-lint: Enable/disable lint checking (default: enabled)
  • -s, --show-stats / --no-show-stats: Show/hide statistics summary table (default: enabled)

Advanced CLI (pydeptree-advanced)

All enhanced options plus:

  • -S, --search TEXT: Search for text/pattern in files
  • --search-type [text|class|function|import]: Type of search to perform (default: text)
  • --show-todos / --no-show-todos: Show/hide TODO comments (default: enabled)
  • --check-git / --no-check-git: Show/hide git status (default: enabled)
  • --show-metrics / --no-show-metrics: Show/hide inline metrics like size, complexity (default: enabled)
  • -R, --generate-requirements: Generate requirements.txt from detected dependencies
  • -o, --requirements-output PATH: Output path for requirements.txt (default: auto-generated)
  • --no-versions: Generate requirements.txt without version numbers
  • --no-interactive: Don't prompt for confirmation when requirements.txt exists
  • --analyze-deps: Show detailed dependency analysis like johnnydep
  • --dep-depth INTEGER: Maximum depth for dependency analysis (default: 2)

Understanding the Metrics

Inline Metrics (Advanced CLI)

  • Size: File size (B/KB/MB)
  • Lines: Total line count (e.g., 31L)
  • Imports: Number of import statements (e.g., 5โ†“)
  • Complexity: Cyclomatic complexity (e.g., C:12)
    • C:1-5 (green/dim): Simple, easy to test
    • C:6-10 (yellow): Moderate complexity
    • C:11+ (red): High complexity, consider refactoring
  • Structure: Class/function count (e.g., [2c/5f] = 2 classes, 5 functions)
  • Lint Issues:
    • E:n (red): Number of errors
    • W:n (yellow): Number of warnings
  • TODOs: Number of TODO/FIXME comments (e.g., ๐Ÿ“Œ3)
  • Git Status: [M] modified, [A] added, [D] deleted
  • Search Matches: Number of search results (e.g., ๐Ÿ”5)

Summary Table Columns

  • Type: File category with icon
  • Count: Number of files in category
  • Total/Avg Lines: Code volume metrics
  • Functions/Classes: Total count per category
  • Avg Complexity: Average cyclomatic complexity
  • TODOs: Total TODO comments found
  • Errors/Warnings: Lint issue counts
  • Matches: Search result counts (when searching)

Requirements Generation

PyDepTree can automatically generate requirements.txt files from your project's external dependencies:

# Generate requirements.txt with versions
pydeptree-advanced myapp.py --generate-requirements

# Generate without versions
pydeptree-advanced myapp.py --generate-requirements --no-versions

# Specify output file
pydeptree-advanced myapp.py -R -o my-deps.txt

Features:

  • Smart Detection: Automatically identifies external packages (excludes stdlib and project modules)
  • Version Detection: Attempts to detect installed package versions
  • File References: Shows which files use each dependency
  • Safe Naming: Automatically avoids overwriting existing requirements.txt
  • Rich Display: Beautiful table showing dependencies with versions and usage
  • Dependency Tree Analysis: Like johnnydep, shows transitive dependencies with descriptions
  • Package Summaries: Displays what each package does

Basic Example Output:

Found 2 external dependencies:
โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”ณโ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”ณโ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”“
โ”ƒ Package  โ”ƒ Version   โ”ƒ Used In             โ”ƒ
โ”กโ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ•‡โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ•‡โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”ฉ
โ”‚ requests โ”‚ 2.32.4    โ”‚ http.py             โ”‚
โ”‚ yaml     โ”‚ Not found โ”‚ config.py           โ”‚
โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ดโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ดโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜

โœ“ Requirements file written to: requirements_1.txt

Enhanced Dependency Analysis (--analyze-deps):

Package Dependency Analysis:
๐Ÿ“ฆ Dependencies
โ”œโ”€โ”€ requests (2.32.4)
โ”‚   โ”œโ”€โ”€ Python HTTP for Humans.
โ”‚   โ”œโ”€โ”€ certifi (2025.7.14)
โ”‚   โ”‚   โ””โ”€โ”€ Python package for providing Mozilla's CA Bundle.
โ”‚   โ”œโ”€โ”€ charset_normalizer (3.4.2)
โ”‚   โ”‚   โ””โ”€โ”€ The Real First Universal Charset Detector.
โ”‚   โ”œโ”€โ”€ idna (3.10)
โ”‚   โ”‚   โ””โ”€โ”€ Internationalized Domain Names in Applications (IDNA)
โ”‚   โ””โ”€โ”€ urllib3 (2.5.0)
โ”‚       โ””โ”€โ”€ HTTP library with thread-safe connection pooling.
โ””โ”€โ”€ yaml (not installed)

Package Summary:
 Package                     Summary                                            
 certifi (2025.7.14)        Python package for providing Mozilla's CA Bundle.  
 charset_normalizer (3.4.2) The Real First Universal Charset Detector...       
 idna (3.10)                Internationalized Domain Names in Applications     
 requests (2.32.4)          Python HTTP for Humans.                            
 urllib3 (2.5.0)            HTTP library with thread-safe connection pooling.  
 yaml (not installed)       No description available                           

โœ“ Requirements file written to: requirements_1.txt

How It Works

PyDepTree uses Python's built-in AST (Abstract Syntax Tree) module to parse Python files and extract import statements. It then:

  1. Identifies which imports are part of your project (vs external libraries)
  2. Recursively analyzes imported modules up to the specified depth
  3. Builds a dependency graph while detecting circular imports
  4. Renders a beautiful tree visualization using Rich

The Advanced CLI adds: 5. AST-based complexity analysis and code structure metrics 6. Pattern matching for search functionality 7. Git integration for version control awareness 8. Comment parsing for TODO detection

Development

Setup Development Environment

# Clone the repository
git clone https://github.com/tfaucheux/pydeptree.git
cd pydeptree

# Create virtual environment
python -m venv venv
source venv/bin/activate  # On Windows: venv\Scripts\activate

# Install in development mode with dev dependencies
pip install -e ".[dev]"

Running Tests

# Run all tests (33 tests total: 5 basic + 28 enhanced)
pytest

# Run with coverage report (should show ~85% coverage)
pytest --cov=pydeptree --cov-report=term-missing

# Run only enhanced CLI tests
pytest tests/test_cli_enhanced.py

# Run linting (Note: sample_project/ contains intentional errors for demo purposes)
ruff check pydeptree/  # Check only the main package code (clean)
ruff check .           # Check everything (will show demo errors)
black --check .
mypy pydeptree

Note: The sample_project/ directory contains intentional linting errors for demonstration purposes. When running linting tools on the entire project, you'll see these demo errors alongside any real issues in the main codebase.

Building for Distribution

# Install build tools
pip install build twine

# Build distribution packages
python -m build

# Upload to TestPyPI (for testing)
twine upload --repository testpypi dist/*

# Upload to PyPI (for release)
twine upload dist/*

Contributing

Contributions are welcome! Please feel free to submit a Pull Request. For major changes, please open an issue first to discuss what you would like to change.

  1. Fork the repository
  2. Create your feature branch (git checkout -b feature/AmazingFeature)
  3. Commit your changes (git commit -m 'Add some AmazingFeature')
  4. Push to the branch (git push origin feature/AmazingFeature)
  5. Open a Pull Request

License

This project is licensed under the MIT License - see the LICENSE file for details.

Acknowledgments

  • Built with Click for CLI
  • Beautiful output powered by Rich
  • Inspired by various dependency analysis tools in the Python ecosystem

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

pydeptree-0.3.0.tar.gz (35.6 kB view details)

Uploaded Source

Built Distribution

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

pydeptree-0.3.0-py3-none-any.whl (29.3 kB view details)

Uploaded Python 3

File details

Details for the file pydeptree-0.3.0.tar.gz.

File metadata

  • Download URL: pydeptree-0.3.0.tar.gz
  • Upload date:
  • Size: 35.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.13.5

File hashes

Hashes for pydeptree-0.3.0.tar.gz
Algorithm Hash digest
SHA256 231bd722f4df4c0ec5ef51e49c7b65e83c10c258ac4d24f30f974e50b2409623
MD5 dc764b9bb2291a0de1eb488ac5d0e9ce
BLAKE2b-256 5528e80b88d09b7626879a305ebc37c24c3ec7fda5e9fbecab1315c9766cc365

See more details on using hashes here.

File details

Details for the file pydeptree-0.3.0-py3-none-any.whl.

File metadata

  • Download URL: pydeptree-0.3.0-py3-none-any.whl
  • Upload date:
  • Size: 29.3 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.13.5

File hashes

Hashes for pydeptree-0.3.0-py3-none-any.whl
Algorithm Hash digest
SHA256 6fa602d711500670f10525d5a79c04e9552282b9810e0e42da4beb4c766f114f
MD5 06d8187594bfa44772e7ae0d24524673
BLAKE2b-256 2eb861ecc07aed3a6806a4b0635d9f3b622acab43faf4807c0160c153767717b

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