Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Refactor/unify/extract shutil.rmtree callbacks (and avoid repetition) #4682

Merged
merged 7 commits into from
Nov 11, 2024

Conversation

abravalheri
Copy link
Contributor

Summary of changes

I noticed that there are at least 2 implementations of shutil.rmtree callbacks in setuptools: one for easy_install and one for bdist_wheel. There is also other places in setuptools that we don't have those callbacks (so potentially still subject to errors on Windows?).

So this PR tries to unify these 2 separated implementations.
I have chosen to extract the implementation from easy_install.
One notable difference though is that bdist_wheel's implementation always try to apply the chmod callback when it fails, while the easy_install implementation is more conservative and only applies the callback on Windows (similar to the suggestion in https://github.com/python/cpython/issues/87823#issuecomment-1093908280)... So that might generate a bit of change in behaviour, but with a bit of luck should be compatible.

The name _shutil was used for the lack of a better name/imagination, and can be changed.

Closes

Pull Request Checklist

@abravalheri abravalheri marked this pull request as ready for review October 16, 2024 12:43
@abravalheri abravalheri merged commit c9d980f into pypa:main Nov 11, 2024
22 of 24 checks passed
@abravalheri abravalheri deleted the refactor-shutil-rmtree branch November 11, 2024 16:37
@abravalheri
Copy link
Contributor Author

According to the comments, it seems that the specific error that the chmod workaround is able to fix is only possible on Windows.

That is why some parts of the old code restrict the chmod workaround the to only Windows platforms.

This PR keeps the workaround homogeneously Windows-specific for all usages. If we have any reported failure we can relax the conditions a bit in a future PR.

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