diff options
author | Richard Purdie <richard.purdie@linuxfoundation.org> | 2022-11-27 17:08:42 +0000 |
---|---|---|
committer | Richard Purdie <richard.purdie@linuxfoundation.org> | 2022-12-08 11:15:47 +0000 |
commit | 4901c9d471cab99d52876842980222ce271b66e4 (patch) | |
tree | f50450c9081ed060b95c77d04370bd2391f2adb1 | |
parent | d0ea143156f2808ab684b3d73fec039d2a62f229 (diff) | |
download | poky-4901c9d471cab99d52876842980222ce271b66e4.tar.gz |
base: Switch to use addpylib directive and BB_GLOBAL_PYMODULES
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.
(From OE-Core rev: 1f56155e91da2030ee0a5e93037c62e1349ba89f)
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
-rw-r--r-- | meta-selftest/conf/layer.conf | 2 | ||||
-rw-r--r-- | meta/classes-global/base.bbclass | 23 | ||||
-rw-r--r-- | meta/conf/layer.conf | 5 | ||||
-rw-r--r-- | meta/lib/oe/__init__.py | 4 |
4 files changed, 11 insertions, 23 deletions
diff --git a/meta-selftest/conf/layer.conf b/meta-selftest/conf/layer.conf index 0899806029..889c056eb6 100644 --- a/meta-selftest/conf/layer.conf +++ b/meta-selftest/conf/layer.conf | |||
@@ -9,4 +9,6 @@ BBFILE_COLLECTIONS += "selftest" | |||
9 | BBFILE_PATTERN_selftest = "^${LAYERDIR}/" | 9 | BBFILE_PATTERN_selftest = "^${LAYERDIR}/" |
10 | BBFILE_PRIORITY_selftest = "5" | 10 | BBFILE_PRIORITY_selftest = "5" |
11 | 11 | ||
12 | addpylib ${LAYERDIR}/lib oeqa | ||
13 | |||
12 | LAYERSERIES_COMPAT_selftest = "kirkstone langdale" | 14 | LAYERSERIES_COMPAT_selftest = "kirkstone langdale" |
diff --git a/meta/classes-global/base.bbclass b/meta/classes-global/base.bbclass index c81aa51ef3..c4ac43c569 100644 --- a/meta/classes-global/base.bbclass +++ b/meta/classes-global/base.bbclass | |||
@@ -15,31 +15,8 @@ inherit utils | |||
15 | inherit utility-tasks | 15 | inherit utility-tasks |
16 | inherit logging | 16 | inherit logging |
17 | 17 | ||
18 | OE_EXTRA_IMPORTS ?= "" | ||
19 | |||
20 | 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}" | ||
21 | OE_IMPORTS[type] = "list" | ||
22 | |||
23 | PACKAGECONFIG_CONFARGS ??= "" | 18 | PACKAGECONFIG_CONFARGS ??= "" |
24 | 19 | ||
25 | def oe_import(d): | ||
26 | import sys | ||
27 | |||
28 | bbpath = [os.path.join(dir, "lib") for dir in d.getVar("BBPATH").split(":")] | ||
29 | sys.path[0:0] = [dir for dir in bbpath if dir not in sys.path] | ||
30 | |||
31 | import oe.data | ||
32 | for toimport in oe.data.typed_value("OE_IMPORTS", d): | ||
33 | try: | ||
34 | # Make a python object accessible from the metadata | ||
35 | bb.utils._context[toimport.split(".", 1)[0]] = __import__(toimport) | ||
36 | except AttributeError as e: | ||
37 | bb.error("Error importing OE modules: %s" % str(e)) | ||
38 | return "" | ||
39 | |||
40 | # We need the oe module name space early (before INHERITs get added) | ||
41 | OE_IMPORTED := "${@oe_import(d)}" | ||
42 | |||
43 | inherit metadata_scm | 20 | inherit metadata_scm |
44 | 21 | ||
45 | def lsb_distro_identifier(d): | 22 | def lsb_distro_identifier(d): |
diff --git a/meta/conf/layer.conf b/meta/conf/layer.conf index 0ce90355ba..e41ada5d35 100644 --- a/meta/conf/layer.conf +++ b/meta/conf/layer.conf | |||
@@ -125,3 +125,8 @@ SSTATE_EXCLUDEDEPS_SYSROOT += ".*->autoconf-archive-native" | |||
125 | # Avoid empty path entries | 125 | # Avoid empty path entries |
126 | BITBAKEPATH := "${@os.path.dirname(bb.utils.which(d.getVar('PATH'),'bitbake'))}" | 126 | BITBAKEPATH := "${@os.path.dirname(bb.utils.which(d.getVar('PATH'),'bitbake'))}" |
127 | PATH := "${@'${BITBAKEPATH}:' if '${BITBAKEPATH}' != '' else ''}${HOSTTOOLS_DIR}" | 127 | PATH := "${@'${BITBAKEPATH}:' if '${BITBAKEPATH}' != '' else ''}${HOSTTOOLS_DIR}" |
128 | |||
129 | # Only OE-Core should set/change this | ||
130 | BB_GLOBAL_PYMODULES = "os sys time" | ||
131 | |||
132 | addpylib ${LAYERDIR}/lib oe | ||
diff --git a/meta/lib/oe/__init__.py b/meta/lib/oe/__init__.py index 92f002d872..47be7b51d7 100644 --- a/meta/lib/oe/__init__.py +++ b/meta/lib/oe/__init__.py | |||
@@ -6,3 +6,7 @@ | |||
6 | 6 | ||
7 | from pkgutil import extend_path | 7 | from pkgutil import extend_path |
8 | __path__ = extend_path(__path__, __name__) | 8 | __path__ = extend_path(__path__, __name__) |
9 | |||
10 | BBIMPORTS = ["data", "path", "utils", "types", "package", \ | ||
11 | "packagegroup", "sstatesig", "lsb", "cachedpath", "license", \ | ||
12 | "qa", "reproducible", "rust", "buildcfg"] | ||