PyClean

 PyClean

Bytecode is opcodes for the Python Virtual Machine. The *.pyc files and __pycache__ folders in your directory tree. On Debian there's pyclean to clean it all up when developing. We need to make this available on all platforms.

See the original presentation at https://slides.com/bittner/pyconx-pyclean/

0de2b4614a6e1bde25d1b1c7ac040104?s=128

Peter Bittner

May 04, 2019
Tweet

Transcript

  1. PyClean PyClean Clean up your Python bytecode & more. PyCon

    X, Firenze 2019 PyCon X, Firenze 2019 pip install pyclean
  2. PyClean PyClean installed on Debian via python-minimal pyclean py3clean pypyclean

  3. Bytecode Bytecode def foo(bar): print(bar) foo.__code__.co_code \x00\x00\x83\x01 \x01\x00\x00\x00 pip3 install

    pyclean
  4. Don't want this in my (Debian) package. pip3 install pyclean

    __pycache__/foo.pyc __pycache__/foo.pyc
  5. pip3 install pyclean python-defaults/pyclean (salsa.debian.org) python3-defaults/py3clean (salsa.debian.org) debian/scripts/pypyclean (salsa.debian.org) ⤋

    github.com/bittner/pyclean Debian, mother of things Debian, mother of things
  6. pip3 install pyclean python-defaults/pyclean (salsa.debian.org) python3-defaults/py3clean (salsa.debian.org) debian/scripts/pypyclean (salsa.debian.org) ⤋

    github.com/bittner/pyclean Debian, mother of things Debian, mother of things
  7. pip3 install pyclean python-defaults/pyclean (salsa.debian.org) python3-defaults/py3clean (salsa.debian.org) debian/scripts/pypyclean (salsa.debian.org) ⤋

    github.com/bittner/pyclean Debian, mother of things Debian, mother of things
  8. Clean Code, Clean Pkg Clean Code, Clean Pkg $ py3clean

    ­v . pip3 install pyclean
  9. pip3 install pyclean Code duplication Debian only + dependencies No

    PyPy3 No tests Limited benefit What's broken? What's broken?
  10. How could we use it? How could we use it?

    tox # runs tests and cleans up afterwards # tox.ini [testenv:clean] commands = py3clean {toxinidir} find . ­name foo ­delete rm ­rf .pytest_cache/ .tox/ *.egg­info whitelist_externals = py3clean find rm
  11. How could we use it? How could we use it?

    tox # runs tests and cleans up afterwards # tox.ini [testenv:clean] commands = py3clean {toxinidir} find . ­name foo ­delete rm ­rf .pytest_cache/ .tox/ *.egg­info whitelist_externals = py3clean find rm # tox.ini [tox] envlist = py27,py37,clean [testenv] ... [testenv:clean] deps = pyclean commands = pyclean {toxinidir} ­­debris tox
  12. git clone https://github.com/bittner/pyclean Contributors wanted! Contributors wanted!

  13. Thank you! Thank you! for your precious time for your

    precious time Painless Software Painless Software Less pain, more fun.