From: Uladzimir Bely <ubely@ilbers.de>
To: isar-users@googlegroups.com
Subject: [PATCH v3 1/5] oe imports in central location
Date: Fri, 19 Nov 2021 10:24:55 +0100 [thread overview]
Message-ID: <20211119092459.27376-2-ubely@ilbers.de> (raw)
In-Reply-To: <20211119092459.27376-1-ubely@ilbers.de>
From: Adriaan Schmidt <adriaan.schmidt@siemens.com>
Code taken from OE. Allows to import OE modules
without first setting python paths manually.
Signed-off-by: Adriaan Schmidt <adriaan.schmidt@siemens.com>
---
meta/classes/base.bbclass | 28 ++++++++++++++++++++++++++++
meta/classes/dpkg-base.bbclass | 5 -----
meta/classes/patch.bbclass | 5 -----
3 files changed, 28 insertions(+), 10 deletions(-)
diff --git a/meta/classes/base.bbclass b/meta/classes/base.bbclass
index 72d4cc0b..13134fff 100644
--- a/meta/classes/base.bbclass
+++ b/meta/classes/base.bbclass
@@ -21,6 +21,34 @@
THISDIR = "${@os.path.dirname(d.getVar('FILE', True))}"
FILESPATH = "${@base_set_filespath(["${FILE_DIRNAME}/${PF}", "${FILE_DIRNAME}/${P}", "${FILE_DIRNAME}/${PN}", "${FILE_DIRNAME}/files", "${FILE_DIRNAME}"], d)}"
+OE_IMPORTS += "os sys time oe.path oe.patch"
+OE_IMPORTS[type] = "list"
+
+def oe_import(d):
+ import sys
+
+ bbpath = d.getVar("BBPATH").split(":")
+ sys.path[0:0] = [os.path.join(dir, "lib") for dir in bbpath]
+
+ def inject(name, value):
+ """Make a python object accessible from the metadata"""
+ if hasattr(bb.utils, "_context"):
+ bb.utils._context[name] = value
+ else:
+ __builtins__[name] = value
+
+ import oe.data
+ for toimport in oe.data.typed_value("OE_IMPORTS", d):
+ try:
+ imported = __import__(toimport)
+ inject(toimport.split(".", 1)[0], imported)
+ 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)}"
+
def get_deb_host_arch():
import subprocess
host_arch = subprocess.check_output(
diff --git a/meta/classes/dpkg-base.bbclass b/meta/classes/dpkg-base.bbclass
index 8bbc4165..2af15f93 100644
--- a/meta/classes/dpkg-base.bbclass
+++ b/meta/classes/dpkg-base.bbclass
@@ -248,11 +248,6 @@ do_deploy_deb[lockfiles] = "${REPO_ISAR_DIR}/isar.lock"
do_deploy_deb[dirs] = "${S}"
python do_devshell() {
- import sys
-
- oe_lib_path = os.path.join(d.getVar('LAYERDIR_core'), 'lib')
- sys.path.insert(0, oe_lib_path)
-
bb.build.exec_func('dpkg_do_mounts', d)
isar_export_proxies(d)
diff --git a/meta/classes/patch.bbclass b/meta/classes/patch.bbclass
index 3060755a..2337693d 100644
--- a/meta/classes/patch.bbclass
+++ b/meta/classes/patch.bbclass
@@ -92,11 +92,6 @@ def should_apply(parm, d):
should_apply[vardepsexclude] = "DATE SRCDATE"
python patch_do_patch() {
- import sys
-
- oe_lib_path = os.path.join(d.getVar('LAYERDIR_core'), 'lib')
- sys.path.insert(0, oe_lib_path)
-
import oe.patch
patchsetmap = {
--
2.20.1
next prev parent reply other threads:[~2021-11-19 9:25 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-11-19 9:24 [PATCH v3 0/5] Use buildstats from OE to generate build charts Uladzimir Bely
2021-11-19 9:24 ` Uladzimir Bely [this message]
2021-11-19 9:24 ` [PATCH v3 2/5] buildstats: Borrow buildstats and pybootchartgui from OE Uladzimir Bely
2021-11-19 9:24 ` [PATCH v3 3/5] buildstats: Fixes to work with bbclass in ISAR Uladzimir Bely
2021-11-19 9:24 ` [PATCH v3 4/5] buildstats: Enable buildstats in default configuration Uladzimir Bely
2021-11-19 9:24 ` [PATCH v3 5/5] doc: Add buildstats section in user manual Uladzimir Bely
2021-12-01 13:24 ` [PATCH v3 0/5] Use buildstats from OE to generate build charts Anton Mikanovich
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20211119092459.27376-2-ubely@ilbers.de \
--to=ubely@ilbers.de \
--cc=isar-users@googlegroups.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox