Skip to content

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

Merged
abravalheri merged 7 commits intopypa:mainfrom
abravalheri:refactor-shutil-rmtree
Nov 11, 2024
Merged

Refactor/unify/extract shutil.rmtree callbacks (and avoid repetition)#4682
abravalheri merged 7 commits intopypa:mainfrom
abravalheri:refactor-shutil-rmtree

Conversation

@abravalheri
Copy link
Copy Markdown
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

Comment thread setuptools/_shutil.py
Comment thread setuptools/tests/test_shutil_wrapper.py
@abravalheri abravalheri force-pushed the refactor-shutil-rmtree branch from fa79779 to 602cde1 Compare October 16, 2024 10:08
@abravalheri abravalheri marked this pull request as ready for review October 16, 2024 12:43
@abravalheri abravalheri force-pushed the refactor-shutil-rmtree branch from 602cde1 to 4692179 Compare October 17, 2024 10:01
@abravalheri abravalheri force-pushed the refactor-shutil-rmtree branch from 4692179 to db2b206 Compare November 11, 2024 16:17
@abravalheri abravalheri merged commit c9d980f into pypa:main Nov 11, 2024
@abravalheri abravalheri deleted the refactor-shutil-rmtree branch November 11, 2024 16:37
@abravalheri
Copy link
Copy Markdown
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