From 30646745ea9334e00f5bf3dcea668ef22efa9340 Mon Sep 17 00:00:00 2001 From: jeremiedbb Date: Mon, 13 Mar 2023 18:34:31 +0100 Subject: [PATCH] clean cmd removes generated from templates --- setup.py | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/setup.py b/setup.py index 55c5cc2923527..e40c1453f7e33 100755 --- a/setup.py +++ b/setup.py @@ -79,17 +79,20 @@ def run(self): shutil.rmtree("build") for dirpath, dirnames, filenames in os.walk("sklearn"): for filename in filenames: - if any( - filename.endswith(suffix) - for suffix in (".so", ".pyd", ".dll", ".pyc") - ): + root, extension = os.path.splitext(filename) + + if extension in [".so", ".pyd", ".dll", ".pyc"]: os.unlink(os.path.join(dirpath, filename)) - continue - extension = os.path.splitext(filename)[1] + if remove_c_files and extension in [".c", ".cpp"]: pyx_file = str.replace(filename, extension, ".pyx") if os.path.exists(os.path.join(dirpath, pyx_file)): os.unlink(os.path.join(dirpath, filename)) + + if remove_c_files and extension == ".tp": + if os.path.exists(os.path.join(dirpath, root)): + os.unlink(os.path.join(dirpath, root)) + for dirname in dirnames: if dirname == "__pycache__": shutil.rmtree(os.path.join(dirpath, dirname))