Skip to content

Commit

Permalink
Merge pull request #129 from ESSS/fb-DCC-149-compute-chemical-eq
Browse files Browse the repository at this point in the history
Fix alfasim plugin library loading
  • Loading branch information
alexandrebbruno authored Feb 27, 2024
2 parents a996cb0 + c692abf commit e0feab9
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 1 deletion.
5 changes: 5 additions & 0 deletions hookman/hookman_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,12 +40,17 @@ def change_path_env(shared_lib_path: str):
Change PATH environment adding the shared library path to it.
"""
old_path = os.environ["PATH"]
handle = None
if sys.platform.startswith("win"):
# We explict opted to not cover this on windows.
os.environ["PATH"] = old_path + os.pathsep + os.path.dirname(shared_lib_path)
handle = os.add_dll_directory(os.path.dirname(shared_lib_path)) # pragma: no cover
try:
yield
finally:
os.environ["PATH"] = old_path
if handle is not None:
handle.close() # pragma: no cover


@contextmanager
Expand Down
4 changes: 3 additions & 1 deletion hookman/hooks.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
from hookman import hookman_utils
from hookman.exceptions import InvalidDestinationPathError
from hookman.exceptions import PluginAlreadyInstalledError
from hookman.hookman_utils import change_path_env
from hookman.plugin_config import PluginInfo


Expand Down Expand Up @@ -206,5 +207,6 @@ def get_hook_caller(self, ignored_plugins: Sequence[str] = ()):
_hookman = __import__(self.specs.pyd_name)
hook_caller = _hookman.HookCaller()
for plugin in self.get_plugins_available(ignored_plugins):
hook_caller.load_impls_from_library(str(plugin.shared_lib_path), plugin.id)
with change_path_env(str(plugin.shared_lib_path)):
hook_caller.load_impls_from_library(str(plugin.shared_lib_path), plugin.id)
return hook_caller

0 comments on commit e0feab9

Please sign in to comment.