]> git.ipfire.org Git - thirdparty/openembedded/openembedded-core.git/commitdiff
base: Switch to use addpylib directive and BB_GLOBAL_PYMODULES
authorRichard Purdie <richard.purdie@linuxfoundation.org>
Sun, 27 Nov 2022 17:08:42 +0000 (17:08 +0000)
committerRichard Purdie <richard.purdie@linuxfoundation.org>
Thu, 8 Dec 2022 11:15:02 +0000 (11:15 +0000)
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.

Also switch to using BB_GLOBAL_PYMODULES to list the global modules
to import.

Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
meta-selftest/conf/layer.conf
meta/classes-global/base.bbclass
meta/conf/layer.conf
meta/lib/oe/__init__.py

index 08998060292a3c6c546b4abc70c14f437238f4e3..889c056eb653445a8649f9a945d0f7154565965a 100644 (file)
@@ -9,4 +9,6 @@ BBFILE_COLLECTIONS += "selftest"
 BBFILE_PATTERN_selftest = "^${LAYERDIR}/"
 BBFILE_PRIORITY_selftest = "5"
 
+addpylib ${LAYERDIR}/lib oeqa
+
 LAYERSERIES_COMPAT_selftest = "kirkstone langdale"
index c81aa51ef3f66edcf24d807f7fb17eebc2647ecd..c4ac43c5696a4f7ab89a65bfd3ead132b4654d47 100644 (file)
@@ -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):
index 0ce90355baf0170be4dc8ed2cf3681bccbcf6b64..e41ada5d35d9160fb5e3b47fa19a682c3eb660c1 100644 (file)
@@ -125,3 +125,8 @@ 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}"
+
+# Only OE-Core should set/change this
+BB_GLOBAL_PYMODULES = "os sys time"
+
+addpylib ${LAYERDIR}/lib oe
index 92f002d872624b5e24ca6cf327448e6d37929a9f..47be7b51d79aaac9ccb3fd5ae3ae5529ed997104 100644 (file)
@@ -6,3 +6,7 @@
 
 from pkgutil import extend_path
 __path__ = extend_path(__path__, __name__)
+
+BBIMPORTS = ["data", "path", "utils", "types", "package", \
+             "packagegroup", "sstatesig", "lsb", "cachedpath", "license", \
+             "qa", "reproducible", "rust", "buildcfg"]