From 604a726f53fa21d4eb03ca47c8c5144581a37452 Mon Sep 17 00:00:00 2001
From: Dominique Benielli <dominique.benielli@univ-amu.fr>
Date: Tue, 6 May 2025 18:25:57 +0200
Subject: [PATCH] Edit setup.py

---
 setup.py | 19 ++++++++++---------
 1 file changed, 10 insertions(+), 9 deletions(-)

diff --git a/setup.py b/setup.py
index 3a830cd..1fbc459 100755
--- a/setup.py
+++ b/setup.py
@@ -105,7 +105,15 @@ def set_version(ltfat_dir, VERSION):
     f.write(buf.encode("utf8"))
     f.write(('__version__ = "%s"\n' % VERSION).encode("utf8"))
 
-
+def remove_generated_c_file():
+    for dirpath, dirnames, filenames in os.walk('.'):
+        for filename in filenames:
+            if filename.endswith('.c'):
+                full_path = os.path.join(dirpath, filename)
+                # Optionnel : ne supprime que ceux qui ont un .pyx à côté
+                pyx_path = full_path[:-2] + '.pyx'
+                if os.path.exists(pyx_path):
+                    os.remove(full_path)
 #################
 # CMake function
 #################
@@ -201,14 +209,6 @@ def run_uninstall(root_dir):
 
 class m_build_ext(build_ext):
     def run(self):
-        for dirpath, dirnames, filenames in os.walk('.'):
-            for filename in filenames:
-                if filename.endswith('.c'):
-                    full_path = os.path.join(dirpath, filename)
-                    # Optionnel : ne supprime que ceux qui ont un .pyx à côté
-                    pyx_path = full_path[:-2] + '.pyx'
-                    if os.path.exists(pyx_path):
-                        os.remove(full_path)
         root_dir = os.path.dirname(os.path.abspath(__file__))
         cur_dir = os.getcwd()
         run_cmake(root_dir)
@@ -316,6 +316,7 @@ def setup_package():
     # and build up the set of Extension objects
     if USE_CYTHON:
         fileExt = ".pyx"
+        remove_generated_c_file()
     else:
         fileExt = ".c"
 
-- 
GitLab