Clean and shrink Python projects by removing junk files and packaging them efficiently
Project description
PyShrink - Python Project Cleaner & Packager
🚀 PyShrink is a command-line tool that helps you clean, shrink, and package Python projects by removing unnecessary files and creating distributable ZIP archives.
Perfect for sharing projects in enterprise environments where you need clean, minimal code packages without Git repositories or development artifacts.
✨ Features
- 🧹 Smart Cleanup: Removes
__pycache__,.pyc,.pytest_cache,.git, virtual environments, and other junk files - 📦 Auto-Packaging: Creates timestamped ZIP files of cleaned projects
- 📝 README Generation: Optionally creates README.md with project structure
- 📋 Requirements Detection: Automatically generates or validates requirements.txt
- 🎨 Rich CLI: Beautiful terminal output with colors and progress indicators
- 🔒 Safe Operation: Always works on a copy - original project stays untouched
- ⚡ Multiple Modes: Interactive, automated, or full cleanup modes
📦 Installation
From PyPI (Recommended)
pip install pyshrink
From Source
git clone https://github.com/yourusername/pyshrink.git
cd pyshrink
pip install -e .
🚀 Quick Start
Interactive Mode (Recommended for first-time users)
pyshrink
You'll be prompted to:
- Enter the project path
- Choose whether to create/validate requirements.txt
- Choose whether to create README.md
Specify Project Path
pyshrink --path /path/to/your/project
Auto-create README and Requirements
pyshrink --path /path/to/your/project --readme --req
Full Cleanup (No README, No Requirements)
pyshrink --path /path/to/your/project --full
📖 Usage Examples
Example 1: Clean Current Directory Interactively
cd my-python-project
pyshrink --path .
Interactive prompts will guide you through the process.
Example 2: Quick Cleanup with All Options
pyshrink --path ./my-project --readme --req
This will:
- Create a copy of your project
- Generate/validate requirements.txt
- Create README.md if missing
- Remove all junk files
- Create a ZIP file with timestamp
Example 3: Minimal Package (No Docs)
pyshrink --path ./my-project --full
This creates the smallest possible package - no README, no requirements, just clean code.
🎯 What Gets Removed?
PyShrink removes common Python development artifacts:
Files Removed:
*.pyc- Python bytecode*.pyo- Optimized bytecode*.pyd- Python DLL.DS_Store- macOS metadataThumbs.db- Windows thumbnails*.log- Log files*.tmp,*.temp- Temporary files
Directories Removed:
__pycache__/- Python cache.pytest_cache/- Pytest cache.mypy_cache/- MyPy cache.git/- Git repository.venv/,venv/,env/- Virtual environments*.egg-info/- Package metadatabuild/,dist/- Build artifactsnode_modules/- Node.js packages (if present)
📋 Command-Line Options
usage: pyshrink [-h] [--path PATH] [--req] [--readme] [--full]
Clean and package Python projects
options:
-h, --help show this help message and exit
--path PATH Path to the Python project to clean
--req Automatically create/validate requirements.txt
--readme Automatically create README.md if missing
--full Full cleanup (no README, no requirements)
🔧 How It Works
-
Creates a Safe Copy: PyShrink copies your project to a new directory with a timestamp (e.g.,
myproject_pyshrink_20240207_143022) -
Optional README: Generates a basic README.md with project structure if requested
-
Optional Requirements: Scans your code for imports and creates requirements.txt if requested
-
Deep Cleanup: Recursively removes all junk files and directories
-
Creates ZIP: Packages everything into a clean ZIP file
-
Original Untouched: Your original project directory remains completely unchanged
📂 Output Structure
After running PyShrink, you'll get:
/path/to/project/ # Your original (unchanged)
/path/to/project_pyshrink_TIMESTAMP/ # Clean working copy
/path/to/project_pyshrink_TIMESTAMP.zip # Final package
🎨 Rich CLI Interface
PyShrink uses the Rich library for beautiful terminal output:
- ✅ Colored success messages
- ❌ Clear error messages
- ⚠️ Helpful warnings
- 📊 Clean progress indicators
- 🎨 Syntax highlighting
🔍 Requirements Detection
When you use --req, PyShrink:
- Scans all
.pyfiles in your project - Extracts
importandfrom X importstatements - Filters out standard library modules
- Creates
requirements.txtwith detected packages - Warns about packages it couldn't determine versions for
⚙️ VS Code Extension
PyShrink also has a VS Code Extension that provides:
- 🎯 Command Palette integration
- 📁 Automatic workspace detection
- 🖥️ Interactive terminal execution
- ⚡ Quick access to all PyShrink modes
Install from VS Code Marketplace: Search for "PyShrink"
🤝 Contributing
Contributions are welcome! Here's how you can help:
- Fork the repository
- Create a feature branch (
git checkout -b feature/amazing-feature) - Commit your changes (
git commit -m 'Add amazing feature') - Push to the branch (
git push origin feature/amazing-feature) - Open a Pull Request
📝 License
This project is licensed under the MIT License - see the LICENSE.txt file for details.
🐛 Bug Reports & Feature Requests
Found a bug or have a feature request? Please open an issue on GitHub Issues.
🙏 Acknowledgments
- Built with Rich for beautiful terminal output
- Inspired by the need for clean code sharing in enterprise environments
📊 Project Stats
- Language: Python 3.7+
- Dependencies: Rich (for CLI)
- License: MIT
- Status: Active Development
Enjoy using PyShrink! 🚀
Made with ❤️ for Python developers who value clean code
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 pyshrink-1.0.0.tar.gz.
File metadata
- Download URL: pyshrink-1.0.0.tar.gz
- Upload date:
- Size: 19.9 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.12.0
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
5f44b2625eb0d3c5abdf144929b7e596f9a5d48b39ce1a3e23a52f190031a88d
|
|
| MD5 |
ee1d226b5f52993e16989d2dcd24c7fb
|
|
| BLAKE2b-256 |
2225066457a1c7b6269d88e05e73f574a6857f590e0405b3fc35aeb593871311
|
File details
Details for the file pyshrink-1.0.0-py3-none-any.whl.
File metadata
- Download URL: pyshrink-1.0.0-py3-none-any.whl
- Upload date:
- Size: 15.9 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.12.0
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
2969e39651cce666eb81bc69525c16f8888b7f8d88d40145f1ad5a544b214d22
|
|
| MD5 |
92a872dbff8566ec01d24cca0030ad8c
|
|
| BLAKE2b-256 |
0c81f849fd13aa11f55abe59c6fff0b4342a788758bafb0edea356a61e7098f3
|