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 Xcan 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 --treeoutput, 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
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
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
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
8766e3904eef96a4e54caff26a7844739a7bb69ea92becf42dcc36d9474f4610
|
|
| MD5 |
3bb6d3a56fcbd6a337e63cb32190edef
|
|
| BLAKE2b-256 |
90467e594788eb959fe15bf775bf1f12432a2e350c61c8367182b33dacecd6df
|
Provenance
The following attestation bundles were made for dshake-0.1.1.tar.gz:
Publisher:
pypi-publish.yml on donin1129/dependency-shaking
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
dshake-0.1.1.tar.gz -
Subject digest:
8766e3904eef96a4e54caff26a7844739a7bb69ea92becf42dcc36d9474f4610 - Sigstore transparency entry: 307367775
- Sigstore integration time:
-
Permalink:
donin1129/dependency-shaking@87060b7ab5f8aa7ab546dd39f4dc375cef41a25f -
Branch / Tag:
refs/tags/v0.1.1 - Owner: https://github.com/donin1129
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
pypi-publish.yml@87060b7ab5f8aa7ab546dd39f4dc375cef41a25f -
Trigger Event:
push
-
Statement type:
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
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
49e39078ecdf8cc9ded4301a4d0fb253a9816870b195606c41607cd19f3e6e01
|
|
| MD5 |
89217e6de6e2bc43280b2e65b50256f3
|
|
| BLAKE2b-256 |
7fef3a054e8b3107a1691283b7bdc34f2b0e220bf4595d6ba0a71435d277706e
|
Provenance
The following attestation bundles were made for dshake-0.1.1-py3-none-any.whl:
Publisher:
pypi-publish.yml on donin1129/dependency-shaking
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
dshake-0.1.1-py3-none-any.whl -
Subject digest:
49e39078ecdf8cc9ded4301a4d0fb253a9816870b195606c41607cd19f3e6e01 - Sigstore transparency entry: 307367779
- Sigstore integration time:
-
Permalink:
donin1129/dependency-shaking@87060b7ab5f8aa7ab546dd39f4dc375cef41a25f -
Branch / Tag:
refs/tags/v0.1.1 - Owner: https://github.com/donin1129
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
pypi-publish.yml@87060b7ab5f8aa7ab546dd39f4dc375cef41a25f -
Trigger Event:
push
-
Statement type: