[oe] [PATCH 1/2] base.bbclass: add <dir>/lib for each dir in BBPATH to the python search path

Chris Larson clarson at kergoth.com
Tue Apr 20 00:49:50 UTC 2010


From: Chris Larson <chris_larson at mentor.com>

Also makes the os, time, and bb package availability explicit.

Signed-off-by: Chris Larson <chris_larson at mentor.com>
---
 classes/base.bbclass |   23 +++++++++++++++++++++++
 1 files changed, 23 insertions(+), 0 deletions(-)

diff --git a/classes/base.bbclass b/classes/base.bbclass
index d3bfa76..a738cec 100644
--- a/classes/base.bbclass
+++ b/classes/base.bbclass
@@ -9,6 +9,29 @@ inherit utils
 inherit utility-tasks
 inherit metadata_scm
 
+python sys_path_eh () {
+    if isinstance(e, bb.event.ConfigParsed):
+        import sys
+        import os
+        import time
+
+        bbpath = e.data.getVar("BBPATH", True).split(":")
+        sys.path[0:0] = [os.path.join(dir, "lib") for dir in bbpath]
+
+        def inject(name, value):
+            """Make a python object accessible from everywhere for the metadata"""
+            if hasattr(bb.utils, "_context"):
+                bb.utils._context[name] = value
+            else:
+                __builtins__[name] = value
+
+        inject("bb", bb)
+        inject("sys", sys)
+        inject("time", time)
+}
+
+addhandler sys_path_eh
+
 die() {
 	oefatal "$*"
 }
-- 
1.6.3.3





More information about the Openembedded-devel mailing list