mirror of
https://git.yoctoproject.org/poky
synced 2026-09-19 09:49:33 +02:00
bitbake: utils: Avoid warnings about deprecated imp module
The imp module is deprecated, port the code over to use importlib. bitbake/lib/bb/utils.py:30: DeprecationWarning: the imp module is deprecated in favour of importlib; see the module's documentation for alternative uses import imp (Bitbake rev: 3c2cb35588e91fbd7b136e5e2c78eeb77e126c84) Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
This commit is contained in:
@@ -27,7 +27,8 @@ import bb
|
|||||||
import bb.msg
|
import bb.msg
|
||||||
import multiprocessing
|
import multiprocessing
|
||||||
import fcntl
|
import fcntl
|
||||||
import imp
|
import importlib
|
||||||
|
from importlib import machinery
|
||||||
import itertools
|
import itertools
|
||||||
import subprocess
|
import subprocess
|
||||||
import glob
|
import glob
|
||||||
@@ -43,7 +44,7 @@ from contextlib import contextmanager
|
|||||||
from ctypes import cdll
|
from ctypes import cdll
|
||||||
|
|
||||||
logger = logging.getLogger("BitBake.Util")
|
logger = logging.getLogger("BitBake.Util")
|
||||||
python_extensions = [e for e, _, _ in imp.get_suffixes()]
|
python_extensions = importlib.machinery.all_suffixes()
|
||||||
|
|
||||||
|
|
||||||
def clean_context():
|
def clean_context():
|
||||||
@@ -1544,12 +1545,9 @@ def export_proxies(d):
|
|||||||
def load_plugins(logger, plugins, pluginpath):
|
def load_plugins(logger, plugins, pluginpath):
|
||||||
def load_plugin(name):
|
def load_plugin(name):
|
||||||
logger.debug(1, 'Loading plugin %s' % name)
|
logger.debug(1, 'Loading plugin %s' % name)
|
||||||
fp, pathname, description = imp.find_module(name, [pluginpath])
|
spec = importlib.machinery.PathFinder.find_spec(name, path=[pluginpath] )
|
||||||
try:
|
if spec:
|
||||||
return imp.load_module(name, fp, pathname, description)
|
return spec.loader.load_module()
|
||||||
finally:
|
|
||||||
if fp:
|
|
||||||
fp.close()
|
|
||||||
|
|
||||||
logger.debug(1, 'Loading plugins from %s...' % pluginpath)
|
logger.debug(1, 'Loading plugins from %s...' % pluginpath)
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user