Skip to content

Commit

Permalink
Invalidate caches after new python modules are installed
Browse files Browse the repository at this point in the history
This ensures that any new python modules installed will be found
by the python import mechanism.
  • Loading branch information
Nick-Hall committed Sep 10, 2023
1 parent 1805079 commit fb26f1c
Showing 1 changed file with 2 additions and 5 deletions.
7 changes: 2 additions & 5 deletions gramps/gui/plug/_windows.py
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down

0 comments on commit fb26f1c

Please sign in to comment.