Cleaning build directory in setup.py Cleaning build directory in setup.py python python

Cleaning build directory in setup.py


Does this answer it? IIRC, you'll need to use the --all flag to get rid of stuff outside of build/lib:

python setup.py clean --all


For pre-deletion, just delete it with distutils.dir_util.remove_tree before calling setup.

For post-delete, I assume you only want to post-delete after selected commands. Subclass the respective command, override its run method (to invoke remove_tree after calling the base run), and pass the new command into the cmdclass dictionary of setup.


This clears the build directory before to install

python setup.py clean --all install

But according to your requirements: This will do it before, and after

python setup.py clean --all install clean --all