public inbox for devel@edk2.groups.io
 help / color / mirror / Atom feed
From: Gary Lin <glin@suse.com>
To: edk2-devel@lists.01.org
Cc: Yonghong Zhu <yonghong.zhu@intel.com>, Liming Gao <liming.gao@intel.com>
Subject: [PATCH v3 17/20] BaseTools: Adopt absolute import for python scripts
Date: Thu, 21 Jun 2018 12:43:43 +0800	[thread overview]
Message-ID: <20180621044346.28495-18-glin@suse.com> (raw)
In-Reply-To: <20180621044346.28495-1-glin@suse.com>

Based on "futurize -f libfuturize.fixes.fix_absolute_import"

Since circular import is not allowed after adopting absolute import, the
following changes are applied to break the circles.

* BaseTools/Source/Python/GenFds/Capsule.py
  - Delay "from .GenFds import GenFds" until GenCapsule()
  - Delay "from .GenFds import FindExtendTool" until GenFmpCapsule()
  To break the circle:
  AutoGen.AutoGen => GenFds.FdfParser => GenFds.Capsule => GenFds.GenFds =>
  GenFds.FdfParser

* BaseTools/Source/Python/GenFds/Fd.py
  - Delay "from .GenFds import GenFds" until GenFd()
  To break the circle:
  AutoGen.AutoGen => GenFds.FdfParser => GenFds.Fd => GenFds.GenFds =>
  GenFds.FdfParser

* BaseTools/Source/Python/GenFds/Fv.py
  - Delay "from .GenFds import GenFds" until AddToBuffer()
  To break the circle:
  AutoGen.AutoGen => GenFds.FdfParser => GenFds.Fd => GenFds.Fv =>
  GenFds.GenFds => GenFds.FdfParser

* BaseTools/Source/Python/GenFds/GuidSection.py
  - Delay "from .GenFds import FindExtendTool" until GuidSection()
  To break the circle:
  AutoGen.AutoGen => GenFds.FdfParser => GenFds.Fd => GenFds.Fv =>
  GenFds.AprioriSection => GenFds.FfsFileStatement => GenFds.GuidSection =>
  GenFds.GenFds => GenFds.FdfParser

* BaseTools/Source/Python/GenFds/OptRomInfStatement.py
  - Delay "from . import OptionRom" until __GetOptRomParams()
  To break the circle:
  AutoGen.AutoGen => GenFds.FdfParser => GenFds.OptionRom =>
  GenFds.OptRomInfStatement => GenFds.OptionRom

* BaseTools/Source/Python/GenFds/OptionRom.py
  - Remove the unused "from .GenFds import GenFds"
  To break the circle:
  AutoGen.AutoGen => GenFds.FdfParser => GenFds.OptionRom =>
  GenFds.GenFds => GenFds.FdfParser

Contributed-under: TianoCore Contribution Agreement 1.1
Cc: Yonghong Zhu <yonghong.zhu@intel.com>
Cc: Liming Gao <liming.gao@intel.com>
Signed-off-by: Gary Lin <glin@suse.com>
---
 BaseTools/Scripts/PackageDocumentTools/packagedoc_cli.py                       |  5 +-
 BaseTools/Scripts/PackageDocumentTools/plugins/EdkPlugins/basemodel/doxygen.py |  3 +-
 BaseTools/Scripts/PackageDocumentTools/plugins/EdkPlugins/basemodel/ini.py     |  3 +-
 BaseTools/Source/Python/AutoGen/AutoGen.py                                     | 17 +++---
 BaseTools/Source/Python/AutoGen/GenC.py                                        |  7 +--
 BaseTools/Source/Python/AutoGen/GenMake.py                                     |  3 +-
 BaseTools/Source/Python/AutoGen/GenPcdDb.py                                    |  7 +--
 BaseTools/Source/Python/AutoGen/IdfClassObject.py                              |  3 +-
 BaseTools/Source/Python/AutoGen/StrGather.py                                   |  3 +-
 BaseTools/Source/Python/BPDG/BPDG.py                                           |  5 +-
 BaseTools/Source/Python/BPDG/GenVpd.py                                         |  3 +-
 BaseTools/Source/Python/Common/Database.py                                     |  9 ++--
 BaseTools/Source/Python/Common/EdkLogger.py                                    |  3 +-
 BaseTools/Source/Python/Common/Expression.py                                   |  3 +-
 BaseTools/Source/Python/Common/LongFilePathOs.py                               |  3 +-
 BaseTools/Source/Python/Common/Misc.py                                         |  9 ++--
 BaseTools/Source/Python/Common/Parsing.py                                      |  5 +-
 BaseTools/Source/Python/Common/StringUtils.py                                  |  9 ++--
 BaseTools/Source/Python/Common/TargetTxtClassObject.py                         |  9 ++--
 BaseTools/Source/Python/Common/ToolDefClassObject.py                           |  9 ++--
 BaseTools/Source/Python/Ecc/CParser.py                                         |  5 +-
 BaseTools/Source/Python/Ecc/Check.py                                           |  9 ++--
 BaseTools/Source/Python/Ecc/CodeFragmentCollector.py                           | 13 ++---
 BaseTools/Source/Python/Ecc/Database.py                                        |  7 +--
 BaseTools/Source/Python/Ecc/Ecc.py                                             | 25 ++++-----
 BaseTools/Source/Python/Ecc/Exception.py                                       |  3 +-
 BaseTools/Source/Python/Ecc/FileProfile.py                                     |  5 +-
 BaseTools/Source/Python/Ecc/MetaDataParser.py                                  |  5 +-
 BaseTools/Source/Python/Ecc/MetaFileWorkspace/MetaFileParser.py                |  3 +-
 BaseTools/Source/Python/Ecc/MetaFileWorkspace/MetaFileTable.py                 |  5 +-
 BaseTools/Source/Python/Ecc/c.py                                               | 13 ++---
 BaseTools/Source/Python/Eot/CParser.py                                         |  5 +-
 BaseTools/Source/Python/Eot/CodeFragmentCollector.py                           | 11 ++--
 BaseTools/Source/Python/Eot/Eot.py                                             | 21 ++++----
 BaseTools/Source/Python/Eot/FileProfile.py                                     |  3 +-
 BaseTools/Source/Python/Eot/InfParserLite.py                                   |  5 +-
 BaseTools/Source/Python/Eot/Parser.py                                          |  3 +-
 BaseTools/Source/Python/Eot/Report.py                                          |  3 +-
 BaseTools/Source/Python/Eot/c.py                                               |  9 ++--
 BaseTools/Source/Python/GenFds/AprioriSection.py                               |  5 +-
 BaseTools/Source/Python/GenFds/Capsule.py                                      |  7 +--
 BaseTools/Source/Python/GenFds/CapsuleData.py                                  |  5 +-
 BaseTools/Source/Python/GenFds/CompressSection.py                              |  7 +--
 BaseTools/Source/Python/GenFds/DataSection.py                                  |  7 +--
 BaseTools/Source/Python/GenFds/DepexSection.py                                 |  7 +--
 BaseTools/Source/Python/GenFds/EfiSection.py                                   |  7 +--
 BaseTools/Source/Python/GenFds/Fd.py                                           |  9 ++--
 BaseTools/Source/Python/GenFds/FdfParser.py                                    | 55 ++++++++++----------
 BaseTools/Source/Python/GenFds/FfsFileStatement.py                             | 11 ++--
 BaseTools/Source/Python/GenFds/FfsInfStatement.py                              | 19 +++----
 BaseTools/Source/Python/GenFds/Fv.py                                           | 11 ++--
 BaseTools/Source/Python/GenFds/FvImageSection.py                               |  7 +--
 BaseTools/Source/Python/GenFds/GenFds.py                                       | 11 ++--
 BaseTools/Source/Python/GenFds/GuidSection.py                                  | 11 ++--
 BaseTools/Source/Python/GenFds/OptRomFileStatement.py                          |  3 +-
 BaseTools/Source/Python/GenFds/OptRomInfStatement.py                           | 15 +++---
 BaseTools/Source/Python/GenFds/OptionRom.py                                    |  6 +--
 BaseTools/Source/Python/GenFds/Region.py                                       |  3 +-
 BaseTools/Source/Python/GenFds/RuleComplexFile.py                              |  3 +-
 BaseTools/Source/Python/GenFds/RuleSimpleFile.py                               |  3 +-
 BaseTools/Source/Python/GenFds/Section.py                                      |  3 +-
 BaseTools/Source/Python/GenFds/UiSection.py                                    |  7 +--
 BaseTools/Source/Python/GenFds/VerSection.py                                   |  7 +--
 BaseTools/Source/Python/GenFds/Vtf.py                                          |  3 +-
 BaseTools/Source/Python/Table/TableDataModel.py                                |  3 +-
 BaseTools/Source/Python/Table/TableDec.py                                      |  3 +-
 BaseTools/Source/Python/Table/TableDsc.py                                      |  3 +-
 BaseTools/Source/Python/Table/TableEotReport.py                                |  5 +-
 BaseTools/Source/Python/Table/TableFdf.py                                      |  3 +-
 BaseTools/Source/Python/Table/TableFile.py                                     |  3 +-
 BaseTools/Source/Python/Table/TableFunction.py                                 |  3 +-
 BaseTools/Source/Python/Table/TableIdentifier.py                               |  5 +-
 BaseTools/Source/Python/Table/TableInf.py                                      |  3 +-
 BaseTools/Source/Python/Table/TablePcd.py                                      |  5 +-
 BaseTools/Source/Python/Table/TableQuery.py                                    |  3 +-
 BaseTools/Source/Python/Table/TableReport.py                                   |  3 +-
 BaseTools/Source/Python/UPT/Library/Parsing.py                                 |  3 +-
 BaseTools/Source/Python/Workspace/DscBuildData.py                              |  9 ++--
 BaseTools/Source/Python/Workspace/InfBuildData.py                              |  3 +-
 BaseTools/Source/Python/Workspace/MetaFileParser.py                            |  5 +-
 BaseTools/Source/Python/Workspace/MetaFileTable.py                             |  5 +-
 BaseTools/Source/Python/Workspace/WorkspaceCommon.py                           |  3 +-
 BaseTools/Source/Python/Workspace/WorkspaceDatabase.py                         |  7 +--
 BaseTools/Source/Python/build/build.py                                         |  3 +-
 84 files changed, 333 insertions(+), 250 deletions(-)

diff --git a/BaseTools/Scripts/PackageDocumentTools/packagedoc_cli.py b/BaseTools/Scripts/PackageDocumentTools/packagedoc_cli.py
index b45b5e69bc54..f2223d82d662 100644
--- a/BaseTools/Scripts/PackageDocumentTools/packagedoc_cli.py
+++ b/BaseTools/Scripts/PackageDocumentTools/packagedoc_cli.py
@@ -13,12 +13,13 @@
 #
 
 from __future__ import print_function
+from __future__ import absolute_import
 from builtins import range
 import os, sys, logging, traceback, subprocess
 from optparse import OptionParser
 
-import plugins.EdkPlugins.edk2.model.baseobject as baseobject
-import plugins.EdkPlugins.edk2.model.doxygengen as doxygengen
+from . import plugins.EdkPlugins.edk2.model.baseobject as baseobject
+from . import plugins.EdkPlugins.edk2.model.doxygengen as doxygengen
 
 gArchMarcoDict = {'ALL'      : 'MDE_CPU_IA32 MDE_CPU_X64 MDE_CPU_EBC MDE_CPU_IPF _MSC_EXTENSIONS __GNUC__ __INTEL_COMPILER',
                   'IA32_MSFT': 'MDE_CPU_IA32 _MSC_EXTENSIONS',
diff --git a/BaseTools/Scripts/PackageDocumentTools/plugins/EdkPlugins/basemodel/doxygen.py b/BaseTools/Scripts/PackageDocumentTools/plugins/EdkPlugins/basemodel/doxygen.py
index b5ab213cd7f0..d1e21135cf05 100644
--- a/BaseTools/Scripts/PackageDocumentTools/plugins/EdkPlugins/basemodel/doxygen.py
+++ b/BaseTools/Scripts/PackageDocumentTools/plugins/EdkPlugins/basemodel/doxygen.py
@@ -12,9 +12,10 @@
 #
 
 from __future__ import print_function
+from __future__ import absolute_import
 import os
 
-from message import *
+from .message import *
 
 class BaseDoxygeItem:
     def __init__(self, name, tag=''):
diff --git a/BaseTools/Scripts/PackageDocumentTools/plugins/EdkPlugins/basemodel/ini.py b/BaseTools/Scripts/PackageDocumentTools/plugins/EdkPlugins/basemodel/ini.py
index 0e9b105b3647..61c344864e32 100644
--- a/BaseTools/Scripts/PackageDocumentTools/plugins/EdkPlugins/basemodel/ini.py
+++ b/BaseTools/Scripts/PackageDocumentTools/plugins/EdkPlugins/basemodel/ini.py
@@ -11,8 +11,9 @@
 # WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
 #
 
+from __future__ import absolute_import
 from builtins import range
-from message import *
+from .message import *
 import re
 import os
 
diff --git a/BaseTools/Source/Python/AutoGen/AutoGen.py b/BaseTools/Source/Python/AutoGen/AutoGen.py
index 8fa5c6f306f3..2cc31cf95d83 100644
--- a/BaseTools/Source/Python/AutoGen/AutoGen.py
+++ b/BaseTools/Source/Python/AutoGen/AutoGen.py
@@ -16,6 +16,7 @@
 ## Import Modules
 #
 from __future__ import print_function
+from __future__ import absolute_import
 from builtins import range
 import Common.LongFilePathOs as os
 import re
@@ -23,13 +24,13 @@ import os.path as path
 import copy
 import uuid
 
-import GenC
-import GenMake
-import GenDepex
+from . import GenC
+from . import GenMake
+from . import GenDepex
 from io import BytesIO
 
-from StrGather import *
-from BuildEngine import BuildRule
+from .StrGather import *
+from .BuildEngine import BuildRule
 
 from Common.LongFilePathSupport import CopyLongFilePath
 from Common.BuildToolError import *
@@ -42,14 +43,14 @@ from CommonDataClass.CommonClass import SkuInfoClass
 from Workspace.BuildClassObject import *
 from GenPatchPcdTable.GenPatchPcdTable import parsePcdInfoFromMapFile
 import Common.VpdInfoFile as VpdInfoFile
-from GenPcdDb import CreatePcdDatabaseCode
+from .GenPcdDb import CreatePcdDatabaseCode
 from Workspace.MetaFileCommentParser import UsageList
 from Workspace.WorkspaceCommon import GetModuleLibInstances
 from Common.MultipleWorkspace import MultipleWorkspace as mws
-import InfSectionParser
+from . import InfSectionParser
 import datetime
 import hashlib
-from GenVar import VariableMgr, var_info
+from .GenVar import VariableMgr, var_info
 from collections import OrderedDict
 from collections import defaultdict
 from Workspace.WorkspaceCommon import OrderedListDict
diff --git a/BaseTools/Source/Python/AutoGen/GenC.py b/BaseTools/Source/Python/AutoGen/GenC.py
index b0af4bc88d97..8f8cb4c4a491 100644
--- a/BaseTools/Source/Python/AutoGen/GenC.py
+++ b/BaseTools/Source/Python/AutoGen/GenC.py
@@ -13,6 +13,7 @@
 
 ## Import Modules
 #
+from __future__ import absolute_import
 from builtins import range
 import string
 import collections
@@ -23,9 +24,9 @@ from Common.BuildToolError import *
 from Common.DataType import *
 from Common.Misc import *
 from Common.StringUtils import StringToArray
-from StrGather import *
-from GenPcdDb import CreatePcdDatabaseCode
-from IdfClassObject import *
+from .StrGather import *
+from .GenPcdDb import CreatePcdDatabaseCode
+from .IdfClassObject import *
 
 ## PCD type string
 gItemTypeStringDatabase  = {
diff --git a/BaseTools/Source/Python/AutoGen/GenMake.py b/BaseTools/Source/Python/AutoGen/GenMake.py
index f3b23ed055fb..32ebb268a670 100644
--- a/BaseTools/Source/Python/AutoGen/GenMake.py
+++ b/BaseTools/Source/Python/AutoGen/GenMake.py
@@ -13,6 +13,7 @@
 
 ## Import Modules
 #
+from __future__ import absolute_import
 import Common.LongFilePathOs as os
 import sys
 import string
@@ -23,7 +24,7 @@ from Common.MultipleWorkspace import MultipleWorkspace as mws
 from Common.BuildToolError import *
 from Common.Misc import *
 from Common.StringUtils import *
-from BuildEngine import *
+from .BuildEngine import *
 import Common.GlobalData as GlobalData
 from collections import OrderedDict
 
diff --git a/BaseTools/Source/Python/AutoGen/GenPcdDb.py b/BaseTools/Source/Python/AutoGen/GenPcdDb.py
index d3790cc42cca..0f89658d3f9c 100644
--- a/BaseTools/Source/Python/AutoGen/GenPcdDb.py
+++ b/BaseTools/Source/Python/AutoGen/GenPcdDb.py
@@ -10,14 +10,15 @@
 # THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
 # WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
 #
+from __future__ import absolute_import
 from builtins import range
 from io import BytesIO
 from Common.Misc import *
 from Common.StringUtils import StringToArray
 from struct import pack
-from ValidCheckingInfoObject import VAR_CHECK_PCD_VARIABLE_TAB_CONTAINER
-from ValidCheckingInfoObject import VAR_CHECK_PCD_VARIABLE_TAB
-from ValidCheckingInfoObject import GetValidationObject
+from .ValidCheckingInfoObject import VAR_CHECK_PCD_VARIABLE_TAB_CONTAINER
+from .ValidCheckingInfoObject import VAR_CHECK_PCD_VARIABLE_TAB
+from .ValidCheckingInfoObject import GetValidationObject
 from Common.VariableAttributes import VariableAttributes
 import copy
 from struct import unpack
diff --git a/BaseTools/Source/Python/AutoGen/IdfClassObject.py b/BaseTools/Source/Python/AutoGen/IdfClassObject.py
index b656bd83e3ba..b227b10258da 100644
--- a/BaseTools/Source/Python/AutoGen/IdfClassObject.py
+++ b/BaseTools/Source/Python/AutoGen/IdfClassObject.py
@@ -13,6 +13,7 @@
 ##
 # Import Modules
 #
+from __future__ import absolute_import
 import Common.EdkLogger as EdkLogger
 from Common.BuildToolError import *
 from Common.StringUtils import GetLineNo
@@ -21,7 +22,7 @@ from Common.LongFilePathSupport import LongFilePath
 import re
 import os
 from Common.GlobalData import gIdentifierPattern
-from UniClassObject import StripComments
+from .UniClassObject import StripComments
 
 IMAGE_TOKEN = re.compile('IMAGE_TOKEN *\(([A-Z0-9_]+) *\)', re.MULTILINE | re.UNICODE)
 
diff --git a/BaseTools/Source/Python/AutoGen/StrGather.py b/BaseTools/Source/Python/AutoGen/StrGather.py
index 77b7aaa31a0a..8f36da83450d 100644
--- a/BaseTools/Source/Python/AutoGen/StrGather.py
+++ b/BaseTools/Source/Python/AutoGen/StrGather.py
@@ -14,11 +14,12 @@
 ##
 # Import Modules
 #
+from __future__ import absolute_import
 from builtins import range
 import re
 import Common.EdkLogger as EdkLogger
 from Common.BuildToolError import *
-from UniClassObject import *
+from .UniClassObject import *
 from io import BytesIO
 from struct import pack, unpack
 from Common.LongFilePathSupport import OpenLongFilePath as open
diff --git a/BaseTools/Source/Python/BPDG/BPDG.py b/BaseTools/Source/Python/BPDG/BPDG.py
index 86c44abb67a6..83674d154a3e 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 83acac1f9ae0..bb81330f80a9 100644
--- a/BaseTools/Source/Python/BPDG/GenVpd.py
+++ b/BaseTools/Source/Python/BPDG/GenVpd.py
@@ -13,10 +13,11 @@
 #  WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
 #
 
+from __future__ import absolute_import
 from builtins import range
 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
diff --git a/BaseTools/Source/Python/Common/Database.py b/BaseTools/Source/Python/Common/Database.py
index d3340f5a9036..cc042315e5cf 100644
--- a/BaseTools/Source/Python/Common/Database.py
+++ b/BaseTools/Source/Python/Common/Database.py
@@ -14,13 +14,14 @@
 ##
 # Import Modules
 #
+from __future__ import absolute_import
 import sqlite3
 import Common.LongFilePathOs as os
 
-import EdkLogger as EdkLogger
+from . import EdkLogger as EdkLogger
 from CommonDataClass.DataClass import *
-from StringUtils import *
-from DataType import *
+from .StringUtils import *
+from .DataType import *
 
 from Table.TableDataModel import TableDataModel
 from Table.TableFile import TableFile
@@ -117,4 +118,4 @@ if __name__ == '__main__':
     Db.QueryTable(Db.TblFile)
     Db.QueryTable(Db.TblDsc)
     Db.Close()
-    
\ No newline at end of file
+    
diff --git a/BaseTools/Source/Python/Common/EdkLogger.py b/BaseTools/Source/Python/Common/EdkLogger.py
index 3f462df49ada..19749066ecee 100644
--- a/BaseTools/Source/Python/Common/EdkLogger.py
+++ b/BaseTools/Source/Python/Common/EdkLogger.py
@@ -12,9 +12,10 @@
 #
 
 ## Import modules
+from __future__ import absolute_import
 import Common.LongFilePathOs as os, sys, logging
 import traceback
-from  BuildToolError import *
+from  .BuildToolError import *
 
 ## Log level constants
 DEBUG_0 = 1
diff --git a/BaseTools/Source/Python/Common/Expression.py b/BaseTools/Source/Python/Common/Expression.py
index 3dbcac8daf2c..6895588da81e 100644
--- a/BaseTools/Source/Python/Common/Expression.py
+++ b/BaseTools/Source/Python/Common/Expression.py
@@ -13,11 +13,12 @@
 ## Import Modules
 #
 from __future__ import print_function
+from __future__ import absolute_import
 from builtins import range
 from Common.GlobalData import *
 from CommonDataClass.Exceptions import BadExpression
 from CommonDataClass.Exceptions import WrnExpression
-from Misc import GuidStringToGuidStructureString, ParseFieldValue, IsFieldValueAnArray
+from .Misc import GuidStringToGuidStructureString, ParseFieldValue, IsFieldValueAnArray
 import Common.EdkLogger as EdkLogger
 import copy
 from Common.DataType import *
diff --git a/BaseTools/Source/Python/Common/LongFilePathOs.py b/BaseTools/Source/Python/Common/LongFilePathOs.py
index 4939a8bc733c..53528546b782 100644
--- a/BaseTools/Source/Python/Common/LongFilePathOs.py
+++ b/BaseTools/Source/Python/Common/LongFilePathOs.py
@@ -11,8 +11,9 @@
 # WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
 #
 
+from __future__ import absolute_import
 import os
-import LongFilePathOsPath
+from . import LongFilePathOsPath
 from Common.LongFilePathSupport import LongFilePath
 from Common.LongFilePathSupport import UniToStr
 import time
diff --git a/BaseTools/Source/Python/Common/Misc.py b/BaseTools/Source/Python/Common/Misc.py
index b3989270afc4..f97039bc0ad1 100644
--- a/BaseTools/Source/Python/Common/Misc.py
+++ b/BaseTools/Source/Python/Common/Misc.py
@@ -14,6 +14,7 @@
 ##
 # Import Modules
 #
+from __future__ import absolute_import
 from builtins import range
 import Common.LongFilePathOs as os
 import sys
@@ -31,10 +32,10 @@ from UserList import UserList
 
 from Common import EdkLogger as EdkLogger
 from Common import GlobalData as GlobalData
-from DataType import *
-from BuildToolError import *
+from .DataType import *
+from .BuildToolError import *
 from CommonDataClass.DataClass import *
-from Parsing import GetSplitValueList
+from .Parsing import GetSplitValueList
 from Common.LongFilePathSupport import OpenLongFilePath as open
 from Common.MultipleWorkspace import MultipleWorkspace as mws
 import uuid
@@ -468,7 +469,7 @@ def SaveFileOnChange(File, Content, IsBinaryFile=True):
     try:
         if GlobalData.gIsWindows:
             try:
-                from PyUtility import SaveFileToDisk
+                from .PyUtility import SaveFileToDisk
                 if not SaveFileToDisk(File, Content):
                     EdkLogger.error(None, FILE_CREATE_FAILURE, ExtraData=File)
             except:
diff --git a/BaseTools/Source/Python/Common/Parsing.py b/BaseTools/Source/Python/Common/Parsing.py
index 717bc569d1c9..27460f9856ad 100644
--- a/BaseTools/Source/Python/Common/Parsing.py
+++ b/BaseTools/Source/Python/Common/Parsing.py
@@ -14,10 +14,11 @@
 ##
 # Import Modules
 #
+from __future__ import absolute_import
 from builtins import range
-from StringUtils import *
+from .StringUtils import *
 from CommonDataClass.DataClass import *
-from DataType import *
+from .DataType import *
 
 ## ParseDefineMacro
 #
diff --git a/BaseTools/Source/Python/Common/StringUtils.py b/BaseTools/Source/Python/Common/StringUtils.py
index 2f45bc3674cc..b62e03f9d32f 100644
--- a/BaseTools/Source/Python/Common/StringUtils.py
+++ b/BaseTools/Source/Python/Common/StringUtils.py
@@ -14,15 +14,16 @@
 ##
 # Import Modules
 #
+from __future__ import absolute_import
 from builtins import range
 import re
-import DataType
+from . import DataType
 import Common.LongFilePathOs as os
 import string
-import EdkLogger as EdkLogger
+from . import EdkLogger as EdkLogger
 
-import GlobalData
-from BuildToolError import *
+from . import GlobalData
+from .BuildToolError import *
 from CommonDataClass.Exceptions import *
 from Common.LongFilePathSupport import OpenLongFilePath as open
 from Common.MultipleWorkspace import MultipleWorkspace as mws
diff --git a/BaseTools/Source/Python/Common/TargetTxtClassObject.py b/BaseTools/Source/Python/Common/TargetTxtClassObject.py
index 8ba8dd31a8c5..55a2f564821e 100644
--- a/BaseTools/Source/Python/Common/TargetTxtClassObject.py
+++ b/BaseTools/Source/Python/Common/TargetTxtClassObject.py
@@ -15,11 +15,12 @@
 # Import Modules
 #
 from __future__ import print_function
+from __future__ import absolute_import
 import Common.LongFilePathOs as os
-import EdkLogger
-import DataType
-from BuildToolError import *
-import GlobalData
+from . import EdkLogger
+from . import DataType
+from .BuildToolError import *
+from . import GlobalData
 from Common.LongFilePathSupport import OpenLongFilePath as open
 
 gDefaultTargetTxtFile = "target.txt"
diff --git a/BaseTools/Source/Python/Common/ToolDefClassObject.py b/BaseTools/Source/Python/Common/ToolDefClassObject.py
index dec48b3f295b..32b39f2b6ca4 100644
--- a/BaseTools/Source/Python/Common/ToolDefClassObject.py
+++ b/BaseTools/Source/Python/Common/ToolDefClassObject.py
@@ -14,20 +14,21 @@
 ##
 # Import Modules
 #
+from __future__ import absolute_import
 from builtins import range
 import Common.LongFilePathOs as os
 import re
-import EdkLogger
+from . import EdkLogger
 
-from BuildToolError import *
-from TargetTxtClassObject import *
+from .BuildToolError import *
+from .TargetTxtClassObject import *
 from Common.LongFilePathSupport import OpenLongFilePath as open
 from Common.Misc import PathClass
 from Common.StringUtils import NormPath
 import Common.GlobalData as GlobalData
 from Common import GlobalData
 from Common.MultipleWorkspace import MultipleWorkspace as mws
-from DataType import TAB_TOD_DEFINES_TARGET, TAB_TOD_DEFINES_TOOL_CHAIN_TAG,\
+from .DataType import TAB_TOD_DEFINES_TARGET, TAB_TOD_DEFINES_TOOL_CHAIN_TAG,\
                      TAB_TOD_DEFINES_TARGET_ARCH, TAB_TOD_DEFINES_COMMAND_TYPE\
                      , TAB_TOD_DEFINES_FAMILY, TAB_TOD_DEFINES_BUILDRULEFAMILY
 
diff --git a/BaseTools/Source/Python/Ecc/CParser.py b/BaseTools/Source/Python/Ecc/CParser.py
index 51a05902e225..432c947c934e 100644
--- a/BaseTools/Source/Python/Ecc/CParser.py
+++ b/BaseTools/Source/Python/Ecc/CParser.py
@@ -1,6 +1,7 @@
 # $ANTLR 3.0.1 C.g 2010-02-23 09:58:53
 
 from __future__ import print_function
+from __future__ import absolute_import
 from antlr3 import *
 from antlr3.compat import set, frozenset
          
@@ -23,8 +24,8 @@ from antlr3.compat import set, frozenset
 #
 ##
 
-import CodeFragment
-import FileProfile
+from . import CodeFragment
+from . import FileProfile
 
 
 
diff --git a/BaseTools/Source/Python/Ecc/Check.py b/BaseTools/Source/Python/Ecc/Check.py
index 4a60e9bab0e4..de34a68fc6c8 100644
--- a/BaseTools/Source/Python/Ecc/Check.py
+++ b/BaseTools/Source/Python/Ecc/Check.py
@@ -10,15 +10,16 @@
 # THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
 # WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
 #
+from __future__ import absolute_import
 from builtins import range
 import Common.LongFilePathOs as os
 import re
 from CommonDataClass.DataClass import *
 import Common.DataType as DT
-from EccToolError import *
-from MetaDataParser import ParseHeaderCommentSection
-import EccGlobalData
-import c
+from .EccToolError import *
+from .MetaDataParser import ParseHeaderCommentSection
+from . import EccGlobalData
+from . import c
 from Common.LongFilePathSupport import OpenLongFilePath as open
 from Common.MultipleWorkspace import MultipleWorkspace as mws
 
diff --git a/BaseTools/Source/Python/Ecc/CodeFragmentCollector.py b/BaseTools/Source/Python/Ecc/CodeFragmentCollector.py
index 2efae2c7c1de..dbd7891928aa 100644
--- a/BaseTools/Source/Python/Ecc/CodeFragmentCollector.py
+++ b/BaseTools/Source/Python/Ecc/CodeFragmentCollector.py
@@ -17,18 +17,19 @@
 #
 
 from __future__ import print_function
+from __future__ import absolute_import
 import re
 import Common.LongFilePathOs as os
 import sys
 
 import antlr3
-from CLexer import CLexer
-from CParser import CParser
+from .CLexer import CLexer
+from .CParser import CParser
 
-import FileProfile
-from CodeFragment import Comment
-from CodeFragment import PP_Directive
-from ParserWarning import Warning
+from . import FileProfile
+from .CodeFragment import Comment
+from .CodeFragment import PP_Directive
+from .ParserWarning import Warning
 
 
 ##define T_CHAR_SPACE                ' '
diff --git a/BaseTools/Source/Python/Ecc/Database.py b/BaseTools/Source/Python/Ecc/Database.py
index 204117512452..34f49f3cba8b 100644
--- a/BaseTools/Source/Python/Ecc/Database.py
+++ b/BaseTools/Source/Python/Ecc/Database.py
@@ -14,6 +14,7 @@
 ##
 # Import Modules
 #
+from __future__ import absolute_import
 import sqlite3
 import Common.LongFilePathOs as os, time
 
@@ -26,9 +27,9 @@ from Table.TableFunction import TableFunction
 from Table.TablePcd import TablePcd
 from Table.TableIdentifier import TableIdentifier
 from Table.TableReport import TableReport
-from MetaFileWorkspace.MetaFileTable import ModuleTable
-from MetaFileWorkspace.MetaFileTable import PackageTable
-from MetaFileWorkspace.MetaFileTable import PlatformTable
+from .MetaFileWorkspace.MetaFileTable import ModuleTable
+from .MetaFileWorkspace.MetaFileTable import PackageTable
+from .MetaFileWorkspace.MetaFileTable import PlatformTable
 from Table.TableFdf import TableFdf
 
 ##
diff --git a/BaseTools/Source/Python/Ecc/Ecc.py b/BaseTools/Source/Python/Ecc/Ecc.py
index e78d70372e36..8fe6c4eed40a 100644
--- a/BaseTools/Source/Python/Ecc/Ecc.py
+++ b/BaseTools/Source/Python/Ecc/Ecc.py
@@ -14,14 +14,15 @@
 ##
 # Import Modules
 #
+from __future__ import absolute_import
 import Common.LongFilePathOs as os, time, glob, sys
 import Common.EdkLogger as EdkLogger
-import Database
-import EccGlobalData
-from MetaDataParser import *
+from . import Database
+from . import EccGlobalData
+from .MetaDataParser import *
 from optparse import OptionParser
-from Configuration import Configuration
-from Check import Check
+from .Configuration import Configuration
+from .Check import Check
 import Common.GlobalData as GlobalData
 
 from Common.StringUtils import NormPath
@@ -29,14 +30,14 @@ from Common.BuildVersion import gBUILD_VERSION
 from Common import BuildToolError
 from Common.Misc import PathClass
 from Common.Misc import DirCache
-from MetaFileWorkspace.MetaFileParser import DscParser
-from MetaFileWorkspace.MetaFileParser import DecParser
-from MetaFileWorkspace.MetaFileParser import InfParser
-from MetaFileWorkspace.MetaFileParser import Fdf
-from MetaFileWorkspace.MetaFileTable import MetaFileStorage
-import c
+from .MetaFileWorkspace.MetaFileParser import DscParser
+from .MetaFileWorkspace.MetaFileParser import DecParser
+from .MetaFileWorkspace.MetaFileParser import InfParser
+from .MetaFileWorkspace.MetaFileParser import Fdf
+from .MetaFileWorkspace.MetaFileTable import MetaFileStorage
+from . import c
 import re, string
-from Exception import *
+from .Exception import *
 from Common.LongFilePathSupport import OpenLongFilePath as open
 from Common.MultipleWorkspace import MultipleWorkspace as mws
 
diff --git a/BaseTools/Source/Python/Ecc/Exception.py b/BaseTools/Source/Python/Ecc/Exception.py
index bde41c3a4b57..ba43ebe03fdb 100644
--- a/BaseTools/Source/Python/Ecc/Exception.py
+++ b/BaseTools/Source/Python/Ecc/Exception.py
@@ -15,7 +15,8 @@
 # Import Modules
 #
 from __future__ import print_function
-from Xml.XmlRoutines import *
+from __future__ import absolute_import
+from .Xml.XmlRoutines import *
 import Common.LongFilePathOs as os
 
 # ExceptionXml to parse Exception Node of XML file
diff --git a/BaseTools/Source/Python/Ecc/FileProfile.py b/BaseTools/Source/Python/Ecc/FileProfile.py
index f31d37ff9683..be0b6455ca41 100644
--- a/BaseTools/Source/Python/Ecc/FileProfile.py
+++ b/BaseTools/Source/Python/Ecc/FileProfile.py
@@ -16,9 +16,10 @@
 # Import Modules
 #
 
+from __future__ import absolute_import
 import re
 import Common.LongFilePathOs as os
-from ParserWarning import Warning
+from .ParserWarning import Warning
 from Common.LongFilePathSupport import OpenLongFilePath as open
 
 CommentList = []
@@ -55,4 +56,4 @@ class FileProfile :
         except IOError:
             raise Warning("Error when opening file %s" % FileName)
         
-        
\ No newline at end of file
+        
diff --git a/BaseTools/Source/Python/Ecc/MetaDataParser.py b/BaseTools/Source/Python/Ecc/MetaDataParser.py
index 9b8b96aa4b43..545a9c3b20b4 100644
--- a/BaseTools/Source/Python/Ecc/MetaDataParser.py
+++ b/BaseTools/Source/Python/Ecc/MetaDataParser.py
@@ -11,12 +11,13 @@
 # WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
 #
 
+from __future__ import absolute_import
 from builtins import range
 import Common.LongFilePathOs as os
 from CommonDataClass.DataClass import *
-from EccToolError import *
+from .EccToolError import *
 from Common.MultipleWorkspace import MultipleWorkspace as mws
-import EccGlobalData
+from . import EccGlobalData
 import re
 ## Get the inlcude path list for a source file
 #
diff --git a/BaseTools/Source/Python/Ecc/MetaFileWorkspace/MetaFileParser.py b/BaseTools/Source/Python/Ecc/MetaFileWorkspace/MetaFileParser.py
index 003a3f6559fa..2a2dabfd7701 100644
--- a/BaseTools/Source/Python/Ecc/MetaFileWorkspace/MetaFileParser.py
+++ b/BaseTools/Source/Python/Ecc/MetaFileWorkspace/MetaFileParser.py
@@ -14,6 +14,7 @@
 ##
 # Import Modules
 #
+from __future__ import absolute_import
 from builtins import range
 import Common.LongFilePathOs as os
 import re
@@ -32,7 +33,7 @@ from Common.Misc import GuidStructureStringToGuidString, CheckPcdDatum, PathClas
 from Common.Expression import *
 from CommonDataClass.Exceptions import *
 
-from MetaFileTable import MetaFileStorage
+from .MetaFileTable import MetaFileStorage
 from GenFds.FdfParser import FdfParser
 from Common.LongFilePathSupport import OpenLongFilePath as open
 from Common.LongFilePathSupport import CodecOpenLongFilePath
diff --git a/BaseTools/Source/Python/Ecc/MetaFileWorkspace/MetaFileTable.py b/BaseTools/Source/Python/Ecc/MetaFileWorkspace/MetaFileTable.py
index 9faa6b58b001..9a0f4769adaa 100644
--- a/BaseTools/Source/Python/Ecc/MetaFileWorkspace/MetaFileTable.py
+++ b/BaseTools/Source/Python/Ecc/MetaFileWorkspace/MetaFileTable.py
@@ -14,13 +14,14 @@
 ##
 # Import Modules
 #
+from __future__ import absolute_import
 import uuid
 
 import Common.EdkLogger as EdkLogger
 import EccGlobalData
 
-from MetaDataTable import Table
-from MetaDataTable import ConvertToSqlString
+from .MetaDataTable import Table
+from .MetaDataTable import ConvertToSqlString
 from CommonDataClass.DataClass import MODEL_FILE_DSC, MODEL_FILE_DEC, MODEL_FILE_INF, \
                                       MODEL_FILE_OTHERS
 
diff --git a/BaseTools/Source/Python/Ecc/c.py b/BaseTools/Source/Python/Ecc/c.py
index e2a5cc8487fa..9f7ed34d23d0 100644
--- a/BaseTools/Source/Python/Ecc/c.py
+++ b/BaseTools/Source/Python/Ecc/c.py
@@ -12,18 +12,19 @@
 #
 
 from __future__ import print_function
+from __future__ import absolute_import
 import sys
 import Common.LongFilePathOs as os
 import re
 import string
-import CodeFragmentCollector
-import FileProfile
+from . import CodeFragmentCollector
+from . import FileProfile
 from CommonDataClass import DataClass
-import Database
+from . import Database
 from Common import EdkLogger
-from EccToolError import *
-import EccGlobalData
-import MetaDataParser
+from .EccToolError import *
+from . import EccGlobalData
+from . import MetaDataParser
 
 IncludeFileListDict = {}
 AllIncludeFileListDict = {}
diff --git a/BaseTools/Source/Python/Eot/CParser.py b/BaseTools/Source/Python/Eot/CParser.py
index 51a05902e225..432c947c934e 100644
--- a/BaseTools/Source/Python/Eot/CParser.py
+++ b/BaseTools/Source/Python/Eot/CParser.py
@@ -1,6 +1,7 @@
 # $ANTLR 3.0.1 C.g 2010-02-23 09:58:53
 
 from __future__ import print_function
+from __future__ import absolute_import
 from antlr3 import *
 from antlr3.compat import set, frozenset
          
@@ -23,8 +24,8 @@ from antlr3.compat import set, frozenset
 #
 ##
 
-import CodeFragment
-import FileProfile
+from . import CodeFragment
+from . import FileProfile
 
 
 
diff --git a/BaseTools/Source/Python/Eot/CodeFragmentCollector.py b/BaseTools/Source/Python/Eot/CodeFragmentCollector.py
index 1e30e2ce62e2..8a5e5df17e5a 100644
--- a/BaseTools/Source/Python/Eot/CodeFragmentCollector.py
+++ b/BaseTools/Source/Python/Eot/CodeFragmentCollector.py
@@ -16,17 +16,18 @@
 # Import Modules
 #
 from __future__ import print_function
+from __future__ import absolute_import
 import re
 import Common.LongFilePathOs as os
 import sys
 
 import antlr3
-from CLexer import CLexer
-from CParser import CParser
+from .CLexer import CLexer
+from .CParser import CParser
 
-import FileProfile
-from CodeFragment import PP_Directive
-from ParserWarning import Warning
+from . import FileProfile
+from .CodeFragment import PP_Directive
+from .ParserWarning import Warning
 
 
 ##define T_CHAR_SPACE                ' '
diff --git a/BaseTools/Source/Python/Eot/Eot.py b/BaseTools/Source/Python/Eot/Eot.py
index 1862d71f7342..f020c90c7cf9 100644
--- a/BaseTools/Source/Python/Eot/Eot.py
+++ b/BaseTools/Source/Python/Eot/Eot.py
@@ -14,21 +14,22 @@
 ##
 # Import Modules
 #
+from __future__ import absolute_import
 from builtins import range
 import Common.LongFilePathOs as os, time, glob
 import Common.EdkLogger as EdkLogger
-import EotGlobalData
+from . import EotGlobalData
 from optparse import OptionParser
 from Common.StringUtils import NormPath
 from Common import BuildToolError
 from Common.Misc import GuidStructureStringToGuidString, sdict
-from InfParserLite import *
-import c
-import Database
+from .InfParserLite import *
+from . import c
+from . import Database
 from array import array
-from Report import Report
+from .Report import Report
 from Common.BuildVersion import gBUILD_VERSION
-from Parser import ConvertGuid
+from .Parser import ConvertGuid
 from Common.LongFilePathSupport import OpenLongFilePath as open
 import struct
 import uuid
@@ -154,7 +155,7 @@ class CompressedImage(Image):
 
     def _GetSections(m):
         try:
-            import EfiCompressor
+            from . import EfiCompressor
             TmpData = EfiCompressor.FrameworkDecompress(
                                         m[m._HEADER_SIZE_:],
                                         len(m) - m._HEADER_SIZE_
@@ -162,7 +163,7 @@ class CompressedImage(Image):
             DecData = array('B')
             DecData.fromstring(TmpData)
         except:
-            import EfiCompressor
+            from . import EfiCompressor
             TmpData = EfiCompressor.UefiDecompress(
                                         m[m._HEADER_SIZE_:],
                                         len(m) - m._HEADER_SIZE_
@@ -749,7 +750,7 @@ class GuidDefinedImage(Image):
                 SectionList.append(Sec)
         elif Guid == m.TIANO_COMPRESS_GUID:
             try:
-                import EfiCompressor
+                from . import EfiCompressor
                 # skip the header
                 Offset = m.DataOffset - 4
                 TmpData = EfiCompressor.FrameworkDecompress(m[Offset:], len(m)-Offset)
@@ -770,7 +771,7 @@ class GuidDefinedImage(Image):
                 pass
         elif Guid == m.LZMA_COMPRESS_GUID:
             try:
-                import LzmaCompressor
+                from . import LzmaCompressor
                 # skip the header
                 Offset = m.DataOffset - 4
                 TmpData = LzmaCompressor.LzmaDecompress(m[Offset:], len(m)-Offset)
diff --git a/BaseTools/Source/Python/Eot/FileProfile.py b/BaseTools/Source/Python/Eot/FileProfile.py
index 0544c0d55b44..3846279cad4c 100644
--- a/BaseTools/Source/Python/Eot/FileProfile.py
+++ b/BaseTools/Source/Python/Eot/FileProfile.py
@@ -16,9 +16,10 @@
 # Import Modules
 #
 
+from __future__ import absolute_import
 import re
 import Common.LongFilePathOs as os
-from ParserWarning import Warning
+from .ParserWarning import Warning
 from Common.LongFilePathSupport import OpenLongFilePath as open
 
 # Profile contents of a file
diff --git a/BaseTools/Source/Python/Eot/InfParserLite.py b/BaseTools/Source/Python/Eot/InfParserLite.py
index 5a2eab9b0413..fb7b6e9755eb 100644
--- a/BaseTools/Source/Python/Eot/InfParserLite.py
+++ b/BaseTools/Source/Python/Eot/InfParserLite.py
@@ -15,6 +15,7 @@
 # Import Modules
 #
 from __future__ import print_function
+from __future__ import absolute_import
 from builtins import range
 import Common.LongFilePathOs as os
 import Common.EdkLogger as EdkLogger
@@ -22,8 +23,8 @@ from Common.DataType import *
 from CommonDataClass.DataClass import *
 from Common.Identification import *
 from Common.StringUtils import *
-from Parser import *
-import Database
+from .Parser import *
+from . import Database
 
 ## EdkInfParser() class
 #
diff --git a/BaseTools/Source/Python/Eot/Parser.py b/BaseTools/Source/Python/Eot/Parser.py
index 0b720d5b2187..e01a9770befb 100644
--- a/BaseTools/Source/Python/Eot/Parser.py
+++ b/BaseTools/Source/Python/Eot/Parser.py
@@ -15,12 +15,13 @@
 ##
 # Import Modules
 #
+from __future__ import absolute_import
 import Common.LongFilePathOs as os, re
 import Common.EdkLogger as EdkLogger
 from Common.DataType import *
 from CommonDataClass.DataClass import *
 from Common.StringUtils import CleanString, GetSplitValueList, ReplaceMacro
-import EotGlobalData
+from . import EotGlobalData
 from Common.StringUtils import GetSplitList
 from Common.LongFilePathSupport import OpenLongFilePath as open
 
diff --git a/BaseTools/Source/Python/Eot/Report.py b/BaseTools/Source/Python/Eot/Report.py
index 7435b4d7c930..afdb31f58411 100644
--- a/BaseTools/Source/Python/Eot/Report.py
+++ b/BaseTools/Source/Python/Eot/Report.py
@@ -14,8 +14,9 @@
 ##
 # Import Modules
 #
+from __future__ import absolute_import
 import Common.LongFilePathOs as os
-import EotGlobalData
+from . import EotGlobalData
 from Common.LongFilePathSupport import OpenLongFilePath as open
 
 ## Report() class
diff --git a/BaseTools/Source/Python/Eot/c.py b/BaseTools/Source/Python/Eot/c.py
index ceefc952237f..4f0b58a52c79 100644
--- a/BaseTools/Source/Python/Eot/c.py
+++ b/BaseTools/Source/Python/Eot/c.py
@@ -16,15 +16,16 @@
 # Import Modules
 #
 from __future__ import print_function
+from __future__ import absolute_import
 import sys
 import Common.LongFilePathOs as os
 import re
-import CodeFragmentCollector
-import FileProfile
+from . import CodeFragmentCollector
+from . import FileProfile
 from CommonDataClass import DataClass
 from Common import EdkLogger
-from EotToolError import *
-import EotGlobalData
+from .EotToolError import *
+from . import EotGlobalData
 
 # Global Dicts
 IncludeFileListDict = {}
diff --git a/BaseTools/Source/Python/GenFds/AprioriSection.py b/BaseTools/Source/Python/GenFds/AprioriSection.py
index 5d1e56b7f1da..b0693eb4ea71 100644
--- a/BaseTools/Source/Python/GenFds/AprioriSection.py
+++ b/BaseTools/Source/Python/GenFds/AprioriSection.py
@@ -15,12 +15,13 @@
 ##
 # Import Modules
 #
+from __future__ import absolute_import
 from builtins import range
 from struct import *
 import Common.LongFilePathOs as os
 from io import BytesIO
-import FfsFileStatement
-from GenFdsGlobalVariable import GenFdsGlobalVariable
+from . import FfsFileStatement
+from .GenFdsGlobalVariable import GenFdsGlobalVariable
 from CommonDataClass.FdfClass import AprioriSectionClassObject
 from Common.StringUtils import *
 from Common.Misc import SaveFileOnChange, PathClass
diff --git a/BaseTools/Source/Python/GenFds/Capsule.py b/BaseTools/Source/Python/GenFds/Capsule.py
index b02661d99855..41fd614b86c4 100644
--- a/BaseTools/Source/Python/GenFds/Capsule.py
+++ b/BaseTools/Source/Python/GenFds/Capsule.py
@@ -15,17 +15,16 @@
 ##
 # Import Modules
 #
-from GenFdsGlobalVariable import GenFdsGlobalVariable
+from __future__ import absolute_import
+from .GenFdsGlobalVariable import GenFdsGlobalVariable
 from CommonDataClass.FdfClass import CapsuleClassObject
 import Common.LongFilePathOs as os
 import subprocess
 from io import BytesIO
 from Common.Misc import SaveFileOnChange
-from GenFds import GenFds
 from Common.Misc import PackRegistryFormatGuid
 import uuid
 from struct import pack
-from GenFds import FindExtendTool
 from Common import EdkLogger
 from Common.BuildToolError import *
 
@@ -66,6 +65,7 @@ class Capsule (CapsuleClassObject) :
         #     UINT32            CapsuleImageSize;
         # } EFI_CAPSULE_HEADER;
         #
+        from .GenFds import FindExtendTool
         Header = BytesIO()
         #
         # Use FMP capsule GUID: 6DCBD5ED-E82D-4C44-BDA1-7194199AD92A
@@ -201,6 +201,7 @@ class Capsule (CapsuleClassObject) :
     #   @retval string      Generated Capsule file path
     #
     def GenCapsule(self):
+        from .GenFds import GenFds
         if self.UiCapsuleName.upper() + 'cap' in GenFds.ImageBinDict:
             return GenFds.ImageBinDict[self.UiCapsuleName.upper() + 'cap']
 
diff --git a/BaseTools/Source/Python/GenFds/CapsuleData.py b/BaseTools/Source/Python/GenFds/CapsuleData.py
index 83b2731110bc..d8d3415ce494 100644
--- a/BaseTools/Source/Python/GenFds/CapsuleData.py
+++ b/BaseTools/Source/Python/GenFds/CapsuleData.py
@@ -15,8 +15,9 @@
 ##
 # Import Modules
 #
-import Ffs
-from GenFdsGlobalVariable import GenFdsGlobalVariable
+from __future__ import absolute_import
+from . import Ffs
+from .GenFdsGlobalVariable import GenFdsGlobalVariable
 from io import BytesIO
 from struct import pack
 import os
diff --git a/BaseTools/Source/Python/GenFds/CompressSection.py b/BaseTools/Source/Python/GenFds/CompressSection.py
index 4ae14f27b3e1..aaaabf84dca8 100644
--- a/BaseTools/Source/Python/GenFds/CompressSection.py
+++ b/BaseTools/Source/Python/GenFds/CompressSection.py
@@ -15,11 +15,12 @@
 ##
 # Import Modules
 #
-from Ffs import Ffs
-import Section
+from __future__ import absolute_import
+from .Ffs import Ffs
+from . import Section
 import subprocess
 import Common.LongFilePathOs as os
-from GenFdsGlobalVariable import GenFdsGlobalVariable
+from .GenFdsGlobalVariable import GenFdsGlobalVariable
 from CommonDataClass.FdfClass import CompressSectionClassObject
 from Common.DataType import *
 
diff --git a/BaseTools/Source/Python/GenFds/DataSection.py b/BaseTools/Source/Python/GenFds/DataSection.py
index 29caa00c0d8d..a6387b07c582 100644
--- a/BaseTools/Source/Python/GenFds/DataSection.py
+++ b/BaseTools/Source/Python/GenFds/DataSection.py
@@ -15,10 +15,11 @@
 ##
 # Import Modules
 #
-import Section
-from GenFdsGlobalVariable import GenFdsGlobalVariable
+from __future__ import absolute_import
+from . import Section
+from .GenFdsGlobalVariable import GenFdsGlobalVariable
 import subprocess
-from Ffs import Ffs
+from .Ffs import Ffs
 import Common.LongFilePathOs as os
 from CommonDataClass.FdfClass import DataSectionClassObject
 from Common.Misc import PeImageClass
diff --git a/BaseTools/Source/Python/GenFds/DepexSection.py b/BaseTools/Source/Python/GenFds/DepexSection.py
index f42162d5a27e..b2d123bfc045 100644
--- a/BaseTools/Source/Python/GenFds/DepexSection.py
+++ b/BaseTools/Source/Python/GenFds/DepexSection.py
@@ -15,10 +15,11 @@
 ##
 # Import Modules
 #
-import Section
-from GenFdsGlobalVariable import GenFdsGlobalVariable
+from __future__ import absolute_import
+from . import Section
+from .GenFdsGlobalVariable import GenFdsGlobalVariable
 import subprocess
-from Ffs import Ffs
+from .Ffs import Ffs
 import Common.LongFilePathOs as os
 from CommonDataClass.FdfClass import DepexSectionClassObject
 from AutoGen.GenDepex import DependencyExpression
diff --git a/BaseTools/Source/Python/GenFds/EfiSection.py b/BaseTools/Source/Python/GenFds/EfiSection.py
index 8ac37dd96b9b..d28019e5f85c 100644
--- a/BaseTools/Source/Python/GenFds/EfiSection.py
+++ b/BaseTools/Source/Python/GenFds/EfiSection.py
@@ -15,11 +15,12 @@
 ##
 # Import Modules
 #
+from __future__ import absolute_import
 from struct import *
-import Section
-from GenFdsGlobalVariable import GenFdsGlobalVariable
+from . import Section
+from .GenFdsGlobalVariable import GenFdsGlobalVariable
 import subprocess
-from Ffs import Ffs
+from .Ffs import Ffs
 import Common.LongFilePathOs as os
 from CommonDataClass.FdfClass import EfiSectionClassObject
 from Common import EdkLogger
diff --git a/BaseTools/Source/Python/GenFds/Fd.py b/BaseTools/Source/Python/GenFds/Fd.py
index 3305a470edfa..9e7d0fbfc534 100644
--- a/BaseTools/Source/Python/GenFds/Fd.py
+++ b/BaseTools/Source/Python/GenFds/Fd.py
@@ -15,18 +15,18 @@
 ##
 # Import Modules
 #
-import Region
-import Fv
+from __future__ import absolute_import
+from . import Region
+from . import Fv
 import Common.LongFilePathOs as os
 from io import BytesIO
 import sys
 from struct import *
-from GenFdsGlobalVariable import GenFdsGlobalVariable
+from .GenFdsGlobalVariable import GenFdsGlobalVariable
 from CommonDataClass.FdfClass import FDClassObject
 from Common import EdkLogger
 from Common.BuildToolError import *
 from Common.Misc import SaveFileOnChange
-from GenFds import GenFds
 from Common.DataType import BINARY_FILE_TYPE_FV
 
 ## generate FD
@@ -47,6 +47,7 @@ class FD(FDClassObject):
     #   @retval string      Generated FD file name
     #
     def GenFd (self, Flag = False):
+        from .GenFds import GenFds
         if self.FdUiName.upper() + 'fd' in GenFds.ImageBinDict:
             return GenFds.ImageBinDict[self.FdUiName.upper() + 'fd']
 
diff --git a/BaseTools/Source/Python/GenFds/FdfParser.py b/BaseTools/Source/Python/GenFds/FdfParser.py
index 22f430894d47..b7c4bb35a4e2 100644
--- a/BaseTools/Source/Python/GenFds/FdfParser.py
+++ b/BaseTools/Source/Python/GenFds/FdfParser.py
@@ -17,35 +17,36 @@
 # Import Modules
 #
 from __future__ import print_function
+from __future__ import absolute_import
 import re
 
-import Fd
-import Region
-import Fv
-import AprioriSection
-import FfsInfStatement
-import FfsFileStatement
-import VerSection
-import UiSection
-import FvImageSection
-import DataSection
-import DepexSection
-import CompressSection
-import GuidSection
-import Capsule
-import CapsuleData
-import Rule
-import RuleComplexFile
-import RuleSimpleFile
-import EfiSection
-import Vtf
-import ComponentStatement
-import OptionRom
-import OptRomInfStatement
-import OptRomFileStatement
+from . import Fd
+from . import Region
+from . import Fv
+from . import AprioriSection
+from . import FfsInfStatement
+from . import FfsFileStatement
+from . import VerSection
+from . import UiSection
+from . import FvImageSection
+from . import DataSection
+from . import DepexSection
+from . import CompressSection
+from . import GuidSection
+from . import Capsule
+from . import CapsuleData
+from . import Rule
+from . import RuleComplexFile
+from . import RuleSimpleFile
+from . import EfiSection
+from . import Vtf
+from . import ComponentStatement
+from . import OptionRom
+from . import OptRomInfStatement
+from . import OptRomFileStatement
 import string
 
-from GenFdsGlobalVariable import GenFdsGlobalVariable
+from .GenFdsGlobalVariable import GenFdsGlobalVariable
 from Common.BuildToolError import *
 from Common import EdkLogger
 from Common.Misc import PathClass
@@ -60,8 +61,8 @@ from Common.Misc import tdict
 from Common.MultipleWorkspace import MultipleWorkspace as mws
 import Common.LongFilePathOs as os
 from Common.LongFilePathSupport import OpenLongFilePath as open
-from Capsule import EFI_CERT_TYPE_PKCS7_GUID
-from Capsule import EFI_CERT_TYPE_RSA2048_SHA256_GUID
+from .Capsule import EFI_CERT_TYPE_PKCS7_GUID
+from .Capsule import EFI_CERT_TYPE_RSA2048_SHA256_GUID
 from Common.RangeExpression import RangeExpression
 
 ##define T_CHAR_SPACE                ' '
diff --git a/BaseTools/Source/Python/GenFds/FfsFileStatement.py b/BaseTools/Source/Python/GenFds/FfsFileStatement.py
index 74c4b3d8adb6..1c655433ed83 100644
--- a/BaseTools/Source/Python/GenFds/FfsFileStatement.py
+++ b/BaseTools/Source/Python/GenFds/FfsFileStatement.py
@@ -15,20 +15,21 @@
 ##
 # Import Modules
 #
+from __future__ import absolute_import
 from builtins import range
-import Ffs
-import Rule
+from . import Ffs
+from . import Rule
 import Common.LongFilePathOs as os
 from io import BytesIO
 import subprocess
 
-from GenFdsGlobalVariable import GenFdsGlobalVariable
+from .GenFdsGlobalVariable import GenFdsGlobalVariable
 from CommonDataClass.FdfClass import FileStatementClassObject
 from Common import EdkLogger
 from Common.BuildToolError import *
 from Common.Misc import GuidStructureByteArrayToGuidString
-from GuidSection import GuidSection
-from FvImageSection import FvImageSection
+from .GuidSection import GuidSection
+from .FvImageSection import FvImageSection
 from Common.Misc import SaveFileOnChange
 from struct import *
 
diff --git a/BaseTools/Source/Python/GenFds/FfsInfStatement.py b/BaseTools/Source/Python/GenFds/FfsInfStatement.py
index ef34dbf00754..63acd50601bc 100644
--- a/BaseTools/Source/Python/GenFds/FfsInfStatement.py
+++ b/BaseTools/Source/Python/GenFds/FfsInfStatement.py
@@ -16,17 +16,18 @@
 ##
 # Import Modules
 #
-import Rule
+from __future__ import absolute_import
+from . import Rule
 import Common.LongFilePathOs as os
 from io import BytesIO
 from struct import *
-from GenFdsGlobalVariable import GenFdsGlobalVariable
-import Ffs
+from .GenFdsGlobalVariable import GenFdsGlobalVariable
+from . import Ffs
 import subprocess
 import sys
-import Section
-import RuleSimpleFile
-import RuleComplexFile
+from . import Section
+from . import RuleSimpleFile
+from . import RuleComplexFile
 from CommonDataClass.FdfClass import FfsInfStatementClassObject
 from Common.MultipleWorkspace import MultipleWorkspace as mws
 from Common.StringUtils import *
@@ -36,15 +37,15 @@ from Common.Misc import ProcessDuplicatedInf
 from Common.Misc import GetVariableOffset
 from Common import EdkLogger
 from Common.BuildToolError import *
-from GuidSection import GuidSection
-from FvImageSection import FvImageSection
+from .GuidSection import GuidSection
+from .FvImageSection import FvImageSection
 from Common.Misc import PeImageClass
 from AutoGen.GenDepex import DependencyExpression
 from PatchPcdValue.PatchPcdValue import PatchBinaryFile
 from Common.LongFilePathSupport import CopyLongFilePath
 from Common.LongFilePathSupport import OpenLongFilePath as open
 import Common.GlobalData as GlobalData
-from DepexSection import DepexSection
+from .DepexSection import DepexSection
 from Common.Misc import SaveFileOnChange
 from Common.Expression import *
 from Common.DataType import *
diff --git a/BaseTools/Source/Python/GenFds/Fv.py b/BaseTools/Source/Python/GenFds/Fv.py
index 31ae60396556..947aaad09903 100644
--- a/BaseTools/Source/Python/GenFds/Fv.py
+++ b/BaseTools/Source/Python/GenFds/Fv.py
@@ -1,3 +1,4 @@
+from __future__ import absolute_import
 ## @file
 # process FV generation
 #
@@ -21,11 +22,10 @@ import subprocess
 from io import BytesIO
 from struct import *
 
-import Ffs
-import AprioriSection
-import FfsFileStatement
-from GenFdsGlobalVariable import GenFdsGlobalVariable
-from GenFds import GenFds
+from . import Ffs
+from . import AprioriSection
+from . import FfsFileStatement
+from .GenFdsGlobalVariable import GenFdsGlobalVariable
 from CommonDataClass.FdfClass import FvClassObject
 from Common.Misc import SaveFileOnChange, PackGUID
 from Common.LongFilePathSupport import CopyLongFilePath
@@ -71,6 +71,7 @@ class FV (FvClassObject):
     #
     def AddToBuffer (self, Buffer, BaseAddress=None, BlockSize= None, BlockNum=None, ErasePloarity='1', VtfDict=None, MacroDict = {}, Flag=False) :
 
+        from .GenFds import GenFds
         if BaseAddress is None and self.UiFvName.upper() + 'fv' in GenFds.ImageBinDict:
             return GenFds.ImageBinDict[self.UiFvName.upper() + 'fv']
         
diff --git a/BaseTools/Source/Python/GenFds/FvImageSection.py b/BaseTools/Source/Python/GenFds/FvImageSection.py
index b4f1f3340e99..04556fc87099 100644
--- a/BaseTools/Source/Python/GenFds/FvImageSection.py
+++ b/BaseTools/Source/Python/GenFds/FvImageSection.py
@@ -15,11 +15,12 @@
 ##
 # Import Modules
 #
-import Section
+from __future__ import absolute_import
+from . import Section
 from io import BytesIO
-from Ffs import Ffs
+from .Ffs import Ffs
 import subprocess
-from GenFdsGlobalVariable import GenFdsGlobalVariable
+from .GenFdsGlobalVariable import GenFdsGlobalVariable
 import Common.LongFilePathOs as os
 from CommonDataClass.FdfClass import FvImageSectionClassObject
 from Common import EdkLogger
diff --git a/BaseTools/Source/Python/GenFds/GenFds.py b/BaseTools/Source/Python/GenFds/GenFds.py
index 04fc17906a57..3931c7051be4 100644
--- a/BaseTools/Source/Python/GenFds/GenFds.py
+++ b/BaseTools/Source/Python/GenFds/GenFds.py
@@ -16,18 +16,19 @@
 # Import Modules
 #
 from __future__ import print_function
+from __future__ import absolute_import
 from builtins import range
 from optparse import OptionParser
 import sys
 import Common.LongFilePathOs as os
 import linecache
-import FdfParser
+from . import FdfParser
 import Common.BuildToolError as BuildToolError
-from GenFdsGlobalVariable import GenFdsGlobalVariable
+from .GenFdsGlobalVariable import GenFdsGlobalVariable
 from Workspace.WorkspaceDatabase import WorkspaceDatabase
 from Workspace.BuildClassObject import PcdClassObject
-import RuleComplexFile
-from EfiSection import EfiSection
+from . import RuleComplexFile
+from .EfiSection import EfiSection
 from io import BytesIO
 import Common.TargetTxtClassObject as TargetTxtClassObject
 import Common.ToolDefClassObject as ToolDefClassObject
@@ -41,7 +42,7 @@ from Common.Misc import ClearDuplicatedInf
 from Common.Misc import GuidStructureStringToGuidString
 from Common.BuildVersion import gBUILD_VERSION
 from Common.MultipleWorkspace import MultipleWorkspace as mws
-import FfsFileStatement
+from . import FfsFileStatement
 import glob
 from struct import unpack
 
diff --git a/BaseTools/Source/Python/GenFds/GuidSection.py b/BaseTools/Source/Python/GenFds/GuidSection.py
index bda185476b95..9c7ee3b3a6a9 100644
--- a/BaseTools/Source/Python/GenFds/GuidSection.py
+++ b/BaseTools/Source/Python/GenFds/GuidSection.py
@@ -16,19 +16,19 @@
 ##
 # Import Modules
 #
-import Section
+from __future__ import absolute_import
+from . import Section
 import subprocess
-from Ffs import Ffs
+from .Ffs import Ffs
 import Common.LongFilePathOs as os
-from GenFdsGlobalVariable import GenFdsGlobalVariable
+from .GenFdsGlobalVariable import GenFdsGlobalVariable
 from CommonDataClass.FdfClass import GuidSectionClassObject
 from Common import ToolDefClassObject
 import sys
 from Common import EdkLogger
 from Common.BuildToolError import *
-from FvImageSection import FvImageSection
+from .FvImageSection import FvImageSection
 from Common.LongFilePathSupport import OpenLongFilePath as open
-from GenFds import FindExtendTool
 from Common.DataType import *
 
 ## generate GUIDed section
@@ -131,6 +131,7 @@ class GuidSection(GuidSectionClassObject) :
         ExternalTool = None
         ExternalOption = None
         if self.NameGuid is not None:
+            from .GenFds import FindExtendTool
             ExternalTool, ExternalOption = FindExtendTool(self.KeyStringList, self.CurrentArchList, self.NameGuid)
 
         #
diff --git a/BaseTools/Source/Python/GenFds/OptRomFileStatement.py b/BaseTools/Source/Python/GenFds/OptRomFileStatement.py
index 4ef9b4d0e9a8..089d77494ffe 100644
--- a/BaseTools/Source/Python/GenFds/OptRomFileStatement.py
+++ b/BaseTools/Source/Python/GenFds/OptRomFileStatement.py
@@ -15,9 +15,10 @@
 ##
 # Import Modules
 #
+from __future__ import absolute_import
 import Common.LongFilePathOs as os
 
-from GenFdsGlobalVariable import GenFdsGlobalVariable
+from .GenFdsGlobalVariable import GenFdsGlobalVariable
 ## 
 #
 #
diff --git a/BaseTools/Source/Python/GenFds/OptRomInfStatement.py b/BaseTools/Source/Python/GenFds/OptRomInfStatement.py
index 79891b3b82a4..b377b6a7ba33 100644
--- a/BaseTools/Source/Python/GenFds/OptRomInfStatement.py
+++ b/BaseTools/Source/Python/GenFds/OptRomInfStatement.py
@@ -15,16 +15,16 @@
 ##
 # Import Modules
 #
-import RuleSimpleFile
-import RuleComplexFile
-import Section
-import OptionRom
+from __future__ import absolute_import
+from . import RuleSimpleFile
+from . import RuleComplexFile
+from . import Section
 import Common.GlobalData as GlobalData
 
 from Common.DataType import *
 from Common.StringUtils import *
-from FfsInfStatement import FfsInfStatement
-from GenFdsGlobalVariable import GenFdsGlobalVariable
+from .FfsInfStatement import FfsInfStatement
+from .GenFdsGlobalVariable import GenFdsGlobalVariable
 
 ## 
 #
@@ -46,6 +46,7 @@ class OptRomInfStatement (FfsInfStatement):
     #
     def __GetOptRomParams(self):
         
+        from . import OptionRom
         if self.OverrideAttribs is None:
             self.OverrideAttribs = OptionRom.OverrideAttribs()
 
@@ -151,4 +152,4 @@ class OptRomInfStatement (FfsInfStatement):
         
         return OutputFileList
 
-    
\ No newline at end of file
+    
diff --git a/BaseTools/Source/Python/GenFds/OptionRom.py b/BaseTools/Source/Python/GenFds/OptionRom.py
index 755eb01da7e1..901b5c4f3318 100644
--- a/BaseTools/Source/Python/GenFds/OptionRom.py
+++ b/BaseTools/Source/Python/GenFds/OptionRom.py
@@ -15,12 +15,12 @@
 ##
 # Import Modules
 #
+from __future__ import absolute_import
 import Common.LongFilePathOs as os
 import subprocess
 
-import OptRomInfStatement
-from GenFdsGlobalVariable import GenFdsGlobalVariable
-from GenFds import GenFds
+from . import OptRomInfStatement
+from .GenFdsGlobalVariable import GenFdsGlobalVariable
 from CommonDataClass.FdfClass import OptionRomClassObject
 from Common.Misc import SaveFileOnChange
 from Common import EdkLogger
diff --git a/BaseTools/Source/Python/GenFds/Region.py b/BaseTools/Source/Python/GenFds/Region.py
index 1b127345bcfb..c2dc31058de6 100644
--- a/BaseTools/Source/Python/GenFds/Region.py
+++ b/BaseTools/Source/Python/GenFds/Region.py
@@ -15,9 +15,10 @@
 ##
 # Import Modules
 #
+from __future__ import absolute_import
 from builtins import range
 from struct import *
-from GenFdsGlobalVariable import GenFdsGlobalVariable
+from .GenFdsGlobalVariable import GenFdsGlobalVariable
 from io import BytesIO
 import string
 from CommonDataClass.FdfClass import RegionClassObject
diff --git a/BaseTools/Source/Python/GenFds/RuleComplexFile.py b/BaseTools/Source/Python/GenFds/RuleComplexFile.py
index 36c483fbb207..c357fedbd3be 100644
--- a/BaseTools/Source/Python/GenFds/RuleComplexFile.py
+++ b/BaseTools/Source/Python/GenFds/RuleComplexFile.py
@@ -15,7 +15,8 @@
 ##
 # Import Modules
 #
-import Rule
+from __future__ import absolute_import
+from . import Rule
 from  CommonDataClass.FdfClass import RuleComplexFileClassObject
 
 ## complex rule
diff --git a/BaseTools/Source/Python/GenFds/RuleSimpleFile.py b/BaseTools/Source/Python/GenFds/RuleSimpleFile.py
index 061f984e6af4..7aa184e7d8bb 100644
--- a/BaseTools/Source/Python/GenFds/RuleSimpleFile.py
+++ b/BaseTools/Source/Python/GenFds/RuleSimpleFile.py
@@ -15,7 +15,8 @@
 ##
 # Import Modules
 #
-import Rule
+from __future__ import absolute_import
+from . import Rule
 from CommonDataClass.FdfClass import RuleSimpleFileClassObject
 
 ## simple rule
diff --git a/BaseTools/Source/Python/GenFds/Section.py b/BaseTools/Source/Python/GenFds/Section.py
index 5895998158b6..891a3734f7cc 100644
--- a/BaseTools/Source/Python/GenFds/Section.py
+++ b/BaseTools/Source/Python/GenFds/Section.py
@@ -15,8 +15,9 @@
 ##
 # Import Modules
 #
+from __future__ import absolute_import
 from CommonDataClass.FdfClass import SectionClassObject
-from GenFdsGlobalVariable import GenFdsGlobalVariable
+from .GenFdsGlobalVariable import GenFdsGlobalVariable
 import Common.LongFilePathOs as os, glob
 from Common import EdkLogger
 from Common.BuildToolError import *
diff --git a/BaseTools/Source/Python/GenFds/UiSection.py b/BaseTools/Source/Python/GenFds/UiSection.py
index 280500952b63..24f2f3ca938d 100644
--- a/BaseTools/Source/Python/GenFds/UiSection.py
+++ b/BaseTools/Source/Python/GenFds/UiSection.py
@@ -15,11 +15,12 @@
 ##
 # Import Modules
 #
-import Section
-from Ffs import Ffs
+from __future__ import absolute_import
+from . import Section
+from .Ffs import Ffs
 import subprocess
 import Common.LongFilePathOs as os
-from GenFdsGlobalVariable import GenFdsGlobalVariable
+from .GenFdsGlobalVariable import GenFdsGlobalVariable
 from CommonDataClass.FdfClass import UiSectionClassObject
 from Common.LongFilePathSupport import OpenLongFilePath as open
 from Common.DataType import *
diff --git a/BaseTools/Source/Python/GenFds/VerSection.py b/BaseTools/Source/Python/GenFds/VerSection.py
index 456a430079bb..db71fe9653d4 100644
--- a/BaseTools/Source/Python/GenFds/VerSection.py
+++ b/BaseTools/Source/Python/GenFds/VerSection.py
@@ -15,11 +15,12 @@
 ##
 # Import Modules
 #
-from Ffs import Ffs
-import Section
+from __future__ import absolute_import
+from .Ffs import Ffs
+from . import Section
 import Common.LongFilePathOs as os
 import subprocess
-from GenFdsGlobalVariable import GenFdsGlobalVariable
+from .GenFdsGlobalVariable import GenFdsGlobalVariable
 from CommonDataClass.FdfClass import VerSectionClassObject
 from Common.LongFilePathSupport import OpenLongFilePath as open
 from Common.DataType import SUP_MODULE_SEC
diff --git a/BaseTools/Source/Python/GenFds/Vtf.py b/BaseTools/Source/Python/GenFds/Vtf.py
index 18ea37b9afdd..de0a8125abc1 100644
--- a/BaseTools/Source/Python/GenFds/Vtf.py
+++ b/BaseTools/Source/Python/GenFds/Vtf.py
@@ -15,7 +15,8 @@
 ##
 # Import Modules
 #
-from GenFdsGlobalVariable import GenFdsGlobalVariable
+from __future__ import absolute_import
+from .GenFdsGlobalVariable import GenFdsGlobalVariable
 import Common.LongFilePathOs as os
 from CommonDataClass.FdfClass import VtfClassObject
 from Common.LongFilePathSupport import OpenLongFilePath as open
diff --git a/BaseTools/Source/Python/Table/TableDataModel.py b/BaseTools/Source/Python/Table/TableDataModel.py
index 2c37592fc67c..6e29365e377e 100644
--- a/BaseTools/Source/Python/Table/TableDataModel.py
+++ b/BaseTools/Source/Python/Table/TableDataModel.py
@@ -14,9 +14,10 @@
 ##
 # Import Modules
 #
+from __future__ import absolute_import
 import Common.EdkLogger as EdkLogger
 import CommonDataClass.DataClass as DataClass
-from Table import Table
+from .Table import Table
 from Common.StringUtils import ConvertToSqlString
 
 ## TableDataModel
diff --git a/BaseTools/Source/Python/Table/TableDec.py b/BaseTools/Source/Python/Table/TableDec.py
index 97139c58d893..93e766a49f7b 100644
--- a/BaseTools/Source/Python/Table/TableDec.py
+++ b/BaseTools/Source/Python/Table/TableDec.py
@@ -14,9 +14,10 @@
 ##
 # Import Modules
 #
+from __future__ import absolute_import
 import Common.EdkLogger as EdkLogger
 import CommonDataClass.DataClass as DataClass
-from Table import Table
+from .Table import Table
 from Common.StringUtils import ConvertToSqlString
 
 ## TableDec
diff --git a/BaseTools/Source/Python/Table/TableDsc.py b/BaseTools/Source/Python/Table/TableDsc.py
index 4ac54933aa3b..51aec0625581 100644
--- a/BaseTools/Source/Python/Table/TableDsc.py
+++ b/BaseTools/Source/Python/Table/TableDsc.py
@@ -1,3 +1,4 @@
+from __future__ import absolute_import
 ## @file
 # This file is used to create/update/query/erase table for dsc datas
 #
@@ -16,7 +17,7 @@
 #
 import Common.EdkLogger as EdkLogger
 import CommonDataClass.DataClass as DataClass
-from Table import Table
+from .Table import Table
 from Common.StringUtils import ConvertToSqlString
 
 ## TableDsc
diff --git a/BaseTools/Source/Python/Table/TableEotReport.py b/BaseTools/Source/Python/Table/TableEotReport.py
index bccf25ca45d5..3e21b957205c 100644
--- a/BaseTools/Source/Python/Table/TableEotReport.py
+++ b/BaseTools/Source/Python/Table/TableEotReport.py
@@ -14,9 +14,10 @@
 ##
 # Import Modules
 #
+from __future__ import absolute_import
 import Common.EdkLogger as EdkLogger
 import Common.LongFilePathOs as os, time
-from Table import Table
+from .Table import Table
 from Common.StringUtils import ConvertToSqlString2
 import Eot.EotToolError as EotToolError
 import Eot.EotGlobalData as EotGlobalData
@@ -73,4 +74,4 @@ class TableEotReport(Table):
         SqlCommand = """select max(ID) from %s""" % self.Table
         self.Cur.execute(SqlCommand)
         for Item in self.Cur:
-            return Item[0]
\ No newline at end of file
+            return Item[0]
diff --git a/BaseTools/Source/Python/Table/TableFdf.py b/BaseTools/Source/Python/Table/TableFdf.py
index eea8e9404d55..6869c3d06820 100644
--- a/BaseTools/Source/Python/Table/TableFdf.py
+++ b/BaseTools/Source/Python/Table/TableFdf.py
@@ -14,9 +14,10 @@
 ##
 # Import Modules
 #
+from __future__ import absolute_import
 import Common.EdkLogger as EdkLogger
 import CommonDataClass.DataClass as DataClass
-from Table import Table
+from .Table import Table
 from Common.StringUtils import ConvertToSqlString
 
 ## TableFdf
diff --git a/BaseTools/Source/Python/Table/TableFile.py b/BaseTools/Source/Python/Table/TableFile.py
index ac762ea7fcc0..cc8120e4de9b 100644
--- a/BaseTools/Source/Python/Table/TableFile.py
+++ b/BaseTools/Source/Python/Table/TableFile.py
@@ -14,8 +14,9 @@
 ##
 # Import Modules
 #
+from __future__ import absolute_import
 import Common.EdkLogger as EdkLogger
-from Table import Table
+from .Table import Table
 from Common.StringUtils import ConvertToSqlString
 import Common.LongFilePathOs as os
 from CommonDataClass.DataClass import FileClass
diff --git a/BaseTools/Source/Python/Table/TableFunction.py b/BaseTools/Source/Python/Table/TableFunction.py
index 3d40bd61f695..9d482ccc7e4b 100644
--- a/BaseTools/Source/Python/Table/TableFunction.py
+++ b/BaseTools/Source/Python/Table/TableFunction.py
@@ -14,8 +14,9 @@
 ##
 # Import Modules
 #
+from __future__ import absolute_import
 import Common.EdkLogger as EdkLogger
-from Table import Table
+from .Table import Table
 from Common.StringUtils import ConvertToSqlString
 
 ## TableFunction
diff --git a/BaseTools/Source/Python/Table/TableIdentifier.py b/BaseTools/Source/Python/Table/TableIdentifier.py
index 0ec8b3c162ce..fa9d4406bb6e 100644
--- a/BaseTools/Source/Python/Table/TableIdentifier.py
+++ b/BaseTools/Source/Python/Table/TableIdentifier.py
@@ -14,9 +14,10 @@
 ##
 # Import Modules
 #
+from __future__ import absolute_import
 import Common.EdkLogger as EdkLogger
 from Common.StringUtils import ConvertToSqlString
-from Table import Table
+from .Table import Table
 
 ## TableIdentifier
 #
@@ -87,4 +88,4 @@ class TableIdentifier(Table):
                                            % (self.Table, self.ID, Modifier, Type, Name, Value, Model, BelongsToFile, BelongsToFunction, StartLine, StartColumn, EndLine, EndColumn)
         Table.Insert(self, SqlCommand)
 
-        return self.ID
\ No newline at end of file
+        return self.ID
diff --git a/BaseTools/Source/Python/Table/TableInf.py b/BaseTools/Source/Python/Table/TableInf.py
index 478b77776e35..94f05c918525 100644
--- a/BaseTools/Source/Python/Table/TableInf.py
+++ b/BaseTools/Source/Python/Table/TableInf.py
@@ -14,9 +14,10 @@
 ##
 # Import Modules
 #
+from __future__ import absolute_import
 import Common.EdkLogger as EdkLogger
 import CommonDataClass.DataClass as DataClass
-from Table import Table
+from .Table import Table
 from Common.StringUtils import ConvertToSqlString
 
 ## TableInf
diff --git a/BaseTools/Source/Python/Table/TablePcd.py b/BaseTools/Source/Python/Table/TablePcd.py
index ca1c0f0c8ab2..adac47d12383 100644
--- a/BaseTools/Source/Python/Table/TablePcd.py
+++ b/BaseTools/Source/Python/Table/TablePcd.py
@@ -14,8 +14,9 @@
 ##
 # Import Modules
 #
+from __future__ import absolute_import
 import Common.EdkLogger as EdkLogger
-from Table import Table
+from .Table import Table
 from Common.StringUtils import ConvertToSqlString
 
 ## TablePcd
@@ -87,4 +88,4 @@ class TablePcd(Table):
                                            % (self.Table, self.ID, CName, TokenSpaceGuidCName, Token, DatumType, Model, BelongsToFile, BelongsToFunction, StartLine, StartColumn, EndLine, EndColumn)
         Table.Insert(self, SqlCommand)
 
-        return self.ID
\ No newline at end of file
+        return self.ID
diff --git a/BaseTools/Source/Python/Table/TableQuery.py b/BaseTools/Source/Python/Table/TableQuery.py
index f377b10561dc..a991e610dafd 100644
--- a/BaseTools/Source/Python/Table/TableQuery.py
+++ b/BaseTools/Source/Python/Table/TableQuery.py
@@ -14,9 +14,10 @@
 ##
 # Import Modules
 #
+from __future__ import absolute_import
 import Common.EdkLogger as EdkLogger
 from Common.StringUtils import ConvertToSqlString
-from Table import Table
+from .Table import Table
 
 ## TableQuery
 #
diff --git a/BaseTools/Source/Python/Table/TableReport.py b/BaseTools/Source/Python/Table/TableReport.py
index 9ce1d0aa2518..b46d082a470a 100644
--- a/BaseTools/Source/Python/Table/TableReport.py
+++ b/BaseTools/Source/Python/Table/TableReport.py
@@ -14,9 +14,10 @@
 ##
 # Import Modules
 #
+from __future__ import absolute_import
 import Common.EdkLogger as EdkLogger
 import Common.LongFilePathOs as os, time
-from Table import Table
+from .Table import Table
 from Common.StringUtils import ConvertToSqlString2
 import EccToolError as EccToolError
 import EccGlobalData as EccGlobalData
diff --git a/BaseTools/Source/Python/UPT/Library/Parsing.py b/BaseTools/Source/Python/UPT/Library/Parsing.py
index 22faabfa4bb0..10bd603be9cb 100644
--- a/BaseTools/Source/Python/UPT/Library/Parsing.py
+++ b/BaseTools/Source/Python/UPT/Library/Parsing.py
@@ -16,6 +16,7 @@
 '''
 Parsing
 '''
+from __future__ import absolute_import
 
 ##
 # Import Modules
@@ -43,7 +44,7 @@ from Logger import StringTable as ST
 import Logger.Log as Logger
 
 from Parser.DecParser import Dec
-import GlobalData
+from . import GlobalData
 
 gPKG_INFO_DICT = {}
 
diff --git a/BaseTools/Source/Python/Workspace/DscBuildData.py b/BaseTools/Source/Python/Workspace/DscBuildData.py
index 09002526b8b0..145ebb56e9ce 100644
--- a/BaseTools/Source/Python/Workspace/DscBuildData.py
+++ b/BaseTools/Source/Python/Workspace/DscBuildData.py
@@ -18,6 +18,7 @@
 # into PlatformBuildClassObject form for easier use for AutoGen.
 #
 from __future__ import print_function
+from __future__ import absolute_import
 from builtins import range
 from Common.StringUtils import *
 from Common.DataType import *
@@ -27,11 +28,11 @@ from Common.Expression import *
 from CommonDataClass.CommonClass import SkuInfoClass
 from Common.TargetTxtClassObject import *
 from Common.ToolDefClassObject import *
-from MetaDataTable import *
-from MetaFileTable import *
-from MetaFileParser import *
+from .MetaDataTable import *
+from .MetaFileTable import *
+from .MetaFileParser import *
 
-from WorkspaceCommon import GetDeclaredPcd
+from .WorkspaceCommon import GetDeclaredPcd
 from Common.Misc import AnalyzeDscPcd
 from Common.Misc import ProcessDuplicatedInf
 import re
diff --git a/BaseTools/Source/Python/Workspace/InfBuildData.py b/BaseTools/Source/Python/Workspace/InfBuildData.py
index 658f86ac891c..b2aa1f755b77 100644
--- a/BaseTools/Source/Python/Workspace/InfBuildData.py
+++ b/BaseTools/Source/Python/Workspace/InfBuildData.py
@@ -12,12 +12,13 @@
 # WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
 #
 
+from __future__ import absolute_import
 from builtins import range
 from Common.StringUtils import *
 from Common.DataType import *
 from Common.Misc import *
 from types import *
-from MetaFileParser import *
+from .MetaFileParser import *
 from collections import OrderedDict
 
 from Workspace.BuildClassObject import ModuleBuildClassObject, LibraryClassObject, PcdClassObject
diff --git a/BaseTools/Source/Python/Workspace/MetaFileParser.py b/BaseTools/Source/Python/Workspace/MetaFileParser.py
index b05d381bdf1a..79624da12ebb 100644
--- a/BaseTools/Source/Python/Workspace/MetaFileParser.py
+++ b/BaseTools/Source/Python/Workspace/MetaFileParser.py
@@ -16,6 +16,7 @@
 # Import Modules
 #
 from __future__ import print_function
+from __future__ import absolute_import
 from builtins import range
 import Common.LongFilePathOs as os
 import re
@@ -34,8 +35,8 @@ from Common.Expression import *
 from CommonDataClass.Exceptions import *
 from Common.LongFilePathSupport import OpenLongFilePath as open
 from collections import defaultdict
-from MetaFileTable import MetaFileStorage
-from MetaFileCommentParser import CheckInfComment
+from .MetaFileTable import MetaFileStorage
+from .MetaFileCommentParser import CheckInfComment
 
 ## RegEx for finding file versions
 hexVersionPattern = re.compile(r'0[xX][\da-f-A-F]{5,8}')
diff --git a/BaseTools/Source/Python/Workspace/MetaFileTable.py b/BaseTools/Source/Python/Workspace/MetaFileTable.py
index 69b2c40e7f1a..c68d1e0a01cb 100644
--- a/BaseTools/Source/Python/Workspace/MetaFileTable.py
+++ b/BaseTools/Source/Python/Workspace/MetaFileTable.py
@@ -14,13 +14,14 @@
 ##
 # Import Modules
 #
+from __future__ import absolute_import
 import uuid
 
 import Common.EdkLogger as EdkLogger
 from Common.BuildToolError import FORMAT_INVALID
 
-from MetaDataTable import Table, TableFile
-from MetaDataTable import ConvertToSqlString
+from .MetaDataTable import Table, TableFile
+from .MetaDataTable import ConvertToSqlString
 from CommonDataClass.DataClass import MODEL_FILE_DSC, MODEL_FILE_DEC, MODEL_FILE_INF, \
                                       MODEL_FILE_OTHERS
 from Common.DataType import *
diff --git a/BaseTools/Source/Python/Workspace/WorkspaceCommon.py b/BaseTools/Source/Python/Workspace/WorkspaceCommon.py
index e8f159b26204..d987bbf441ea 100644
--- a/BaseTools/Source/Python/Workspace/WorkspaceCommon.py
+++ b/BaseTools/Source/Python/Workspace/WorkspaceCommon.py
@@ -11,9 +11,10 @@
 # WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
 #
 
+from __future__ import absolute_import
 from collections import OrderedDict, defaultdict
 from Common.DataType import SUP_MODULE_USER_DEFINED
-from BuildClassObject import LibraryClassObject
+from .BuildClassObject import LibraryClassObject
 import Common.GlobalData as GlobalData
 from Workspace.BuildClassObject import StructurePcd
 from Common.BuildToolError import RESOURCE_NOT_AVAILABLE
diff --git a/BaseTools/Source/Python/Workspace/WorkspaceDatabase.py b/BaseTools/Source/Python/Workspace/WorkspaceDatabase.py
index 9e055fcfc46b..0ee8cdedd8b3 100644
--- a/BaseTools/Source/Python/Workspace/WorkspaceDatabase.py
+++ b/BaseTools/Source/Python/Workspace/WorkspaceDatabase.py
@@ -15,15 +15,16 @@
 ##
 # Import Modules
 #
+from __future__ import absolute_import
 import sqlite3
 from Common.StringUtils import *
 from Common.DataType import *
 from Common.Misc import *
 from types import *
 
-from MetaDataTable import *
-from MetaFileTable import *
-from MetaFileParser import *
+from .MetaDataTable import *
+from .MetaFileTable import *
+from .MetaFileParser import *
 
 from Workspace.DecBuildData import DecBuildData
 from Workspace.DscBuildData import DscBuildData
diff --git a/BaseTools/Source/Python/build/build.py b/BaseTools/Source/Python/build/build.py
index 08e81016de8b..e612ff77eab1 100644
--- a/BaseTools/Source/Python/build/build.py
+++ b/BaseTools/Source/Python/build/build.py
@@ -17,6 +17,7 @@
 # Import Modules
 #
 from __future__ import print_function
+from __future__ import absolute_import
 import Common.LongFilePathOs as os
 import re
 from io import BytesIO
@@ -46,7 +47,7 @@ from Common.BuildToolError import *
 from Workspace.WorkspaceDatabase import *
 from Common.MultipleWorkspace import MultipleWorkspace as mws
 
-from BuildReport import BuildReport
+from .BuildReport import BuildReport
 from GenPatchPcdTable.GenPatchPcdTable import *
 from PatchPcdValue.PatchPcdValue import *
 
-- 
2.17.1



  parent reply	other threads:[~2018-06-21  4:44 UTC|newest]

Thread overview: 37+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-06-21  4:43 [PATCH v3 00/20] BaseTools: One step toward python3 Gary Lin
2018-06-21  4:43 ` [PATCH v3 01/20] BaseTools: Fix a typo in ini.py Gary Lin
2018-06-21 15:46   ` Carsey, Jaben
2018-06-21  4:43 ` [PATCH v3 02/20] BaseTools: Refactor python except statements Gary Lin
2018-06-21  6:27   ` Gary Lin
2018-06-21  4:43 ` [PATCH v3 03/20] BaseTools: Refactor python print statements Gary Lin
2018-06-21  4:43 ` [PATCH v3 04/20] BaseTools: Remove the old python "not-equal" Gary Lin
2018-06-21  4:43 ` [PATCH v3 05/20] BaseTools: Use the python3-range functions Gary Lin
2018-06-21 12:40   ` Zhu, Yonghong
2018-06-22  2:04     ` Gary Lin
2018-06-22  5:29       ` Zhu, Yonghong
2018-06-22  8:21         ` Gary Lin
2018-06-22  8:45           ` Gary Lin
2018-06-22  8:53             ` Zhu, Yonghong
2018-06-22  9:13               ` Gary Lin
2018-06-22  9:22                 ` Zhu, Yonghong
2018-06-22  9:24                 ` Zhu, Yonghong
2018-06-22  9:48                   ` Gary Lin
2018-06-22 10:22                     ` Zhu, Yonghong
2018-06-25  3:34                       ` Gary Lin
2018-06-25  5:58                         ` Zhu, Yonghong
2018-06-25  6:18                           ` Gary Lin
2018-06-21  4:43 ` [PATCH v3 06/20] BaseTools: Remove tuple parameter in python scripts Gary Lin
2018-06-21  4:43 ` [PATCH v3 07/20] BaseTools: Remove the deprecated hash_key() Gary Lin
2018-06-21  4:43 ` [PATCH v3 08/20] BaseTools: Replace StandardError with Expression Gary Lin
2018-06-21  4:43 ` [PATCH v3 09/20] BaseTools: Remove types.TypeType Gary Lin
2018-06-21  4:43 ` [PATCH v3 10/20] BaseTools: Refactor python raise statement Gary Lin
2018-06-21  4:43 ` [PATCH v3 11/20] BaseTools: Adjust the spaces around commas and colons Gary Lin
2018-06-21  4:43 ` [PATCH v3 12/20] BaseTools: Migrate to the new octal literal Gary Lin
2018-06-21  4:43 ` [PATCH v3 13/20] BaseTools: Unify long int and int in python scripts Gary Lin
2018-06-21  4:43 ` [PATCH v3 14/20] BaseTools: Fix old python2 idioms Gary Lin
2018-06-21  4:43 ` [PATCH v3 15/20] BaseTools: Replace StringIO.StringIO with io.BytesIO Gary Lin
2018-06-21  4:43 ` [PATCH v3 16/20] BaseTools: Treat GenFds.py and build.py as python modules Gary Lin
2018-06-21  4:43 ` Gary Lin [this message]
2018-06-21  4:43 ` [PATCH v3 18/20] BaseTools: Move OverrideAttribs to OptRomInfStatement.py Gary Lin
2018-06-21  4:43 ` [PATCH v3 19/20] BaseTools: Move FindExtendTool to GenFdsGlobalVariable.py Gary Lin
2018-06-21  4:43 ` [PATCH v3 20/20] BaseTools: Move ImageBinDict " Gary Lin

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-list from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20180621044346.28495-18-glin@suse.com \
    --to=devel@edk2.groups.io \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox