A tool to analyze and clean unused Python dependencies
Project description
PDC (python-dependency-cleaner)
PDC is a Python library and CLI tool that helps you analyze your Python projects to detect:
- ✅ Used dependencies
- ⚠️ Unused dependencies
- 📦 Package sizes
- 📊 Top-N largest packages
It also supports exporting reports in JSON and CSV formats.
✨ Features
- 🔍 Static analysis of imports using AST
- ⚡ Optional runtime import tracing
- 📑 Detect unused packages listed in
requirements.txt - 📦 Measure installed package sizes
- 📊 Export reports to JSON/CSV
- 🖥️ CLI support for quick usage
- 📈 Show top-N largest packages for optimization
📦 Installation
Install via pip (project name is python-dependency-cleaner):
🔗 PyPI: python-dependency-cleaner
🔗 Github: python-dependency-cleaner
pip install python-dependency-cleaner==0.1.1
Usage
As a library
from pdc import analyze_dependencies, export_json, export_csv, top_n_packages, print_packages
# Analyze a project
in_use, unused = analyze_dependencies(".")
# print in_use
print_packages(in_use, title="✅ In-Use Packages")
# print unused
print_packages(unused, title="⚠️ Unused Packages")
# Export reports
export_json(in_use, unused, filename="report.json")
export_csv(in_use, unused, filename="report.csv")
# Get top n largest packages
n = 5
top_packages = top_n_packages(in_use, unused, n)
print_packages(top_packages, title=f"Top {n} largest packages:")
CLI Usage
# Analyze current directory
pdc .
# Export JSON report
pdc . --json
# Export CSV report
pdc . --csv
# Show top 10 largest packages
pdc . --top 10
Requirements
- Python 3.10+
- Optional: packages in your
requirements.txt
Contributing
- Fork the repository
- Create a feature branch
- Make your changes
- Submit a pull request
License
This project is licensed under the MIT License. See LICENSE for details.
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 python_dependency_cleaner-0.1.1.tar.gz.
File metadata
- Download URL: python_dependency_cleaner-0.1.1.tar.gz
- Upload date:
- Size: 8.5 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.12.3
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
3eb37d631ee7b075c4e4900e95a46625f062a98cd53a8eda15745de1979c9bd2
|
|
| MD5 |
527665a42fd6204fa24c682076c97750
|
|
| BLAKE2b-256 |
1ec245acd8f07333432946ea521f205c7a6117b4bb276cd0e27e1e1f79b08b8e
|
File details
Details for the file python_dependency_cleaner-0.1.1-py3-none-any.whl.
File metadata
- Download URL: python_dependency_cleaner-0.1.1-py3-none-any.whl
- Upload date:
- Size: 8.3 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.12.3
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
a8c5f40a89f0dfd14c50a198d20bee715b6246177b1351facc5626c739516177
|
|
| MD5 |
2fc18007d2259900ac1de605677febca
|
|
| BLAKE2b-256 |
84d82f207c1f26d0039bac312b2553a330077be580e5d42eea08651c7a27c3fe
|