Remove directory symlinks in ensure_empty_dir - #300
Merged
Merged
Conversation
gaborbernat
requested changes
Sep 14, 2026
rmtree raises on a symlink and ignore_errors=True hid the error, so links to directories survived and the metadata directory was not emptied. Unlink symlinks instead of passing them to rmtree.
gaborbernat
force-pushed
the
githubpower/t_e673392d
branch
from
September 15, 2026 22:37
63376fd to
5c21e92
Compare
gaborbernat
approved these changes
Sep 15, 2026
gaborbernat
approved these changes
Sep 15, 2026
gaborbernat
enabled auto-merge (squash)
September 15, 2026 22:50
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.

ensure_empty_dircalledrmtree(sub_path, ignore_errors=True)on every entry whereis_dir()returned true. For asymlink to a directory
rmtreeraisesOSError("Cannot call rmtree on a symbolic link"),ignore_errors=Trueswallowsit, and the link stays.
_check_metadata_dirrelies on this function to empty the metadata directory beforeprepare_metadata_for_build_wheelandprepare_metadata_for_build_editable, so a stale link survived between runs.Symlinks now go through
unlink, which removes the link and leaves its target alone. The new test intests/test_util.pychecks both.
🤖 Generated with Claude Code