diff options
Diffstat (limited to 'scripts/lib')
| -rw-r--r-- | scripts/lib/scriptutils.py | 7 | ||||
| -rw-r--r-- | scripts/lib/wic/pluginbase.py | 8 |
2 files changed, 11 insertions, 4 deletions
diff --git a/scripts/lib/scriptutils.py b/scripts/lib/scriptutils.py index 3164171eb2..47a08194d0 100644 --- a/scripts/lib/scriptutils.py +++ b/scripts/lib/scriptutils.py | |||
| @@ -18,7 +18,8 @@ import sys | |||
| 18 | import tempfile | 18 | import tempfile |
| 19 | import threading | 19 | import threading |
| 20 | import importlib | 20 | import importlib |
| 21 | from importlib import machinery | 21 | import importlib.machinery |
| 22 | import importlib.util | ||
| 22 | 23 | ||
| 23 | class KeepAliveStreamHandler(logging.StreamHandler): | 24 | class KeepAliveStreamHandler(logging.StreamHandler): |
| 24 | def __init__(self, keepalive=True, **kwargs): | 25 | def __init__(self, keepalive=True, **kwargs): |
| @@ -82,7 +83,9 @@ def load_plugins(logger, plugins, pluginpath): | |||
| 82 | logger.debug('Loading plugin %s' % name) | 83 | logger.debug('Loading plugin %s' % name) |
| 83 | spec = importlib.machinery.PathFinder.find_spec(name, path=[pluginpath] ) | 84 | spec = importlib.machinery.PathFinder.find_spec(name, path=[pluginpath] ) |
| 84 | if spec: | 85 | if spec: |
| 85 | return spec.loader.load_module() | 86 | mod = importlib.util.module_from_spec(spec) |
| 87 | spec.loader.exec_module(mod) | ||
| 88 | return mod | ||
| 86 | 89 | ||
| 87 | def plugin_name(filename): | 90 | def plugin_name(filename): |
| 88 | return os.path.splitext(os.path.basename(filename))[0] | 91 | return os.path.splitext(os.path.basename(filename))[0] |
diff --git a/scripts/lib/wic/pluginbase.py b/scripts/lib/wic/pluginbase.py index d9b4e57747..b64568339b 100644 --- a/scripts/lib/wic/pluginbase.py +++ b/scripts/lib/wic/pluginbase.py | |||
| @@ -9,9 +9,11 @@ __all__ = ['ImagerPlugin', 'SourcePlugin'] | |||
| 9 | 9 | ||
| 10 | import os | 10 | import os |
| 11 | import logging | 11 | import logging |
| 12 | import types | ||
| 12 | 13 | ||
| 13 | from collections import defaultdict | 14 | from collections import defaultdict |
| 14 | from importlib.machinery import SourceFileLoader | 15 | import importlib |
| 16 | import importlib.util | ||
| 15 | 17 | ||
| 16 | from wic import WicError | 18 | from wic import WicError |
| 17 | from wic.misc import get_bitbake_var | 19 | from wic.misc import get_bitbake_var |
| @@ -54,7 +56,9 @@ class PluginMgr: | |||
| 54 | mname = fname[:-3] | 56 | mname = fname[:-3] |
| 55 | mpath = os.path.join(ppath, fname) | 57 | mpath = os.path.join(ppath, fname) |
| 56 | logger.debug("loading plugin module %s", mpath) | 58 | logger.debug("loading plugin module %s", mpath) |
| 57 | SourceFileLoader(mname, mpath).load_module() | 59 | spec = importlib.util.spec_from_file_location(mname, mpath) |
| 60 | module = importlib.util.module_from_spec(spec) | ||
| 61 | spec.loader.exec_module(module) | ||
| 58 | 62 | ||
| 59 | return PLUGINS.get(ptype) | 63 | return PLUGINS.get(ptype) |
| 60 | 64 | ||
