Know the cost of your imports - Audit your dependencies before you commit
Project description
pip-weigh 📦⚖️
"Know the cost of your imports."
A CLI tool that measures the true disk size of Python packages, including all their dependencies. Perfect for optimizing Docker images, Lambda functions, and understanding your dependency footprint.
Features
- 🔍 Accurate Size Analysis - Measures the real disk footprint of packages and all dependencies
- 🌐 Cross-Platform Analysis - Check Linux package sizes from macOS/Windows (great for Docker planning)
- 🐍 Python Version Support - Analyze sizes across different Python versions
- 📊 Beautiful Output - Rich terminal output with dependency trees
- 🔄 CI/CD Ready - JSON output and budget checks for pipelines
- ⚡ Fast - Leverages uv's speed and caching
Installation
pip install pip-weigh
Or with uv:
uv pip install pip-weigh
Requirements
- Python 3.9+
- uv must be installed and available in PATH
Usage
Basic Usage
pip-weigh pandas
Output:
Package: pandas (2.1.4)
├── Total Size: 138 MB
├── Self Size: 45 MB
└── Dependencies (Recursive):
├── numpy (1.26.2): 85 MB
├── pytz (2023.3): 5 MB
└── python-dateutil: 3 MB
Cross-Platform Analysis
Check what the size would be on Linux (great for Docker):
pip-weigh torch --platform linux
Multiple Packages
pip-weigh pandas numpy requests
JSON Output (for CI/CD)
pip-weigh pandas --json
Budget Check
Fail if package exceeds a size limit:
pip-weigh pandas --budget 100MB
# Exit code 1 if exceeded
Specify Python Version
pip-weigh pandas --python 3.12
CLI Options
| Option | Short | Description |
|---|---|---|
--platform |
-p |
Target platform (linux, macos, windows) |
--python |
Python version to analyze (e.g., 3.11) | |
--json |
-j |
Output as JSON |
--budget |
-b |
Maximum allowed size (e.g., 100MB, 1GB) |
--no-deps |
Show only the package itself, not dependencies | |
--verbose |
-v |
Show detailed output |
--help |
-h |
Show help message |
How It Works
- Creates a temporary isolated environment using uv
- Installs the target package(s) with all dependencies
- Parses
uv.lockto get the complete dependency tree - Scans
.dist-info/RECORDfiles for accurate file-to-package mapping - Calculates logical sizes (important for Docker/Lambda accuracy)
- Presents results with a beautiful dependency tree
Why Logical Size Matters
uv uses hardlinks from a global cache, so disk usage tools might show misleading numbers. pip-weigh always reports the logical size - the actual bytes your package would consume in a Docker image or cloud function.
License
MIT
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 pip_weigh-0.1.0.tar.gz.
File metadata
- Download URL: pip_weigh-0.1.0.tar.gz
- Upload date:
- Size: 9.9 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.13.0
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
f4e70117cf2b2fe6ecd6897ffa0162fa701eed4d1f24b4790ef9585af791843d
|
|
| MD5 |
0ab6f34588e663fcbc198a5b85f1b8ca
|
|
| BLAKE2b-256 |
d867cde91e76c141e8f8ae549acc84222236dc34fe22eccb93abd808249999e9
|
File details
Details for the file pip_weigh-0.1.0-py3-none-any.whl.
File metadata
- Download URL: pip_weigh-0.1.0-py3-none-any.whl
- Upload date:
- Size: 11.5 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.13.0
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
d17680b9b7b201b1137720c06814cb3f1f36606385e5d7871ebc36d16b22d9fe
|
|
| MD5 |
ffc18a410dc5e5401c57c0346df88c38
|
|
| BLAKE2b-256 |
c047f75282a12081ffb68efb9706beb69005e8ebd484e59a82b9add9cc34226c
|