Skip to content

Remove directory symlinks in ensure_empty_dir - #300

Merged
gaborbernat merged 1 commit into
tox-dev:mainfrom
Str0k:githubpower/t_e673392d
Sep 15, 2026
Merged

gaborbernat merged 1 commit into
tox-dev:mainfrom
Str0k:githubpower/t_e673392d

Conversation

@Str0k

@Str0k Str0k commented Sep 13, 2026

Copy link
Copy Markdown
Contributor

ensure_empty_dir called rmtree(sub_path, ignore_errors=True) on every entry where is_dir() returned true. For a
symlink to a directory rmtree raises OSError("Cannot call rmtree on a symbolic link"), ignore_errors=True swallows
it, and the link stays. _check_metadata_dir relies on this function to empty the metadata directory before
prepare_metadata_for_build_wheel and prepare_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 in tests/test_util.py
checks both.

🤖 Generated with Claude Code

Comment thread tests/test_util_regression.py Outdated
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 gaborbernat changed the title Fix ensure_empty_dir leaving directory symlinks behind Remove directory symlinks in ensure_empty_dir Sep 15, 2026
@gaborbernat
gaborbernat force-pushed the githubpower/t_e673392d branch from 63376fd to 5c21e92 Compare September 15, 2026 22:37

@gaborbernat gaborbernat left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@gaborbernat
gaborbernat enabled auto-merge (squash) September 15, 2026 22:50
@gaborbernat
gaborbernat merged commit 289d6b6 into tox-dev:main Sep 15, 2026
29 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants