Skip to content

Iterates through each path from self._clean_trees to improve error ha… #58263

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

Closed
wants to merge 4 commits into from
Closed
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 6 additions & 4 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -171,10 +171,12 @@ def run(self) -> None:
except OSError:
pass
for clean_tree in self._clean_trees:
try:
shutil.rmtree(clean_tree)
except OSError:
pass
for path in clean_tree:
try:
# Remove the directory tree at the specified path
shutil.rmtree(path)
except OSError:
pass
Copy link
Member

@Aloqeely Aloqeely Apr 15, 2024

Choose a reason for hiding this comment

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

Instead of iterating through clean_tree, I would recommend reverting the changes done in #54236 (setup.py) which caused self._clean_trees to be a list of generators.

EDIT: Using generator comprehension is intended, so you should probably fix the current logic of self._clean_trees such that it is a list of paths (strings) and not generators.
self._clean_trees.extend(...) instead of self_clean_trees.append(...) should be sufficient.

Copy link
Author

Choose a reason for hiding this comment

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

Extend self._clean_trees by converting generator to list using list comprehension
This finds all "pycache" directories in the current root and appends their full paths to self._clean_trees

self._clean_trees.extend([os.path.join(root, dir) for dir in dirs if dir == "__pycache__"])
#and 
self._clean_trees.extend([os.path.join(os.getcwd(), dir) for dir in ("build", "dist") if os.path.exists(dir)])



# we need to inherit from the versioneer
Expand Down
Loading