From fb26f1c96b30475fb986330c9c61fcec3876b2ab Mon Sep 17 00:00:00 2001 From: Nick Hall Date: Sun, 10 Sep 2023 21:43:05 +0100 Subject: [PATCH] Invalidate caches after new python modules are installed This ensures that any new python modules installed will be found by the python import mechanism. --- gramps/gui/plug/_windows.py | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/gramps/gui/plug/_windows.py b/gramps/gui/plug/_windows.py index fd9bbfee2db..2d516b1fbbd 100644 --- a/gramps/gui/plug/_windows.py +++ b/gramps/gui/plug/_windows.py @@ -305,11 +305,8 @@ def __on_install_clicked(self, button, addon): ) return - location = os.path.join(LIB_PATH, package, "__init__.py") - spec = importlib.util.spec_from_file_location(package, location) - module = importlib.util.module_from_spec(spec) - sys.modules[spec.name] = module - spec.loader.exec_module(module) + # Invalidate the caches to ensure that the new modules will be found. + importlib.invalidate_caches() if not self.req.check_addon(addon): InfoDialog(