Skip to main content

pip-weigh

Tests PyPI version Python versions License: MIT

"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
  • 📁 Local Project Analysis - Weigh everything your own pyproject.toml pulls in
  • 🌐 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:

📦 pandas (2.1.4)
├── Total Size: 138 MB
├── Self Size: 45 MB
├── Platform: linux
├── Python: 3.12
└── Dependencies (3):
    ├── numpy (1.26.2): 85 MB
    ├── pytz (2023.3): 5 MB
    └── python-dateutil (2.8.2): 3 MB

Analyzing a Local Project

Point pip-weigh at your own project to weigh everything its pyproject.toml pulls in:

pip-weigh .                       # current directory
pip-weigh ./services/api          # any directory with a pyproject.toml
pip-weigh path/to/pyproject.toml  # the file itself
pip-weigh requirements.txt        # a requirements file

If the project has a uv.lock, pip-weigh measures the locked versions, so the number matches what you will actually ship. Pass --no-lock to re-resolve the declared specifiers instead.

Optional extras and PEP 735 dependency groups are excluded by default — dev tooling shouldn't count against your image budget — and can be opted into:

pip-weigh . --extra api --extra worker
pip-weigh . --group test
pip-weigh . --dev

Your project is never modified: no .venv is created in it, no lockfile is written, and the project's own code is not installed. Only its dependency closure is measured.

This makes a neat CI gate:

pip-weigh . --platform linux --budget 250MB

Note: a bare name is always treated as a PyPI package. Write ./rich (not rich) if you mean a local directory of that name.

Cross-Platform Analysis

Check what the size would be on Linux (great for Docker):

pip-weigh torch --platform linux

Accepts linux, macos, windows, or a full target triple such as x86_64-manylinux_2_28 or aarch64-apple-darwin.

Multiple Packages

pip-weigh pandas numpy requests

Each package is measured in isolation, and pip-weigh additionally installs them together to report the deduplicated footprint — shared dependencies are counted once, so the combined total is smaller than the sum of the rows. Skip that extra pass with --no-combined.

Seeing Every Dependency

The tree lists the 15 largest dependencies by default. To see them all:

pip-weigh pandas --limit 0    # no limit
pip-weigh pandas --limit 40   # a specific cap
pip-weigh pandas -v           # verbose implies no limit

--json always includes every dependency regardless of --limit.

JSON Output (for CI/CD)

pip-weigh pandas --json

Budget Check

Fail if a package or project 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, or a target triple)
--python Python version to analyze (e.g., 3.11)
--json -j Output as JSON
--budget -b Maximum allowed size (e.g., 100MB, 1GB)
--limit -l Max dependencies to list (default 15; 0 for all)
--no-deps Show only the package itself, not dependencies
--extra Project mode: include an optional-dependency extra (repeatable)
--group Project mode: include a PEP 735 dependency group (repeatable)
--dev Project mode: include the dev dependency group
--no-lock Project mode: re-resolve instead of using uv.lock
--no-combined Skip the deduplicated total for multiple packages
--verbose -v Show detailed output, including every dependency
--check Check that uv is installed
--version Show version
--help -h Show help message

How It Works

  1. Creates a temporary isolated environment using uv
  2. Installs the target package(s) with all dependencies, honoring --python-platform so cross-platform estimates use the right wheels
  3. Reads the installed .dist-info directories to get the exact resolved set
  4. Scans .dist-info/RECORD files for accurate file-to-package mapping
  5. Calculates logical sizes (important for Docker/Lambda accuracy)
  6. 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

Metadata

Release files for pip-weigh 0.2.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for pip-weigh 0.2.0
File Size Uploaded Provenance
pip_weigh-0.2.0.tar.gz 19.0 kB With provenance Details

Built distribution (wheel)

Table of built distributions (wheels) for pip-weigh 0.2.0
File Interpreter ABI Platform
pip_weigh-0.2.0-py3-none-any.whl Python 3 none any Details

Total release size: 37.8 kB

Release files / pip_weigh-0.2.0.tar.gz

Download URL pip_weigh-0.2.0.tar.gz
Size 19.0 kB
Tags Source
SHA-256 checksum
How to use checksums
fbe16157a5d56b43612f86db6b5e63c4dfa67c02df146de3f0aae466e0debb87
BLAKE2b-256 checksum
How to use checksums
eb1f47bb5b172ab64267790ab6915ef49d38d73d4926a3bf2fe40808dcb85165
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Aug 24, 2026.

Transparency log

Release files / pip_weigh-0.2.0-py3-none-any.whl

Download URL pip_weigh-0.2.0-py3-none-any.whl
Size 18.8 kB
Tags Python 3
SHA-256 checksum
How to use checksums
937d0d79dace5d0b2ffbc04b3b7a1c61aacadb8399d96b0dc39373008e6d81e5
BLAKE2b-256 checksum
How to use checksums
46abc71d52d1bac0f21cde80e4a327b0625a70fda2c69626afdbfc8231080881
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Aug 24, 2026.

Transparency log

Security for pip-weigh 0.2.0

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

Full provenance

All 2 files in this release have been uploaded with provenance metadata.

Select from 2 files

Attestation for pip_weigh-0.2.0.tar.gz

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Aug 24, 2026.

Transparency log

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Release history Release notifications | RSS feed

This release

0.2.0 This release

2 release files Full provenance

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page