|
28 | 28 |
|
29 | 29 |
|
30 | 30 | class Config: |
31 | | - libzim_dl_version: str = os.getenv("LIBZIM_DL_VERSION", "8.2.0") |
| 31 | + libzim_dl_version: str = os.getenv("LIBZIM_DL_VERSION", "8.2.1-1") |
32 | 32 | use_system_libzim: bool = bool(os.getenv("USE_SYSTEM_LIBZIM", False)) |
33 | 33 | download_libzim: bool = not bool(os.getenv("DONT_DOWNLOAD_LIBZIM", False)) |
34 | 34 |
|
@@ -256,6 +256,18 @@ def _install_from(self, folder: pathlib.Path): |
256 | 256 | file=sys.stderr, |
257 | 257 | ) |
258 | 258 |
|
| 259 | + def cleanup(self): |
| 260 | + """removes created files to prevent re-run issues""" |
| 261 | + # we downloaded libzim, so we must remove it |
| 262 | + if self.download_libzim: |
| 263 | + print("removing downloaded libraries") |
| 264 | + for fpath in self.dylib_file.parent.glob("*.[dylib|so]*"): |
| 265 | + print(">", fpath) |
| 266 | + fpath.unlink(missing_ok=True) |
| 267 | + if self.header_file.parent.exists(): |
| 268 | + print("removing downloaded headers") |
| 269 | + shutil.rmtree(self.header_file.parent, ignore_errors=True) |
| 270 | + |
259 | 271 | @property |
260 | 272 | def header_file(self) -> pathlib.Path: |
261 | 273 | return self.base_dir / "include" / "zim" / "zim.h" |
@@ -466,13 +478,30 @@ def run(self): |
466 | 478 | config.download_to_dest() |
467 | 479 |
|
468 | 480 |
|
| 481 | +class LibzimClean(Command): |
| 482 | + user_options = [] |
| 483 | + |
| 484 | + def initialize_options(self): |
| 485 | + ... |
| 486 | + |
| 487 | + def finalize_options(self): |
| 488 | + ... |
| 489 | + |
| 490 | + def run(self): |
| 491 | + config.cleanup() |
| 492 | + |
| 493 | + |
469 | 494 | if len(sys.argv) == 2 and sys.argv[1] in config.buildless_commands: |
470 | 495 | ext_modules = None |
471 | 496 | else: |
472 | 497 | config.check_platform() |
473 | 498 | ext_modules = get_cython_extension() |
474 | 499 |
|
475 | 500 | setup( |
476 | | - cmdclass={"build_ext": LibzimBuildExt, "download_libzim": DownloadLibzim}, |
| 501 | + cmdclass={ |
| 502 | + "build_ext": LibzimBuildExt, |
| 503 | + "download_libzim": DownloadLibzim, |
| 504 | + "clean": LibzimClean, |
| 505 | + }, |
477 | 506 | ext_modules=ext_modules, |
478 | 507 | ) |
0 commit comments