Remove empty default build tree left behind by bdist_wheel - #5308
Open
CAOShurong wants to merge 1 commit into
Open
CAOShurong wants to merge 1 commit into
CAOShurong wants to merge 1 commit into
Conversation
With the default options a wheel build leaves an empty 'build/bdist.*' chain behind because bdist_wheel removes only its own scratch directory. Prune any directories that are still empty along the *default* chain (build_base -> bdist.plat -> wheel) after removing bdist_dir, so 'python -m build --wheel' no longer litters the project root with an empty 'build/' tree (pypa#5134). User-supplied --bdist-dir values and a customized [build] build_base are never touched.
Contributor
|
Tick the box to add this pull request to the merge queue (same as
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Fixes #5134 (the
build/bdist.*leftover part — the separate egg-info question discussed in that issue is out of scope here).With the default options, a wheel build leaves an empty directory chain behind:
The cause:
bdist_wheelremoves only its own scratch directory (bdist_dir = build/bdist.<plat>/wheel), so the parent directories it created along the way survive as empty shells.Change
After removing
bdist_dir, prune directories that are still empty walking up the default chain ([build] build_base→bdist.<plat>). The pruning stops at the first non-empty directory and is guarded on both sides:--bdist-dir(anything other than the default<bdist_base>/wheel) is never touched;[build] build_basedisables pruning entirely.A non-empty
build/containing real artifacts (e.g. frombuild_ext) is preserved as before.Testing
setuptools/tests/test_bdist_wheel.py:test_bdist_base_removed_when_empty: default build leaves nobuild/behind (verified RED without the fix:1 failed);test_bdist_base_preserved_when_not_empty(parametrized): custom--bdist-dir, plus stale file / subdirectory left inside the base — never removed.32 passed, 2 skippedon current main.python -m build --wheel: before the fixbuild/ + build/bdist.win-amd64remain; after the fix onlydist/remains.