Security News
Research
Data Theft Repackaged: A Case Study in Malicious Wrapper Packages on npm
The Socket Research Team breaks down a malicious wrapper package that uses obfuscation to harvest credentials and exfiltrate sensitive data.
|checks-status| |tests-status| |publish-status| |scrutinizer| |codacy| |python-versions| |python-impl| |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.
|video|
Presented at PyConX
_, Firenze 2019.
.. |latest-version| image:: https://img.shields.io/pypi/v/pyclean.svg :target: https://pypi.org/project/pyclean :alt: Latest version on PyPI .. |checks-status| image:: https://github.com/bittner/pyclean/actions/workflows/check.yml/badge.svg :target: https://github.com/bittner/pyclean/actions/workflows/check.yml :alt: GitHub Workflow Status .. |tests-status| image:: https://github.com/bittner/pyclean/actions/workflows/test.yml/badge.svg :target: https://github.com/bittner/pyclean/actions/workflows/test.yml :alt: GitHub Workflow Status .. |publish-status| image:: https://github.com/bittner/pyclean/actions/workflows/publish.yml/badge.svg :target: https://github.com/bittner/pyclean/actions/workflows/publish.yml :alt: GitHub Workflow Status .. |scrutinizer| image:: https://img.shields.io/scrutinizer/build/g/bittner/pyclean/main?logo=scrutinizer&label=%22 :target: https://scrutinizer-ci.com/g/bittner/pyclean/ :alt: Scrutinizer .. |codacy| image:: https://img.shields.io/codacy/grade/69de1364a09f41b399f95afe901826eb/main.svg?logo=codacy&label=%22 :target: https://app.codacy.com/gh/bittner/pyclean/dashboard :alt: Code health .. |python-versions| image:: https://img.shields.io/pypi/pyversions/pyclean.svg :target: https://pypi.org/project/pyclean :alt: Python versions .. |python-impl| image:: https://img.shields.io/pypi/implementation/pyclean.svg :target: https://pypi.org/project/pyclean :alt: Python implementations .. |license| image:: https://img.shields.io/pypi/l/pyclean.svg :target: https://github.com/bittner/pyclean/blob/main/LICENSE :alt: Software license .. |video| image:: https://asciinema.org/a/g8Q2ljghA7W4RD9cb3Xz100Tl.svg :target: https://asciinema.org/a/g8Q2ljghA7W4RD9cb3Xz100Tl :alt: PyClean and its future .. _Presented at PyConX: https://slides.com/bittner/pyconx-pyclean/
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.
.. _Python Virtual Machine: https://www.ics.uci.edu/~brgallar/week9_3.html .. _"All Singing All Dancing Python Bytecode": https://www.youtube.com/watch?v=0IzXcjHs-P8 .. _"Introduction to Python bytecode": https://opensource.com/article/18/4/introduction-python-bytecode
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!)
.. _looking for a simple, concise solution for everybody: https://stackoverflow.com/questions/785519/how-do-i-remove-all-pyc-files-from-a-project
Just for reference, the Python scripts Debian ships with its
python-minimal
_ and python3-minimal
_ packages can be found at:
salsa.debian.org/cpython-team/python-defaults <https://salsa.debian.org/cpython-team/python-defaults/blob/master/pyclean>
__salsa.debian.org/cpython-team/python3-defaults <https://salsa.debian.org/cpython-team/python3-defaults/blob/master/py3clean>
__salsa.debian.org/debian/pypy <https://salsa.debian.org/debian/pypy/blob/debian/debian/scripts/pypyclean>
__.. _python-minimal: https://packages.debian.org/stable/python-minimal .. _python3-minimal: https://packages.debian.org/stable/python3-minimal
.. code:: console
$ pip install pyclean
or
.. code:: console
$ python -m pip install pyclean
.. code:: console
$ pyclean --help
or
.. code:: console
$ python -m pyclean --help
Clean up all bytecode in the current directory tree, and explain verbosely:
.. code:: console
$ pyclean -v .
PyClean can clean up leftovers, generated data and temporary files from popular Python development tools in their default locations, along with Python bytecode. The following topics are currently covered:
Example: Dry-run a cleanup of bytecode and tool debris in verbose mode (to see what would be deleted):
.. code:: console
$ pyclean . --debris --verbose --dry-run
PyClean also lets you remove free-form targets using globbing. Note that
this is potentially dangerous: You can delete everything anywhere in
the file system, including the entire project you're working on. For this
reason, the --erase
option has a few artificial constraints:
--yes
option, in addition... code:: console
$ pyclean . --erase tmp/**/* tmp/
The above would delete the entire tmp/
directory with all subdirectories
inside the current folder. If you omit the final tmp/
you'll leave the
empty tmp
directory in place. (WARNING! Don't put the .
after
the --erase
option! Obviously, your project files will all be deleted.)
If you want to avoid installing pyclean
you can add it to your
tox.ini
file as follows:
.. code:: ini
[testenv:clean]
skip_install = true
deps = pyclean
commands = pyclean {posargs:. --debris}
You'll then be able to run it with Tox
_ like this:
.. code:: console
$ tox -e clean
.. _Tox: https://tox.wiki/
If you want to help out please see our contribution guide
_.
.. _contribution guide: https://github.com/bittner/pyclean/blob/main/CONTRIBUTING.md
FAQs
Pure Python cross-platform pyclean. Clean up your Python bytecode.
We found that pyclean demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 4 open source maintainers collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
Research
The Socket Research Team breaks down a malicious wrapper package that uses obfuscation to harvest credentials and exfiltrate sensitive data.
Research
Security News
Attackers used a malicious npm package typosquatting a popular ESLint plugin to steal sensitive data, execute commands, and exploit developer systems.
Security News
The Ultralytics' PyPI Package was compromised four times in one weekend through GitHub Actions cache poisoning and failure to rotate previously compromised API tokens.