Upgrade to Pro — share decks privately, control downloads, hide ads and more …

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/

Peter Bittner

May 04, 2019
Tweet

More Decks by Peter Bittner

Other Decks in Programming

Transcript

  1. PyClean
    PyClean
    Clean up your Python bytecode & more.
    PyCon X, Firenze 2019
    PyCon X, Firenze 2019
    pip install pyclean

    View Slide

  2. PyClean
    PyClean
    installed on Debian via python-minimal
    pyclean
    py3clean
    pypyclean

    View Slide

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

    View Slide

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

    View Slide

  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

    View Slide

  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

    View Slide

  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

    View Slide

  8. Clean Code, Clean Pkg
    Clean Code, Clean Pkg
    $ py3clean ­v .
    pip3 install pyclean

    View Slide

  9. pip3 install pyclean
    Code duplication
    Debian only + dependencies
    No PyPy3
    No tests
    Limited benefit
    What's broken?
    What's broken?

    View Slide

  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

    View Slide

  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

    View Slide

  12. git clone https://github.com/bittner/pyclean
    Contributors wanted!
    Contributors wanted!

    View Slide

  13. Thank you!
    Thank you!
    for your precious time
    for your precious time
    Painless Software
    Painless Software
    Less pain, more fun.

    View Slide