Since bitbake now supports an official method to inject python modules, switch to it.
Anyone using OE_EXTRA_IMPORTS will need to adjust their code accordingly, probably switching to their own module namespace. Signed-off-by: Richard Purdie <richard.pur...@linuxfoundation.org> --- [This patch is an RFC as part of a series on the bitbake-devel list] meta/classes-global/base.bbclass | 23 ----------------------- meta/conf/layer.conf | 2 ++ meta/lib/oe/__init__.py | 4 ++++ 3 files changed, 6 insertions(+), 23 deletions(-) diff --git a/meta/classes-global/base.bbclass b/meta/classes-global/base.bbclass index c81aa51ef3f..c4ac43c5696 100644 --- a/meta/classes-global/base.bbclass +++ b/meta/classes-global/base.bbclass @@ -15,31 +15,8 @@ inherit utils inherit utility-tasks inherit logging -OE_EXTRA_IMPORTS ?= "" - -OE_IMPORTS += "os sys time oe.path oe.utils oe.types oe.package oe.packagegroup oe.sstatesig oe.lsb oe.cachedpath oe.license oe.qa oe.reproducible oe.rust oe.buildcfg ${OE_EXTRA_IMPORTS}" -OE_IMPORTS[type] = "list" - PACKAGECONFIG_CONFARGS ??= "" -def oe_import(d): - import sys - - bbpath = [os.path.join(dir, "lib") for dir in d.getVar("BBPATH").split(":")] - sys.path[0:0] = [dir for dir in bbpath if dir not in sys.path] - - import oe.data - for toimport in oe.data.typed_value("OE_IMPORTS", d): - try: - # Make a python object accessible from the metadata - bb.utils._context[toimport.split(".", 1)[0]] = __import__(toimport) - except AttributeError as e: - bb.error("Error importing OE modules: %s" % str(e)) - return "" - -# We need the oe module name space early (before INHERITs get added) -OE_IMPORTED := "${@oe_import(d)}" - inherit metadata_scm def lsb_distro_identifier(d): diff --git a/meta/conf/layer.conf b/meta/conf/layer.conf index 0ce90355baf..0fe05beebf0 100644 --- a/meta/conf/layer.conf +++ b/meta/conf/layer.conf @@ -125,3 +125,5 @@ SSTATE_EXCLUDEDEPS_SYSROOT += ".*->autoconf-archive-native" # Avoid empty path entries BITBAKEPATH := "${@os.path.dirname(bb.utils.which(d.getVar('PATH'),'bitbake'))}" PATH := "${@'${BITBAKEPATH}:' if '${BITBAKEPATH}' != '' else ''}${HOSTTOOLS_DIR}" + +addpylib ${LAYERDIR}/lib oe diff --git a/meta/lib/oe/__init__.py b/meta/lib/oe/__init__.py index 92f002d8726..9166420b00e 100644 --- a/meta/lib/oe/__init__.py +++ b/meta/lib/oe/__init__.py @@ -6,3 +6,7 @@ from pkgutil import extend_path __path__ = extend_path(__path__, __name__) + +BBIMPORTS = ["os", "sys", "time", "oe.data", "oe.path", "oe.utils", "oe.types", "oe.package", \ + "oe.packagegroup", "oe.sstatesig", "oe.lsb", "oe.cachedpath", "oe.license", \ + "oe.qa", "oe.reproducible", "oe.rust", "oe.buildcfg"] -- 2.34.1
-=-=-=-=-=-=-=-=-=-=-=- Links: You receive all messages sent to this group. View/Reply Online (#173885): https://lists.openembedded.org/g/openembedded-core/message/173885 Mute This Topic: https://lists.openembedded.org/mt/95297771/21656 Group Owner: openembedded-core+ow...@lists.openembedded.org Unsubscribe: https://lists.openembedded.org/g/openembedded-core/unsub [arch...@mail-archive.com] -=-=-=-=-=-=-=-=-=-=-=-