Skip to contentSkip to conversation

base.bbclass: add <dir>/lib for each dir in BBPATH to the python search path

PATCH New Chris Larson 1 participant 2 messages Apr 20, 2010

lore
Share & tools
lore
#0 lore raw

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

From: Chris Larson <[email protected]>

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

---
 classes/base.bbclass |   23 +++++++++++++++++++++++
 1 files changed, 23 insertions(+), 0 deletions(-)
classes/base.bbclass +23 -0
index d3bfa76..a738cec 100644
@@ -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 "$*"
 }
Signature · 1 line
1.6.3.3
#1 lore raw

PATCH 2/2 Initial move of common python bits into modules of the 'oe' python package

From: Chris Larson <[email protected]>

---
 classes/base.bbclass   |    3 +
 classes/insane.bbclass |   85 +---------
 classes/patch.bbclass  |  466 ++----------------------------------------------
 classes/utils.bbclass  |  158 +++++------------
 lib/oe/patch.py        |  407 ++++++++++++++++++++++++++++++++++++++++++
 lib/oe/path.py         |   46 +++++
 lib/oe/qa.py           |   76 ++++++++
 lib/oe/utils.py        |   69 +++++++
 8 files changed, 657 insertions(+), 653 deletions(-)
 create mode 100644 lib/oe/__init__.py
 create mode 100644 lib/oe/patch.py
 create mode 100644 lib/oe/path.py
 create mode 100644 lib/oe/qa.py
 create mode 100644 lib/oe/utils.py
classes/base.bbclass +3 -0
index a738cec..f3c9428 100644
@@ -25,9 +25,12 @@ python sys_path_eh () {
             else:
                 __builtins__[name] = value
 
+        import oe.path
+        import oe.utils
         inject("bb", bb)
         inject("sys", sys)
         inject("time", time)
+        inject("oe", oe)
 }
 
 addhandler sys_path_eh
classes/insane.bbclass +3 -82

106 lines not on this page · raw message

classes/patch.bbclass +12 -454

497 lines not on this page · raw message

classes/utils.bbclass +41 -117

173 lines not on this page · raw message

lib/oe/__init__.py new file +0 -0
new file mode 100644
index 0000000..e69de29
lib/oe/patch.py new file +407 -0

407 lines not on this page · raw message

lib/oe/path.py new file +46 -0

46 lines not on this page · raw message

lib/oe/qa.py new file +76 -0

76 lines not on this page · raw message

lib/oe/utils.py new file +69 -0

69 lines not on this page · raw message

Signature · 1 line
1.6.3.3