Skip to content

Commit

Permalink
Add plugin module paths to system path
Browse files Browse the repository at this point in the history
Closes tianocore#338

Adds dynamically loaded plugin module directory paths to the system
path so the plugin modules can import other modules relative to their
path as they would if they were not dynamically loaded.

Signed-off-by: Michael Kubacki <michael.kubacki@microsoft.com>
  • Loading branch information
makubacki authored and Javagedes committed Nov 9, 2022
1 parent 9b42220 commit 24f080b
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions edk2toolext/environment/plugin_manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,11 @@ def _load(self, PluginDescriptor):
py_module_name, py_module_path)
module = importlib.util.module_from_spec(spec)
sys.modules[py_module_name] = module

py_module_dir = os.path.dirname(py_module_path)
if py_module_dir not in sys.path:
sys.path.append(py_module_dir)

spec.loader.exec_module(module)
except Exception:
exc_info = sys.exc_info()
Expand Down

0 comments on commit 24f080b

Please sign in to comment.