PyClean

Clean up your Python bytecode & more.

pip install pyclean

 

PyCon X, Firenze 2019

PyClean

pyclean
py3clean
pypyclean

Bytecode

def foo(bar):
    print(bar)

foo.__code__.co_code

\x00\x00\x83\x01
\x01\x00\x00\x00

 __pycache__/foo.pyc

Don't want this in my (Debian) package.

 

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

 Clean Code, Clean Pkg

 $ py3clean -v .

 

  • Code duplication
  • Debian only + dependencies
  • No PyPy3
  • No tests
  • Limited benefit

 

 What's broken?

# tox.ini
[tox]
envlist = py27,py37,clean

[testenv]
...

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

 How could we use it?

# tox.ini
[testenv:clean]
commands =
    py3clean {toxinidir}
    find . -name foo -delete
    rm -rf .pytest_cache/ .tox/ *.egg-info
whitelist_externals =
    py3clean
    find
    rm

 

Contributors wanted!

 

Thank you!

for your precious time

Painless Software

Less pain, more fun.

Made with Slides.com