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.1.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.1-py3-none-any.whl (10.4 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: dshake-0.1.1.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.1.tar.gz
Algorithm Hash digest
SHA256 8766e3904eef96a4e54caff26a7844739a7bb69ea92becf42dcc36d9474f4610
MD5 3bb6d3a56fcbd6a337e63cb32190edef
BLAKE2b-256 90467e594788eb959fe15bf775bf1f12432a2e350c61c8367182b33dacecd6df

See more details on using hashes here.

Provenance

The following attestation bundles were made for dshake-0.1.1.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.1-py3-none-any.whl.

File metadata

  • Download URL: dshake-0.1.1-py3-none-any.whl
  • Upload date:
  • Size: 10.4 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.1-py3-none-any.whl
Algorithm Hash digest
SHA256 49e39078ecdf8cc9ded4301a4d0fb253a9816870b195606c41607cd19f3e6e01
MD5 89217e6de6e2bc43280b2e65b50256f3
BLAKE2b-256 7fef3a054e8b3107a1691283b7bdc34f2b0e220bf4595d6ba0a71435d277706e

See more details on using hashes here.

Provenance

The following attestation bundles were made for dshake-0.1.1-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