{"id":16911321,"url":"https://github.com/bittner/pyclean","last_synced_at":"2025-04-09T20:15:09.289Z","repository":{"id":34308559,"uuid":"177030142","full_name":"bittner/pyclean","owner":"bittner","description":"Pure Python cross-platform pyclean. Clean up your Python bytecode.","archived":false,"fork":false,"pushed_at":"2025-03-08T11:59:38.000Z","size":179,"stargazers_count":74,"open_issues_count":3,"forks_count":7,"subscribers_count":2,"default_branch":"main","last_synced_at":"2025-04-09T20:15:03.783Z","etag":null,"topics":["bytecode","cli","python","tools"],"latest_commit_sha":null,"homepage":"https://speakerdeck.com/bittner/pyclean","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/bittner.png","metadata":{"files":{"readme":"README.rst","changelog":null,"contributing":"CONTRIBUTING.md","funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2019-03-21T22:00:14.000Z","updated_at":"2025-03-23T01:20:26.000Z","dependencies_parsed_at":"2024-02-10T19:30:54.764Z","dependency_job_id":"3ed17bfd-53a8-48b6-a53c-bb5a6dd4c310","html_url":"https://github.com/bittner/pyclean","commit_stats":{"total_commits":144,"total_committers":1,"mean_commits":144.0,"dds":0.0,"last_synced_commit":"82f466e5697e73848fb821ef3da72f4711302026"},"previous_names":[],"tags_count":17,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bittner%2Fpyclean","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bittner%2Fpyclean/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bittner%2Fpyclean/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bittner%2Fpyclean/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/bittner","download_url":"https://codeload.github.com/bittner/pyclean/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248103872,"owners_count":21048245,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["bytecode","cli","python","tools"],"created_at":"2024-10-13T19:05:20.244Z","updated_at":"2025-04-09T20:15:09.262Z","avatar_url":"https://github.com/bittner.png","language":"Python","readme":".. SPDX-FileCopyrightText: 2019 Peter Bittner \u003cdjango@bittner.it\u003e\n..\n.. SPDX-License-Identifier: GPL-3.0-or-later\n\npyclean |pypi-latest| |conda-latest|\n====================================\n\n|checks-status| |tests-status| |publish-status| |scrutinizer| |codacy| |python-versions| |python-impl| |license|\n\nWorried about ``.pyc`` files and ``__pycache__`` directories? Fear not!\nPyClean is here to help. Finally, the single-command clean up for Python\nbytecode files in your favorite directories. On any platform.\n\n|video|\n\n`Presented at PyConX`_, Firenze 2019.\n\n.. |pypi-latest| image:: https://img.shields.io/pypi/v/pyclean.svg\n   :target: https://pypi.org/project/pyclean\n   :alt: Latest version on PyPI\n.. |conda-latest| image:: https://img.shields.io/conda/vn/conda-forge/pyclean\n   :target: https://anaconda.org/conda-forge/pyclean\n   :alt: Latest version on Anaconda\n.. |checks-status| image:: https://github.com/bittner/pyclean/actions/workflows/check.yml/badge.svg\n   :target: https://github.com/bittner/pyclean/actions/workflows/check.yml\n   :alt: GitHub Workflow Status\n.. |tests-status| image:: https://github.com/bittner/pyclean/actions/workflows/test.yml/badge.svg\n   :target: https://github.com/bittner/pyclean/actions/workflows/test.yml\n   :alt: GitHub Workflow Status\n.. |publish-status| image:: https://github.com/bittner/pyclean/actions/workflows/publish.yml/badge.svg\n   :target: https://github.com/bittner/pyclean/actions/workflows/publish.yml\n   :alt: GitHub Workflow Status\n.. |scrutinizer| image:: https://img.shields.io/scrutinizer/build/g/bittner/pyclean/main?logo=scrutinizer\u0026label=%22\n   :target: https://scrutinizer-ci.com/g/bittner/pyclean/\n   :alt: Scrutinizer\n.. |codacy| image:: https://img.shields.io/codacy/grade/69de1364a09f41b399f95afe901826eb/main.svg?logo=codacy\u0026label=%22\n   :target: https://app.codacy.com/gh/bittner/pyclean/dashboard\n   :alt: Code health\n.. |python-versions| image:: https://img.shields.io/pypi/pyversions/pyclean.svg\n   :target: https://pypi.org/project/pyclean\n   :alt: Python versions\n.. |python-impl| image:: https://img.shields.io/pypi/implementation/pyclean.svg\n   :target: https://pypi.org/project/pyclean\n   :alt: Python implementations\n.. |license| image:: https://img.shields.io/pypi/l/pyclean.svg\n   :target: https://github.com/bittner/pyclean/blob/main/LICENSES/GPL-3.0-or-later.txt\n   :alt: Software license\n.. |video| image:: https://asciinema.org/a/g8Q2ljghA7W4RD9cb3Xz100Tl.svg\n   :target: https://asciinema.org/a/g8Q2ljghA7W4RD9cb3Xz100Tl\n   :alt: PyClean and its future\n.. _Presented at PyConX: https://slides.com/bittner/pyconx-pyclean/\n\nWait! What is bytecode?\n-----------------------\n\nBytecode is opcodes for the Python Virtual Machine. -- Confused?\n\nIf you want to deep-dive into the topic watch the 2013 EuroPython talk\n`\"All Singing All Dancing Python Bytecode\"`_ by Larry Hastings.\nOtherwise James Bennett's `\"Introduction to Python bytecode\"`_ should\nprovide you with just the sound understanding of what it is all about.\n\n.. _\"All Singing All Dancing Python Bytecode\":\n    https://www.youtube.com/watch?v=0IzXcjHs-P8\n.. _\"Introduction to Python bytecode\":\n    https://opensource.com/article/18/4/introduction-python-bytecode\n\nWhy not simply use ``rm **/*.pyc`` or ``find -name '*.py?' -delete``?\n---------------------------------------------------------------------\n\nIf you're happy with ``rm`` or ``find``, go for it! When I was `looking\nfor a simple, concise solution for everybody`_ I figured people are\nstruggling, and simple things are more complicated than they appear at\nfirst sight.\n\nAlso, there is a ``pyclean`` command (and its siblings) on Debian. And,\nwell, only on Debian as it turns out. Not that I'm a big fan of Mircosoft\nWindos, but why ignore the biggest Python population on this planet?\n(As if they weren't punished enough already using this unfree piece of\nsoftware!)\n\n.. _looking for a simple, concise solution for everybody:\n    https://stackoverflow.com/questions/785519/how-do-i-remove-all-pyc-files-from-a-project\n\nInspired by Debian\n------------------\n\nJust for reference, the Python scripts Debian ships with its\n`python-minimal`_ and `python3-minimal`_ packages can be found at:\n\n- pyclean: `salsa.debian.org/cpython-team/python-defaults\n  \u003chttps://salsa.debian.org/cpython-team/python-defaults/blob/master/pyclean\u003e`__\n- py3clean: `salsa.debian.org/cpython-team/python3-defaults\n  \u003chttps://salsa.debian.org/cpython-team/python3-defaults/blob/master/py3clean\u003e`__\n- pypyclean: `salsa.debian.org/debian/pypy\n  \u003chttps://salsa.debian.org/debian/pypy/blob/debian/debian/scripts/pypyclean\u003e`__\n\n.. _python-minimal: https://packages.debian.org/stable/python-minimal\n.. _python3-minimal: https://packages.debian.org/stable/python3-minimal\n\nInstallation\n============\n\n.. code:: console\n\n    $ pip install pyclean\n\nor\n\n.. code:: console\n\n    $ python -m pip install pyclean\n\nuv\n--\n\nIf you work with ``uv`` you can install ``pyclean`` globally via uv's\n`tool interface`_, or use the ``uvx`` command and not care about installing:\n\n.. code:: console\n\n    $ uv tool install pyclean\n\nor\n\n.. code:: console\n\n    $ uvx pyclean\n\n.. _tool interface: https://docs.astral.sh/uv/concepts/tools/\n\nTox\n---\n\nIf you want to integrate ``pyclean`` in your Python development setup you\ncan add it to your ``tox.ini`` file as follows:\n\n.. code:: ini\n\n    [testenv:clean]\n    skip_install = true\n    deps = pyclean\n    commands = pyclean {posargs:. --debris}\n\nYou'll then be able to run it with `Tox`_ like this:\n\n.. code:: console\n\n    $ tox -e clean\n\n.. _Tox: https://tox.wiki/\n\nUsage\n=====\n\n.. code:: console\n\n    $ pyclean --help\n\nor\n\n.. code:: console\n\n    $ python -m pyclean --help\n\nClean up all bytecode in the current directory tree, and explain verbosely:\n\n.. code:: console\n\n    $ pyclean -v .\n\nClean up debris\n---------------\n\nPyClean can clean up leftovers, generated data and temporary files from\npopular Python development tools in their default locations, along with\nPython bytecode. The following topics are currently covered:\n\n- Cache (general purpose folder for several tools, e.g. Python eggs, legacy Pytest)\n- Coverage (coverage database, and supported file formats)\n- Packaging (build files and folders)\n- Pytest (build files and folders)\n- Ruff (ruff cache folder)\n- Jupyter (notebook checkpoints) – *optional*\n- Mypy (mypy cache folder) – *optional*\n- Tox (tox environments) – *optional*\n\n*Example:* Dry-run a cleanup of bytecode and tool debris in verbose mode\n(to see what would be deleted):\n\n.. code:: console\n\n    $ pyclean . --debris --verbose --dry-run\n\nRemove arbitrary file system objects\n------------------------------------\n\nPyClean also lets you remove free-form targets using globbing. Note that\nthis is **potentially dangerous**: You can delete everything anywhere in\nthe file system, including the entire project you're working on. For this\nreason, the ``--erase`` option has a few artificial constraints:\n\n- It doesn't do recursive deletion by itself, which means that you have\n  to specify the directory and its contents, separately and explicitly.\n- The above entails that you're responsible for the deletion order, i.e.\n  removal of a directory will only work if you asked to delete all files\n  inside first.\n- You're prompted interactively to confirm deletion, unless you specify\n  the ``--yes`` option, in addition.\n\n.. code:: console\n\n    $ pyclean . --erase tmp/**/* tmp/\n\nThe above would delete the entire ``tmp/`` directory with all subdirectories\ninside the current folder. If you omit the final ``tmp/`` you'll leave the\nempty ``tmp`` directory in place. (**WARNING!** Don't put the ``.`` *after*\nthe ``--erase`` option! Obviously, your project files will all be deleted.)\n\nDevelopment\n===========\n\nIf you want to help out please see our `contribution guide`_.\n\n.. _contribution guide: https://github.com/bittner/pyclean/blob/main/CONTRIBUTING.md\n","funding_links":[],"categories":["Utilities"],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbittner%2Fpyclean","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fbittner%2Fpyclean","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbittner%2Fpyclean/lists"}