From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mga11.intel.com (mga11.intel.com [192.55.52.93]) by mail.openembedded.org (Postfix) with ESMTP id 4BCAF6BCF4 for ; Thu, 29 Aug 2013 15:26:01 +0000 (UTC) Received: from fmsmga001.fm.intel.com ([10.253.24.23]) by fmsmga102.fm.intel.com with ESMTP; 29 Aug 2013 08:26:01 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="4.89,984,1367996400"; d="scan'208";a="388332164" Received: from unknown (HELO helios.localnet) ([10.252.123.55]) by fmsmga001.fm.intel.com with ESMTP; 29 Aug 2013 08:26:00 -0700 From: Paul Eggleton To: Hongxu Jia , openembedded-core@lists.openembedded.org Date: Thu, 29 Aug 2013 16:25:59 +0100 Message-ID: <2059010.0EkyrxoSPo@helios> Organization: Intel Corporation User-Agent: KMail/4.10.5 (Linux/3.8.0-27-generic; KDE/4.10.5; i686; ; ) In-Reply-To: <08dbbf71b281261919744307654a91bf3d452d18.1377660850.git.hongxu.jia@windriver.com> References: <08dbbf71b281261919744307654a91bf3d452d18.1377660850.git.hongxu.jia@windriver.com> MIME-Version: 1.0 Subject: Re: [PATCH 1/1] list-packageconfig-flags.py: fix searching bitbake module failed X-BeenThere: openembedded-core@lists.openembedded.org X-Mailman-Version: 2.1.12 Precedence: list List-Id: Patches and discussions about the oe-core layer List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 29 Aug 2013 15:26:02 -0000 Content-Transfer-Encoding: 7Bit Content-Type: text/plain; charset="us-ascii" 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 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 > --- > 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 Intel Open Source Technology Centre