From 351a2526d60238ee67b7cf363578e9bc152a26cb Mon Sep 17 00:00:00 2001 From: Paul Eggleton Date: Thu, 19 Apr 2018 16:17:43 +1200 Subject: [PATCH] utils: add function to add meta/lib/oe to sys.path Add a function that lets us import OE python modules easily. Signed-off-by: Paul Eggleton --- layerindex/utils.py | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/layerindex/utils.py b/layerindex/utils.py index ebcfcaf..093ba14 100644 --- a/layerindex/utils.py +++ b/layerindex/utils.py @@ -341,3 +341,15 @@ def chain_unique(*iterables): if k not in seen: seen.add(k) yield item + +def setup_core_layer_sys_path(settings, branchname): + """ + Add OE-Core's lib/oe directory to sys.path in order to allow importing + OE python modules + """ + core_layer = get_layer(settings.CORE_LAYER_NAME) + core_layerbranch = core_layer.get_layerbranch(branchname) + core_urldir = core_layer.get_fetch_dir() + core_repodir = os.path.join(settings.LAYER_FETCH_DIR, core_urldir) + core_layerdir = os.path.join(core_repodir, core_layerbranch.vcs_subdir) + sys.path.insert(0, os.path.join(core_layerdir, 'lib'))