Skip to content

Pure Python cross-platform pyclean. Clean up your Python bytecode.

License

Notifications You must be signed in to change notification settings

smeggingsmegger/pyclean

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

32 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

pyclean Latest version on PyPI

Build status Build status Code health Python versions Software license

Worried about .pyc files and __pycache__ directories? Fear not! Pyclean is here to help. Finally the single-command clean up for Python bytecode files in your favorite directories. On any platform.

PyClean and its future

Presented at PyConX, Firenze 2019.

Wait! What is bytecode?

Bytecode is opcodes for the Python Virtual Machine. -- Confused?

If you want to deep-dive into the topic watch the 2013 EuroPython talk "All Singing All Dancing Python Bytecode" by Larry Hastings. Otherwise James Bennett's "Introduction to Python bytecode" should provide you with just the sound understanding of what it is all about.

Why not simply use rm **/*.pyc or find -name '*.py?' -delete?

If you're happy with rm or find, go for it! When I was looking for a simple, concise solution for everybody I figured people are struggling, and simple things are more complicated than they appear at first sight.

Also, there is a pyclean command (and its siblings) on Debian. And, well, only on Debian as it turns out. Not that I'm a big fan of Mircosoft Windos, but why ignore the biggest Python population on this planet? (As if they weren't punished enough already using this unfree piece of software!)

Debian

Just for reference, the Python scripts Debian ships with its python-minimal and python3-minimal packages can be found at:

Installation

$ pip install pyclean

Usage

$ pyclean --help

If you want to explicitly operate the version-specific implementation:

$ py2clean --help
$ py3clean --help
$ pypyclean --help

Clean up all bytecode in the current directory tree, and explain verbosely:

$ pyclean -v .

Clean up all bytecode for a Debian package: (may require root permissions)

$ pyclean -p python3-keyring

Use pyclean with Tox

If you want to avoid installing pyclean you can add it to your tox.ini file as follows:

[testenv:clean]
deps = pyclean
commands = pyclean {toxinidir}

You'll then be able to run it with Tox like this:

$ tox -e clean

Roadmap (for v2.0.0)

  1. Consolidate original Debian scripts into a single code base that serves all target platforms (py27, py3x, pypy2.7, pypy3.5).
  2. Ensure the package is actually tested also on Windows NT and Darwin target machines :-) (AppVeyor and Travis CI).
  3. Reduce the package dependencies to an absolute minimum for maximum portability.
  4. Add additional CLI options to delete debris from builds, testing and packaging (build/, .cache/, dist/, .pytest_cache/, .tox/ and free-form targets).

About

Pure Python cross-platform pyclean. Clean up your Python bytecode.

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages

  • Python 100.0%