File tree Expand file tree Collapse file tree 1 file changed +22
-4
lines changed Expand file tree Collapse file tree 1 file changed +22
-4
lines changed Original file line number Diff line number Diff line change @@ -259,6 +259,19 @@ def _install_from(self, folder: pathlib.Path):
259259 file = sys .stderr ,
260260 )
261261
262+ def cleanup (self ):
263+ """ removes created files to prevent re-run issues"""
264+ # we downloaded libzim, so we must remove it
265+ if self .download_libzim :
266+ print ("removing downloaded libraries" )
267+ for fpath in self .dylib_file .parent .glob ("*.[dylib|so]*" ):
268+ print (">" , fpath )
269+ fpath .unlink (missing_ok = True )
270+ if self .header_file .parent .exists ():
271+ print ("removing downloaded headers" )
272+ shutil .rmtree (self .header_file .parent , ignore_errors = True )
273+
274+
262275 @property
263276 def header_file (self ) -> pathlib .Path :
264277 return self .base_dir / "include" / "zim" / "zim.h"
@@ -475,7 +488,12 @@ def run(self):
475488 config .check_platform ()
476489 ext_modules = get_cython_extension ()
477490
478- setup (
479- cmdclass = {"build_ext" : LibzimBuildExt , "download_libzim" : DownloadLibzim },
480- ext_modules = ext_modules ,
481- )
491+ try :
492+ setup (
493+ cmdclass = {"build_ext" : LibzimBuildExt , "download_libzim" : DownloadLibzim },
494+ ext_modules = ext_modules ,
495+ )
496+ except Exception as exc :
497+ raise exc
498+ finally :
499+ config .cleanup ()
You can’t perform that action at this time.
0 commit comments