Skip to main content

Dependency Shake: Analyze actual package usage in your Python codebase.

Project description

DShake

DShake is a tool to introspect, unfold, and analyze internal and external dependencies in a Python project—especially when managing large monorepos, private packages, and organizational Python distributions.

🚨 Problem Statement

Managing code and dependencies in large organizations often leads to the following issues:

1. Organizational Dependency Management

Organizations often publish internal packages (e.g., my-company-core, my-company-ml) to private repositories or internal PyPI registries. Over time:

  • It becomes unclear which internal packages are truly used.
  • Shared utilities are copied across services instead of being reused properly.
  • External dependencies may duplicate internal functionality unknowingly.
  • No tooling exists to visualize internal usage vs. third-party dependencies.

2. Project Domain Import Management

In a Python project:

  • Imports like from my_company.core.utils import X can be hard to trace—where do they come from?
  • Relative imports, internal utilities, and third-party modules get mixed up.
  • You want to analyze how your project relies on specific internal / external packages, and which of them are leaf vs core dependencies.

🧰 Usages

CLI Command Structure

dshake analyze [OPTIONS]
dshake analyze \
  --src-dir src \
  --namespace my-company \
  --output used_packages.json \
  [--format json|text]

Python Package API

from dshake.package import analyze_package_usages
from dshake.dependency import get_dependency_tree
from dshake.module_import import get_import_tree

🧩 Key Features

  • Build import trees from Python files using AST traversal.
  • Differentiate internal (to_unfold=True) vs. external imports based on namespace (e.g., my-company).
  • Parse Poetry’s show --tree output, capturing hierarchical dependency chains.
  • Correlate import usage with installed packages to surface only those used in practice.
  • Detect internal packages in use, separate from third-party dependencies.

📌 Why This Matters

  • ✅ Helps de-risk code audits, refactorings, and security scans.
  • 📉 Can drive dependency slimming (e.g., removing unused packages).
  • 💡 Surfaces duplicated functionality between internal and external libraries.
  • 📊 Builds a foundation for automated graph-based tooling on import relationships.

🧠 Credits

Built by an engineer who got tired of guessing where my-company-utils was coming from. Inspired by the lack of ecosystem tools that combine AST, package metadata, and visual dependency resolution.

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

dshake-0.1.0.tar.gz (12.2 kB view details)

Uploaded Source

Built Distribution

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

dshake-0.1.0-py3-none-any.whl (10.3 kB view details)

Uploaded Python 3

File details

Details for the file dshake-0.1.0.tar.gz.

File metadata

  • Download URL: dshake-0.1.0.tar.gz
  • Upload date:
  • Size: 12.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.12.9

File hashes

Hashes for dshake-0.1.0.tar.gz
Algorithm Hash digest
SHA256 c59cac3145809eb140dbe676f773faeba191bb342be1abede14f53841c375413
MD5 adaeced0ac683d080d174706dac903c3
BLAKE2b-256 64b6342295d06040ba75d130a06470b3a930c7a2f6fc943d72cc6f62621f0a9c

See more details on using hashes here.

Provenance

The following attestation bundles were made for dshake-0.1.0.tar.gz:

Publisher: pypi-publish.yml on donin1129/dependency-shaking

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file dshake-0.1.0-py3-none-any.whl.

File metadata

  • Download URL: dshake-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 10.3 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.12.9

File hashes

Hashes for dshake-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 942d7cbaed9cd24dfb37f54a3db721523d262e399a48efa7794253b37f8eda87
MD5 cc470664a6b051b6c1bb30e7c47b7471
BLAKE2b-256 cbd79ecca76bd219efb3c92baf7f320972c2fde730ff392e929710aa27543778

See more details on using hashes here.

Provenance

The following attestation bundles were made for dshake-0.1.0-py3-none-any.whl:

Publisher: pypi-publish.yml on donin1129/dependency-shaking

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

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