Improving plugin imports
This commit is contained in:
parent
f5567d2631
commit
d41235882a
@ -21,6 +21,9 @@ class Plugins:
|
||||
"""Plugins controller"""
|
||||
|
||||
def __init__(self, settings: type):
|
||||
path = os.path.dirname(os.path.realpath(__file__))
|
||||
sys.path.insert(0, path) # NOTE: I think I'm not using this correctly...
|
||||
|
||||
self._settings = settings
|
||||
self._builder = self._settings.get_builder()
|
||||
self._plugins_path = self._settings.get_plugins_path()
|
||||
@ -69,11 +72,9 @@ class Plugins:
|
||||
|
||||
def load_plugin_module(self, path, folder, target):
|
||||
os.chdir(path)
|
||||
sys.path.insert(0, path) # NOTE: I think I'm not using this correctly...
|
||||
# The folder and target aren't working to create parent package references, so using as stopgap.
|
||||
# The above is probably polutling import logic and will cause unforseen import issues.
|
||||
spec = importlib.util.spec_from_file_location(folder, target)
|
||||
spec = importlib.util.spec_from_file_location(folder, target, submodule_search_locations=path)
|
||||
module = importlib.util.module_from_spec(spec)
|
||||
sys.modules[folder] = module
|
||||
spec.loader.exec_module(module)
|
||||
|
||||
return module
|
||||
|
Loading…
Reference in New Issue
Block a user