Find and delete Python artifacts (venvs, caches, build dirs) from your terminal. The Python equivalent of npkill for node_modules.
Heads up — name is provisional. I didn't realize there were already three other
pypurgeprojects on GitHub when I started this. The name will likely change before any public release; for now it stays aspypurgewhile the project is finding its shape. Suggestions welcome.Aviso — el nombre es provisional. No sabía que ya existían otros tres proyectos llamados
pypurgeen GitHub. Probablemente lo renombre antes de cualquier release público; por ahora se queda así mientras el proyecto se asienta. Sugerencias bienvenidas.
pypurge scans a directory tree (and optional global cache locations) for Python artifacts that take up disk space — virtual environments, type-checker caches, test caches, coverage output, build leftovers — displays them in an interactive TUI, and lets you select which ones to delete.
| Kind | Detected by |
|---|---|
venv |
pyvenv.cfg inside (PEP 405) |
pycache |
__pycache__/ |
mypy |
.mypy_cache/ |
pytest |
.pytest_cache/ |
ruff |
.ruff_cache/ |
tox |
.tox/ |
nox |
.nox/ |
hypothesis |
.hypothesis/ |
benchmarks |
.benchmarks/ |
pyre |
.pyre/ |
pytype |
.pytype/ |
eggs |
.eggs/ |
egg-info |
*.egg-info/ |
htmlcov |
htmlcov/ |
pip-cache |
per-OS global pip cache |
uv-cache |
per-OS global uv cache |
poetry-cache |
per-OS global poetry cache |
pdm-cache |
per-OS global pdm cache |
build/anddist/are intentionally excluded — those names are too ambiguous and may exist in non-Python projects.
Requires uv and Python 3.10+.
# Clone and run
git clone <repo-url> && cd pypurge
uv run pypurge
# Or install globally
uv tool install .Note: global package-manager caches (pip/uv/poetry/pdm) are included by default regardless of
-d. Use--no-globalsto scan only the target directory.
# Scan current directory + global caches (all kinds by default)
pypurge
# Scan a specific directory
pypurge -d C:\dev
# Scan entire home directory
pypurge --full
# Sort by date instead of size
pypurge -s date
# Exclude directory names from the walk
pypurge --exclude vendor --exclude .tox
# Only specific artifact kinds
pypurge --types venv,pycache
# Skip specific kinds
pypurge --exclude-types pycache,htmlcov
# Skip global caches
pypurge --no-globals
# Preview without deleting
pypurge --dry-run| Key | Action |
|---|---|
Space |
Toggle select/deselect current row |
x |
Delete all selected artifacts |
r |
Rescan directory |
s |
Cycle sort order (size / date / path) |
j / Down |
Move cursor down |
k / Up |
Move cursor up |
q |
Quit |
| Option | Description | Default |
|---|---|---|
-d, --directory |
Directory to scan | . (current) |
--full |
Scan home directory | off |
-s, --sort |
Initial sort: size, date, path |
size |
--exclude |
Directory names to skip during the walk (repeatable) | .git, node_modules, .hg, .svn |
--types |
Comma-separated artifact kinds to include (e.g. venv,pycache) |
all |
--exclude-types |
Comma-separated artifact kinds to exclude | none |
--no-globals |
Skip global pip/uv/poetry/pdm caches | off |
--dry-run |
Show what would be deleted without deleting | off |
--version |
Show version | |
--help |
Show help |
- Scan — Walks the directory tree using
os.scandir(fast, non-blocking viaasyncio.to_thread). Detects artifacts by directory name, suffix (.egg-info), orpyvenv.cfg(for venvs). Stops recursing inside detected artifacts. - Globals — Resolves per-OS paths for pip/uv/poetry/pdm caches (Windows
LOCALAPPDATA/APPDATA, LinuxXDG_CACHE_HOME, macOS~/Library/Caches) and adds them up-front. - Display — Results stream into a Textual DataTable as they're found. Shows kind, path, size, Python version (for venvs), and last modified date.
- Select — Mark artifacts for deletion with
Space. The stats bar shows how many are selected and their total size. - Delete — Press
xto delete all selected. Each row shows "Deleting..." during removal and disappears on success. The "Freed" counter updates in real time.
- Refuses to delete the currently active Python environment
- Refuses to delete anything inside system directories (
C:\Windows,/usr, etc.) - Venvs must contain
pyvenv.cfgto be eligible - Skips symlinks to avoid filesystem cycles
- Handles
PermissionErrorgracefully (skips inaccessible dirs) --dry-runflag for safe previewing- Selection step before deletion prevents accidental removes
- Textual — Terminal UI framework
- Click — CLI parsing
- uv — Package management
- hatchling — Build backend
pypurge escanea un árbol de directorios (y opcionalmente ubicaciones de cache globales) para encontrar artifacts de Python que ocupan espacio — entornos virtuales, caches de type-checkers, caches de tests, output de coverage, restos de builds — los muestra en una TUI interactiva y te permite elegir cuáles eliminar.
| Tipo | Detección |
|---|---|
venv |
pyvenv.cfg adentro (PEP 405) |
pycache |
__pycache__/ |
mypy |
.mypy_cache/ |
pytest |
.pytest_cache/ |
ruff |
.ruff_cache/ |
tox |
.tox/ |
nox |
.nox/ |
hypothesis |
.hypothesis/ |
benchmarks |
.benchmarks/ |
pyre |
.pyre/ |
pytype |
.pytype/ |
eggs |
.eggs/ |
egg-info |
*.egg-info/ |
htmlcov |
htmlcov/ |
pip-cache |
cache global de pip (per-OS) |
uv-cache |
cache global de uv (per-OS) |
poetry-cache |
cache global de poetry (per-OS) |
pdm-cache |
cache global de pdm (per-OS) |
build/ydist/quedaron deliberadamente afuera — son nombres demasiado ambiguos y pueden existir en proyectos no-Python.
Requiere uv y Python 3.10+.
# Clonar y ejecutar
git clone <repo-url> && cd pypurge
uv run pypurge
# O instalar globalmente
uv tool install .Nota: los caches globales (pip/uv/poetry/pdm) se incluyen por default sin importar
-d. Usá--no-globalspara escanear solo el directorio objetivo.
# Escanear directorio actual + caches globales (todos los tipos por default)
pypurge
# Escanear un directorio específico
pypurge -d C:\dev
# Escanear todo el home
pypurge --full
# Ordenar por fecha en vez de tamaño
pypurge -s date
# Excluir nombres de directorio del walk
pypurge --exclude vendor --exclude .tox
# Solo tipos específicos
pypurge --types venv,pycache
# Excluir tipos específicos
pypurge --exclude-types pycache,htmlcov
# Saltear caches globales
pypurge --no-globals
# Vista previa sin borrar
pypurge --dry-run| Tecla | Acción |
|---|---|
Space |
Seleccionar/deseleccionar la fila actual |
x |
Eliminar todos los artifacts seleccionados |
r |
Re-escanear directorio |
s |
Cambiar orden (tamaño / fecha / ruta) |
j / Abajo |
Mover cursor abajo |
k / Arriba |
Mover cursor arriba |
q |
Salir |
| Opción | Descripción | Default |
|---|---|---|
-d, --directory |
Directorio a escanear | . (actual) |
--full |
Escanear directorio home | desactivado |
-s, --sort |
Orden inicial: size, date, path |
size |
--exclude |
Nombres de directorio a omitir en el walk (repetible) | .git, node_modules, .hg, .svn |
--types |
Lista CSV de tipos a incluir (ej: venv,pycache) |
todos |
--exclude-types |
Lista CSV de tipos a excluir | ninguno |
--no-globals |
Saltear caches globales pip/uv/poetry/pdm | desactivado |
--dry-run |
Muestra qué se borraría sin borrar nada | desactivado |
--version |
Mostrar versión | |
--help |
Mostrar ayuda |
- Rechaza eliminar el entorno Python actualmente activo
- Rechaza eliminar cualquier path dentro de directorios del sistema (
C:\Windows,/usr, etc.) - Los venvs requieren
pyvenv.cfgpara ser elegibles - Omite symlinks para evitar ciclos en el filesystem
- Maneja
PermissionErrorsilenciosamente (omite directorios inaccesibles) - Flag
--dry-runpara vista previa segura - Paso de selección antes de eliminar previene borrados accidentales