Skip to main content

A Python package to analyze the disk usage of installed packages.

Project description

📦 PkgSize - Python Package Size Analyzer

PkgSize is a CLI tool and Python library for analyzing the disk space usage of installed Python packages, helping you manage your environments efficiently.

Core Features

  • Comprehensive Size Analysis: Displays installed Python packages with their disk usage in human-readable formats (KB, MB, GB).
  • Flexible Sorting: Sort packages by size (default), name, or installation date (feature to be confirmed/added if not present).
  • Targeted Analysis:
    • Analyze packages in the current environment or specify a target virtual environment using --path <venv_path>.
    • Filter by package name (--name), size threshold (--threshold), or focus on packages imported in your project (--project-only <path_to_project>).
  • In-depth Dependency Insights:
    • Use --include-deps to view a breakdown of package sizes including their unique dependencies.
    • The console output shows an indented tree of dependencies with individual sizes.
    • JSON exports include a detailed dependencies_breakdown structure.
  • Detailed File Structure View: Use --tree to explore the internal directory tree and file sizes of each package.
  • Versatile Export Options:
    • Export reports in JSON, CSV, or Markdown formats.
    • Specify an output directory with --output <directory> and format with --format <format>.
    • Console output is automatically suppressed when exporting to a file (unless overridden).
  • Customizable Output:
    • Show only the top N largest packages (--top N).
    • Disable colorized CLI output with --no-color.
    • Minimize output for scripting with --quiet.
  • Environment Comparison: Compare package sizes between two different Python environments (feature to be confirmed/added, e.g., --compare <path_to_other_venv>).

Key CLI Options

The pkgsize analyze command supports various options to customize the analysis:

  • --name <package_name>: Filter results to show only specific packages (can be used multiple times).
  • --top N: Display only the top N largest packages.
  • --threshold SIZE: Filter out packages smaller than a specified size (e.g., 10MB, 1GB).
  • --include-deps: Include the size of dependencies and show a breakdown.
  • --path <venv_path>: Specify the path to a Python virtual environment to analyze its packages instead of the current environment.
  • --project-only <project_path>: (To be implemented/confirmed) Only show packages used in a given .py file or directory.
  • --tree: (To be implemented/confirmed) Show directory tree of package internals and file sizes.
  • --output <directory_path>: Specify a directory to export the report.
  • --format <json|csv|md>: Specify the output format for reports when using --output.
  • --sort <size|name>: Sort packages by size (default) or name. (Add 'date' if implemented)
  • --no-color: Disable CLI coloring.
  • --quiet: Suppress informational messages and console output, useful when only exporting.
  • --version: Display the version of PkgSize.
  • --help: Show the help message and exit.

Installation

pip install pypkgsize

Basic Usage

Analyze packages in the current environment:

pkgsize analyze

Show the top 5 largest packages, including dependencies:

pkgsize analyze --top 5 --include-deps

Analyze packages in a specific virtual environment and export a CSV report:

pkgsize analyze --path /path/to/your/venv --output ./reports --format csv

Export a JSON report of packages larger than 50MB to the my_reports directory:

pkgsize analyze --threshold 50MB --output ./my_reports --format json

Analyze specific packages (e.g., requests and numpy):

pkgsize analyze --name requests --name numpy

Show the top 3 packages sorted by name:

pkgsize analyze --top 3 --sort name

Export a Markdown report of all packages, including dependencies, to the docs directory quietly (no console output):

pkgsize analyze --include-deps --output ./docs --format md --quiet

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

pypkgsize-1.0.1.tar.gz (14.8 kB view details)

Uploaded Source

Built Distribution

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

pypkgsize-1.0.1-py3-none-any.whl (10.7 kB view details)

Uploaded Python 3

File details

Details for the file pypkgsize-1.0.1.tar.gz.

File metadata

  • Download URL: pypkgsize-1.0.1.tar.gz
  • Upload date:
  • Size: 14.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.10.11

File hashes

Hashes for pypkgsize-1.0.1.tar.gz
Algorithm Hash digest
SHA256 60e04c132e13b952bcdfab8a9c38f65f60fde0586f87f2178babb41ce51ea7b8
MD5 ea2decf3d5994976ff42a7d49017d49d
BLAKE2b-256 b46e3b7af86ba32c0a6680b67c997ea165051ad67ab7ac713add17e897fdb523

See more details on using hashes here.

File details

Details for the file pypkgsize-1.0.1-py3-none-any.whl.

File metadata

  • Download URL: pypkgsize-1.0.1-py3-none-any.whl
  • Upload date:
  • Size: 10.7 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.10.11

File hashes

Hashes for pypkgsize-1.0.1-py3-none-any.whl
Algorithm Hash digest
SHA256 b17373f77541496fdb20470fb23d0877045bc6b8d139079ae9e22ec9323d18d5
MD5 6d153dd5dcf202ca808f9fe3f77581ca
BLAKE2b-256 0772b60ce59f9de2e5d13a2b2b49d9e56258ea7e6fc342a903166baa653a4352

See more details on using hashes here.

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