@@ -106,6 +106,11 @@ def get_mod_name(project_root: Path) -> str:
106106 if (project_root / mod_name ).exists ():
107107 return mod_name
108108
109+ # Try the first part before hyphen
110+ first_part = lib_name .split ("-" )[0 ]
111+ if (project_root / first_part ).exists ():
112+ return first_part
113+
109114 # Otherwise return the lib_name as is
110115 return lib_name
111116
@@ -125,14 +130,22 @@ def remove_if_exists(path: Path) -> None:
125130 path .unlink ()
126131
127132
128- def remove_glob_pattern (pattern : str , search_root : Path ) -> None :
133+ def remove_glob_pattern (
134+ pattern : str , search_root : Path , case_sensitive : bool = True
135+ ) -> None :
129136 """Remove files matching a glob pattern.
130137
131138 Args:
132139 pattern: Glob pattern to match files/directories.
133140 search_root: Root directory to search from.
141+ case_sensitive: Whether the glob matching should be case sensitive.
134142 """
135- matches = list (search_root .glob (pattern ))
143+ if not case_sensitive :
144+ pattern = f"**/{ pattern .lower ()} "
145+ matches = [p for p in search_root .rglob ("*" ) if p .match (pattern )]
146+ print (f" Searching for pattern (case insensitive): { pattern } " )
147+ else :
148+ matches = list (search_root .glob (pattern ))
136149
137150 if matches :
138151 print (f" Removing { len (matches )} items matching pattern: { pattern } " )
@@ -202,7 +215,7 @@ def clean_coverage_files(project_root: Path) -> None:
202215 remove_if_exists (project_root / ".pytest_cache" )
203216
204217 # Remove .coverage.* files
205- remove_glob_pattern (".coverage.*" , project_root )
218+ remove_glob_pattern ("**/ .coverage.*" , project_root )
206219
207220
208221def clean_profile_files (project_root : Path ) -> None :
@@ -265,18 +278,20 @@ def clean_documentation_files(project_root: Path, lib_name: str, mod_name: str)
265278 mod_name: The main module name.
266279 """
267280 print (" Cleaning documentation files..." )
281+ remove_if_exists (project_root / "doc" / "_download" )
268282 remove_if_exists (project_root / "doc" / "changelog.md" )
269283 remove_if_exists (project_root / "doc" / "auto_examples" )
270284 remove_if_exists (project_root / "doc" / "sg_execution_times.rst" )
271285 remove_glob_pattern (f"{ mod_name } /data/doc/{ lib_name } *.pdf" , project_root )
272286
273287
274- def clean_wix_installer_files (project_root : Path , lib_name : str ) -> None :
288+ def clean_wix_installer_files (project_root : Path , lib_name : str , mod_name : str ) -> None :
275289 """Remove WiX installer related files.
276290
277291 Args:
278292 project_root: The root directory of the project.
279293 lib_name: The library name from pyproject.toml.
294+ mod_name: The main module name.
280295 """
281296 print (" Cleaning WiX installer files..." )
282297 wix_dir = project_root / "wix"
@@ -285,7 +300,8 @@ def clean_wix_installer_files(project_root: Path, lib_name: str) -> None:
285300 remove_if_exists (wix_dir / "obj" )
286301 remove_glob_pattern ("*.bmp" , wix_dir )
287302 remove_glob_pattern ("*.wixpdb" , wix_dir )
288- remove_glob_pattern (f"{ lib_name } *.wxs" , wix_dir )
303+ remove_glob_pattern (f"{ lib_name } *.wxs" , wix_dir , case_sensitive = False )
304+ remove_glob_pattern (f"{ mod_name } *.wxs" , wix_dir , case_sensitive = False )
289305
290306
291307def clean_empty_directories (project_root : Path ) -> None :
@@ -390,7 +406,7 @@ def run_cleanup(project_root: Path | str | None = None) -> None:
390406 clean_log_files (project_root )
391407 clean_localization_files (project_root , mod_name )
392408 clean_documentation_files (project_root , lib_name , mod_name )
393- clean_wix_installer_files (project_root , lib_name )
409+ clean_wix_installer_files (project_root , lib_name , mod_name )
394410 clean_empty_directories (project_root )
395411
396412 print ("🆗 Cleanup completed successfully!" )
0 commit comments