From 5535d856d6224bf1a098c361bc14a4ebd908d68f Mon Sep 17 00:00:00 2001 From: aabhinavg Date: Mon, 15 Apr 2024 10:46:30 +0530 Subject: [PATCH 1/4] Iterates through each path from self._clean_trees to improve error handling with shutil.rmtree() --- setup.py | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/setup.py b/setup.py index 737ebd270d1e4..c82cf899d3689 100755 --- a/setup.py +++ b/setup.py @@ -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 # we need to inherit from the versioneer From 5e35b965ad7cf6bf8e15226545258e4106a2a3eb Mon Sep 17 00:00:00 2001 From: aabhinavg Date: Mon, 15 Apr 2024 18:10:24 +0530 Subject: [PATCH 2/4] Revert "Iterates through each path from self._clean_trees to improve error handling with shutil.rmtree()" This reverts commit 5535d856d6224bf1a098c361bc14a4ebd908d68f. --- setup.py | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/setup.py b/setup.py index c82cf899d3689..737ebd270d1e4 100755 --- a/setup.py +++ b/setup.py @@ -171,12 +171,10 @@ def run(self) -> None: except OSError: pass for clean_tree in self._clean_trees: - for path in clean_tree: - try: - # Remove the directory tree at the specified path - shutil.rmtree(path) - except OSError: - pass + try: + shutil.rmtree(clean_tree) + except OSError: + pass # we need to inherit from the versioneer From 24513c1089e05dcbc9328f76601d6ee3ed9463bf Mon Sep 17 00:00:00 2001 From: aabhinavg Date: Mon, 15 Apr 2024 18:25:17 +0530 Subject: [PATCH 3/4] fix(setup.py): ensure self._clean_trees contains list of paths --- setup.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/setup.py b/setup.py index 737ebd270d1e4..468bfd8b1474f 100755 --- a/setup.py +++ b/setup.py @@ -152,7 +152,9 @@ def initialize_options(self) -> None: ".orig", ): self._clean_me.append(filepath) - self._clean_trees.append(pjoin(root, d) for d in dirs if d == "__pycache__") + + # Extend self._clean_trees with list comprehension (convert generator to list) + self._clean_trees.extend([os.path.join(root, dir) for dir in dirs if dir == "__pycache__"]) # clean the generated pxi files for pxifile in _pxifiles: From 3371dd820e903c530fa596b59f543f7adc8d16a8 Mon Sep 17 00:00:00 2001 From: aabhinavg Date: Mon, 15 Apr 2024 18:40:06 +0530 Subject: [PATCH 4/4] fix(setup.py): ensure self._clean_trees contains list of paths --- setup.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/setup.py b/setup.py index 468bfd8b1474f..ba40efe732b2e 100755 --- a/setup.py +++ b/setup.py @@ -153,7 +153,7 @@ def initialize_options(self) -> None: ): self._clean_me.append(filepath) - # Extend self._clean_trees with list comprehension (convert generator to list) + # Extend self._clean_trees with list comprehension (convert generator to list) self._clean_trees.extend([os.path.join(root, dir) for dir in dirs if dir == "__pycache__"]) # clean the generated pxi files @@ -161,7 +161,8 @@ def initialize_options(self) -> None: pxifile_replaced = pxifile.replace(".pxi.in", ".pxi") self._clean_me.append(pxifile_replaced) - self._clean_trees.append(d for d in ("build", "dist") if os.path.exists(d)) + self._clean_trees.extend([os.path.join(os.getcwd(), dir) for dir in ("build", "dist") if os.path.exists(dir)]) + def finalize_options(self) -> None: pass