Skip to main content

A lightweight Python dependency analyzer

Project description

DigDep

Version License Status Open Source GitHub issues Last Commit

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.


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

digdep-0.0.4.tar.gz (10.0 kB view details)

Uploaded Source

Built Distribution

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

digdep-0.0.4-py3-none-any.whl (12.0 kB view details)

Uploaded Python 3

File details

Details for the file digdep-0.0.4.tar.gz.

File metadata

  • Download URL: digdep-0.0.4.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

Hashes for digdep-0.0.4.tar.gz
Algorithm Hash digest
SHA256 e08859558e61c68c0bc495ad0e44bb156c5fb9dedae93137c996590f029df61a
MD5 1c62085a848d94ff7865f899b6cb8300
BLAKE2b-256 0e583d3330267578980725c9601f80fb436d054e5103bf3501d43db0aedb890d

See more details on using hashes here.

File details

Details for the file digdep-0.0.4-py3-none-any.whl.

File metadata

  • Download URL: digdep-0.0.4-py3-none-any.whl
  • Upload date:
  • Size: 12.0 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/7.0.0 CPython/3.11.9

File hashes

Hashes for digdep-0.0.4-py3-none-any.whl
Algorithm Hash digest
SHA256 216cdc2c9cae825dc80850930094be6230be5d3415de38d53e96a67221c58bb1
MD5 62d415940af98ffa8119c98632bbfc3c
BLAKE2b-256 2bebbba28bdd55081bd509c22a38cb13afab14c25fa8b59458525e27cec8c726

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