* [PATCH 0/1] list-packageconfig-flags.py: fix searching bitbake module failed @ 2013-08-28 4:30 Hongxu Jia 2013-08-28 4:30 ` [PATCH 1/1] " Hongxu Jia 0 siblings, 1 reply; 3+ messages in thread From: Hongxu Jia @ 2013-08-28 4:30 UTC (permalink / raw) To: openembedded-core The following changes since commit b467b99a5d25efe5eadfb07dbecba608575256ac: linux-yocto: switch genericx86 to use common-pc (2013-08-24 09:37:49 +0100) are available in the git repository at: git://git.pokylinux.org/poky-contrib hongxu/fix-list-pkgconfig http://git.pokylinux.org/cgit.cgi/poky-contrib/log/?h=hongxu/fix-list-pkgconfig Hongxu Jia (1): list-packageconfig-flags.py: fix searching bitbake module failed scripts/contrib/list-packageconfig-flags.py | 32 ++++++++++++++++++++++------- 1 file changed, 25 insertions(+), 7 deletions(-) -- 1.8.1.2 ^ permalink raw reply [flat|nested] 3+ messages in thread
* [PATCH 1/1] list-packageconfig-flags.py: fix searching bitbake module failed 2013-08-28 4:30 [PATCH 0/1] list-packageconfig-flags.py: fix searching bitbake module failed Hongxu Jia @ 2013-08-28 4:30 ` Hongxu Jia 2013-08-29 15:25 ` Paul Eggleton 0 siblings, 1 reply; 3+ messages in thread From: Hongxu Jia @ 2013-08-28 4:30 UTC (permalink / raw) To: openembedded-core Run list-packageconfig-flags.py on wrlinux's platform in which the oe-core layer and bitbake layer in different directories: ---- ../layers/oe-core/scripts/contrib/list-packageconfig-flags.py Traceback (most recent call last): File "../layers/oe-core/scripts/contrib/list-packageconfig-flags.py", line 28, in <module> import bb.cache ImportError: No module named bb.cache ---- The script import bb module from bitbake lib dir, the previous lib dir was hardcode and only worked on poky but not for others. In this situation, look for bitbake/bin dir in PATH could fix this issue. [YOCTO #5060] Signed-off-by: Hongxu Jia <hongxu.jia@windriver.com> --- scripts/contrib/list-packageconfig-flags.py | 32 ++++++++++++++++++++++------- 1 file changed, 25 insertions(+), 7 deletions(-) diff --git a/scripts/contrib/list-packageconfig-flags.py b/scripts/contrib/list-packageconfig-flags.py index 149922d..371033a 100755 --- a/scripts/contrib/list-packageconfig-flags.py +++ b/scripts/contrib/list-packageconfig-flags.py @@ -23,8 +23,26 @@ import sys import getopt import os +def search_bitbakepath(): + bitbakepath = "" + + # Search path to bitbake lib dir in order to load bb modules + if os.path.exists(os.path.join(os.path.dirname(sys.argv[0]), '../../bitbake/lib/bb')): + bitbakepath = os.path.join(os.path.dirname(sys.argv[0]), '../../bitbake/lib') + bitbakepath = os.path.abspath(bitbakepath) + else: + # Look for bitbake/bin dir in PATH + for pth in os.environ['PATH'].split(':'): + if os.path.exists(os.path.join(pth, '../lib/bb')): + bitbakepath = os.path.abspath(os.path.join(pth, '../lib')) + break + if not bitbakepath: + sys.stderr.write("Unable to find bitbake by searching parent directory of this script or PATH\n") + sys.exit(1) + return bitbakepath + # For importing the following modules -sys.path.insert(0, os.path.join(os.path.abspath(os.path.dirname(sys.argv[0])), '../../bitbake/lib')) +sys.path.insert(0, search_bitbakepath()) import bb.cache import bb.cooker import bb.providers @@ -39,12 +57,12 @@ OPTION: -p, --prefer list pkgs with preferred version EXAMPLE: -list-packageconfig-flags.py poky/meta poky/meta-yocto -list-packageconfig-flags.py -f poky/meta poky/meta-yocto -list-packageconfig-flags.py -a poky/meta poky/meta-yocto -list-packageconfig-flags.py -p poky/meta poky/meta-yocto -list-packageconfig-flags.py -f -p poky/meta poky/meta-yocto -list-packageconfig-flags.py -a -p poky/meta poky/meta-yocto +list-packageconfig-flags.py +list-packageconfig-flags.py -f +list-packageconfig-flags.py -a +list-packageconfig-flags.py -p +list-packageconfig-flags.py -f -p +list-packageconfig-flags.py -a -p ''' def usage(): -- 1.8.1.2 ^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [PATCH 1/1] list-packageconfig-flags.py: fix searching bitbake module failed 2013-08-28 4:30 ` [PATCH 1/1] " Hongxu Jia @ 2013-08-29 15:25 ` Paul Eggleton 0 siblings, 0 replies; 3+ messages in thread From: Paul Eggleton @ 2013-08-29 15:25 UTC (permalink / raw) To: Hongxu Jia, openembedded-core On Wednesday 28 August 2013 12:30:01 Hongxu Jia wrote: > Run list-packageconfig-flags.py on wrlinux's platform in which > the oe-core layer and bitbake layer in different directories: > ---- > ../layers/oe-core/scripts/contrib/list-packageconfig-flags.py > Traceback (most recent call last): > File "../layers/oe-core/scripts/contrib/list-packageconfig-flags.py", line > 28, in <module> import bb.cache > ImportError: No module named bb.cache > ---- > > The script import bb module from bitbake lib dir, the previous > lib dir was hardcode and only worked on poky but not for others. > > In this situation, look for bitbake/bin dir in PATH could fix this issue. > > [YOCTO #5060] > > Signed-off-by: Hongxu Jia <hongxu.jia@windriver.com> > --- > scripts/contrib/list-packageconfig-flags.py | 32 > ++++++++++++++++++++++------- 1 file changed, 25 insertions(+), 7 > deletions(-) > > diff --git a/scripts/contrib/list-packageconfig-flags.py > b/scripts/contrib/list-packageconfig-flags.py index 149922d..371033a 100755 > --- a/scripts/contrib/list-packageconfig-flags.py > +++ b/scripts/contrib/list-packageconfig-flags.py > @@ -23,8 +23,26 @@ import sys > import getopt > import os > > +def search_bitbakepath(): > + bitbakepath = "" > + > + # Search path to bitbake lib dir in order to load bb modules > + if os.path.exists(os.path.join(os.path.dirname(sys.argv[0]), > '../../bitbake/lib/bb')): + bitbakepath = > os.path.join(os.path.dirname(sys.argv[0]), '../../bitbake/lib') + > bitbakepath = os.path.abspath(bitbakepath) > + else: > + # Look for bitbake/bin dir in PATH > + for pth in os.environ['PATH'].split(':'): > + if os.path.exists(os.path.join(pth, '../lib/bb')): > + bitbakepath = os.path.abspath(os.path.join(pth, '../lib')) > + break > + if not bitbakepath: > + sys.stderr.write("Unable to find bitbake by searching parent > directory of this script or PATH\n") + sys.exit(1) > + return bitbakepath > + > # For importing the following modules > -sys.path.insert(0, > os.path.join(os.path.abspath(os.path.dirname(sys.argv[0])), > '../../bitbake/lib')) > +sys.path.insert(0, search_bitbakepath()) This looks fine, but I've been thinking for a while that we should have a place for shared library code just for the scripts directory in which we could put this function rather than having it repeated in a number of different scripts. I'll add an enhancement to bugzilla to do this in 1.6. > import bb.cache > import bb.cooker > import bb.providers > @@ -39,12 +57,12 @@ OPTION: > -p, --prefer list pkgs with preferred version > > EXAMPLE: > -list-packageconfig-flags.py poky/meta poky/meta-yocto > -list-packageconfig-flags.py -f poky/meta poky/meta-yocto > -list-packageconfig-flags.py -a poky/meta poky/meta-yocto > -list-packageconfig-flags.py -p poky/meta poky/meta-yocto > -list-packageconfig-flags.py -f -p poky/meta poky/meta-yocto > -list-packageconfig-flags.py -a -p poky/meta poky/meta-yocto > +list-packageconfig-flags.py > +list-packageconfig-flags.py -f > +list-packageconfig-flags.py -a > +list-packageconfig-flags.py -p > +list-packageconfig-flags.py -f -p > +list-packageconfig-flags.py -a -p > ''' > > def usage(): Acked-by: Paul Eggleton <paul.eggleton@linux.intel.com> -- Paul Eggleton Intel Open Source Technology Centre ^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2013-08-29 15:26 UTC | newest] Thread overview: 3+ messages (download: mbox.gz follow: Atom feed -- links below jump to the message on this page -- 2013-08-28 4:30 [PATCH 0/1] list-packageconfig-flags.py: fix searching bitbake module failed Hongxu Jia 2013-08-28 4:30 ` [PATCH 1/1] " Hongxu Jia 2013-08-29 15:25 ` Paul Eggleton
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox