7

I am following the tutorial here to package a python project into a wheel package. I am using setup.cfg to do the build. I was able to do

python -m build --wheel

to create the wheel package. However, I'd like to automatically clean up the unwanted folders "build/" and "xxx.egg-info" after I get the wheel package in "dist/". I did a lot of search but the only answers I found were for using setup.py (e.g. here). I wonder if there's any way to do the cleanup with setup.cfg as well?

Akahs
  • 333
  • 2
  • 10

1 Answers1

6

AFAIK you can't, build can only be cleaned from a setup.py script, and the egg-info dir can not be cleaned up at all. You can, however, point both dirs to temp dir so they are cleaned up on the next reboot. For example, put in your setup.cfg:

[build]
build-base = /tmp/build

[egg_info]
egg-base = /tmp

Or you can call a fake setup script without creating it, with the clean subcommand. This will only remove the build directory, though:

$ python -c "from setuptools import setup; setup()" clean --all
hoefling
  • 59,418
  • 12
  • 147
  • 194
  • 6
    That's a little discouraging to know; hope this functionality can be implemented at some point. – Akahs Apr 07 '21 at 20:55
  • 2023 and it's still an open, unassigned issue on setuptools' github: https://github.com/pypa/setuptools/issues/1347 – Swirle13 Aug 30 '23 at 19:11