Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

setuptools pyproject.toml equivalent to `python setup.py clean --all`

I'm migrating from setup.py to pyproject.toml. The commands to install my package appear to be the same, but I can't find what the pyproject.toml command for cleaning up build artifacts is. What is the equivalent to python setup.py clean --all?

like image 538
ringo Avatar asked Apr 25 '26 03:04

ringo


2 Answers

The distutils command clean is not needed for a pyproject.toml based build. Modern tools invoking PEP517/PEP518 hooks, such as build, create a temporary directory or a cache directory to store intermediate files while building, rather than littering the project directory with a build subdirectory.

Anyway, it was not really an exciting command in the first place and rm -rf build does the same job.

like image 132
wim Avatar answered Apr 27 '26 16:04

wim


I ran into this same issue when I was migrating. What wim answered seems to be mostly true.

If you do as the setuptools documentation says and use python -m build then the build directory will not be created, but a dist will.

However if you do pip install . a build directory will be left behind even if you are using a pyproject.toml file. This can cause issues if you change your package structure or rename files as sometimes the old version that is in the build directory will be installed instead of your current changes.

Personally I run pip install . && rm -rf build or pip install . && rmdir /s /q build for Windows. This could be expanded to remove any other unwanted artifacts.

like image 38
ptth222 Avatar answered Apr 27 '26 17:04

ptth222



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!