Pybroom is a command-line tool written in Rust for cleaning up Python bytecode files and directories, including __pycache__ directories and standalone .pyc and .pyo files.
Pybroom provides a simple, fast and efficient way to remove unnecessary Python bytecode files and directories from your project. It helps keep your project directories clean and organized by removing clutter generated during Python development. It can be employed, for instance, within a Git post-checkout hook, to mitigate conflicts during development.
- Recursively scans for
__pycache__directories and removes them entirely - Finds and removes standalone
.pycand.pyobytecode files throughout the directory tree - Skip confirmation flag (
-s,--skip-confirmation) to remove files/directories without confirmation - Verbose flag (
-v,--verbose) to display detailed information about the cleaning process - Cross-platform support for Windows, macOS, and Linux
- Rust compiler (https://www.rust-lang.org/tools/install)
To install Pybroom, run the following command inside the project directory:
cargo install --path .Usage: pybroom [OPTIONS] <DIRECTORY>
Arguments:
<DIRECTORY> Directory to start searching
Options:
-s, --skip-confirmation Skip confirmation
-v, --verbose Verbose mode
-h, --help Print help
-V, --version Print version
Run pybroom . to clean the current directory. To clean another directory provide a path like this: pybroom my/path.
Pybroom will:
- Remove all
__pycache__directories and their contents - Remove standalone
.pycand.pyofiles found anywhere in the directory tree - Preserve all
.pysource files and other non-bytecode files
By default, Pybroom will ask for confirmation before removing files. Use the -s or --skip-confirmation flag to skip this prompt.
For more options, run pybroom --help.
Pybroom is licensed under the MIT License.
Pybroom was inspired by pyclean (https://github.com/bittner/pyclean)