From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received-SPF: Pass (sender SPF authorized) identity=mailfrom; client-ip=195.135.221.5; helo=smtp.nue.novell.com; envelope-from=glin@suse.com; receiver=edk2-devel@lists.01.org Received: from smtp.nue.novell.com (smtp.nue.novell.com [195.135.221.5]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ml01.01.org (Postfix) with ESMTPS id 3488C211F8862 for ; Wed, 11 Jul 2018 21:24:22 -0700 (PDT) Received: from emea4-mta.ukb.novell.com ([10.120.13.87]) by smtp.nue.novell.com with ESMTP (TLS encrypted); Thu, 12 Jul 2018 06:24:21 +0200 Received: from GaryWorkstation (nwb-a10-snat.microfocus.com [10.120.13.202]) by emea4-mta.ukb.novell.com with ESMTP (TLS encrypted); Thu, 12 Jul 2018 05:23:49 +0100 Date: Thu, 12 Jul 2018 12:23:45 +0800 From: Gary Lin To: "Zhu, Yonghong" Cc: "edk2-devel@lists.01.org" , "Gao, Liming" Message-ID: <20180712042345.mxjjignydrd33kmz@GaryWorkstation> References: <20180710033107.32359-1-glin@suse.com> <20180710033107.32359-8-glin@suse.com> MIME-Version: 1.0 In-Reply-To: User-Agent: NeoMutt/20170912 (1.9.0) Subject: Re: [PATCH 07/14] BaseTools: Use absolute import in BPDG X-BeenThere: edk2-devel@lists.01.org X-Mailman-Version: 2.1.27 Precedence: list List-Id: EDK II Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 12 Jul 2018 04:24:23 -0000 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline On Thu, Jul 12, 2018 at 12:52:32AM +0000, Zhu, Yonghong wrote: > Hi Gary, > > I got below error: > > Traceback (most recent call last): > File "C:\TCWork\Edk2\BaseTools\Source\Python\BPDG\BPDG.py", line 34, in > from . import StringTable as st > ValueError: Attempted relative import in non-package > Hmmm, so BPDG also uses the module in its own directory. I'll modify BPDG in BinWrappers as GenFds. Thanks, Gary Lin > Best Regards, > Zhu Yonghong > > > -----Original Message----- > From: Gary Lin [mailto:glin@suse.com] > Sent: Tuesday, July 10, 2018 11:31 AM > To: edk2-devel@lists.01.org > Cc: Zhu, Yonghong ; Gao, Liming > Subject: [PATCH 07/14] BaseTools: Use absolute import in BPDG > > Based on "futurize -f libfuturize.fixes.fix_absolute_import > > Contributed-under: TianoCore Contribution Agreement 1.1 > Cc: Yonghong Zhu > Cc: Liming Gao > Signed-off-by: Gary Lin > --- > BaseTools/Source/Python/BPDG/BPDG.py | 5 +++-- > BaseTools/Source/Python/BPDG/GenVpd.py | 3 ++- > 2 files changed, 5 insertions(+), 3 deletions(-) > > diff --git a/BaseTools/Source/Python/BPDG/BPDG.py b/BaseTools/Source/Python/BPDG/BPDG.py > index 07cee8976208..2ec1516c0a08 100644 > --- a/BaseTools/Source/Python/BPDG/BPDG.py > +++ b/BaseTools/Source/Python/BPDG/BPDG.py > @@ -21,6 +21,7 @@ > # Import Modules > # > from __future__ import print_function > +from __future__ import absolute_import > import Common.LongFilePathOs as os > import sys > import encodings.ascii > @@ -30,8 +31,8 @@ from Common import EdkLogger from Common.BuildToolError import * from Common.BuildVersion import gBUILD_VERSION > > -import StringTable as st > -import GenVpd > +from . import StringTable as st > +from . import GenVpd > > PROJECT_NAME = st.LBL_BPDG_LONG_UNI > VERSION = (st.LBL_BPDG_VERSION + " Build " + gBUILD_VERSION) > diff --git a/BaseTools/Source/Python/BPDG/GenVpd.py b/BaseTools/Source/Python/BPDG/GenVpd.py > index 2eefcc24905f..cd272a2d9a79 100644 > --- a/BaseTools/Source/Python/BPDG/GenVpd.py > +++ b/BaseTools/Source/Python/BPDG/GenVpd.py > @@ -13,9 +13,10 @@ > # WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. > # > > +from __future__ import absolute_import > import Common.LongFilePathOs as os > from io import BytesIO > -import StringTable as st > +from . import StringTable as st > import array > import re > from Common.LongFilePathSupport import OpenLongFilePath as open > -- > 2.18.0 > >