pypa / build

A simple, correct Python build frontend

Home Page:https://build.pypa.io

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

[feature] option for cleaning up build artefacts and directories

con-f-use opened this issue · comments

Build creates several files and directories in the project dirs, some of them intermediate. Manual cleanup e.g. with something like rm -rf src/*.egg-info/ ./dist/ ./build/ can get tedious, because the command is hard to remember and because what actually gets created by build might be subject to change. Can we get a pyproject-build --clean and --clean-all option? The former would leave the resulting wheels and/or source distributions, while the latter removes everything including the dist directory.

Could be combined with #455 to clean before building, when are provided like so: pyproject-build --clean-all --wheel.

"clear" instead of "clean" might be an option name to consider, as e.g. venv uses it in that context and consistency is cozy and nice.

This is handed by the build backend. Setuptools happens to make those directories (.egg-info and build), but other build backends make different ones. Scikit-build-core actually allows a user to configure where build artifacts go, with build mildly recommended. Build can't safely clean up files it doesn't know about.

Hmm... then the scope of the problem is "just" larger, right? To solve that correctly we'd need an interface between the build back- and frontend so that the frontend can trigger a cleanup by the backend.

commented

I don't know if it's worth exposing a hook/param to purge the in-tree build cache. As far as I'm aware no other backend dumps its build cache in the source tree and is something that should be fixed by setuptools.

I don't know if it's worth exposing a hook/param to purge the in-tree build cache. As far as I'm aware no other backend dumps its build cache in the source tree and is something that should be fixed by setuptools.

Very much agreed, your earlier post was the first time it dawned on my that setuptools was the culprit. Thanks for taking the time of reading and answering. The only real usecase I can present was outlined in #455, their presence can cause unexpeted behavior and makes some task a bit more annoying.