[PATCH v2 13/14] patman: Move to absolute imports

Simon Glass sjg at chromium.org
Sat Apr 18 02:09:04 CEST 2020


At present patman sets the python path on startup so that it can access
the libraries it needs. If we convert to use absolute imports this is not
necessary.

Move patman to use absolute imports. This requires changes in tools which
use the patman libraries (which is most of them).

Signed-off-by: Simon Glass <sjg at chromium.org>
---

Changes in v2:
- Expand to convert all Python tools in U-Boot

 tools/binman/cbfs_util.py                      |  4 ++--
 tools/binman/cbfs_util_test.py                 |  4 ++--
 tools/binman/control.py                        |  6 +++---
 tools/binman/elf.py                            |  6 +++---
 tools/binman/elf_test.py                       |  8 ++++----
 tools/binman/entry.py                          |  4 ++--
 tools/binman/entry_test.py                     |  2 +-
 tools/binman/etype/_testing.py                 |  2 +-
 tools/binman/etype/blob.py                     |  4 ++--
 tools/binman/etype/fdtmap.py                   |  4 ++--
 tools/binman/etype/files.py                    |  2 +-
 tools/binman/etype/fill.py                     |  2 +-
 tools/binman/etype/fmap.py                     |  4 ++--
 tools/binman/etype/gbb.py                      |  4 ++--
 tools/binman/etype/intel_ifwi.py               |  2 +-
 tools/binman/etype/section.py                  |  4 ++--
 tools/binman/etype/text.py                     |  2 +-
 tools/binman/etype/u_boot_dtb_with_ucode.py    |  2 +-
 tools/binman/etype/u_boot_elf.py               |  2 +-
 tools/binman/etype/u_boot_spl_bss_pad.py       |  4 ++--
 .../binman/etype/u_boot_tpl_with_ucode_ptr.py  |  4 ++--
 tools/binman/etype/u_boot_ucode.py             |  2 +-
 tools/binman/etype/u_boot_with_ucode_ptr.py    |  4 ++--
 tools/binman/etype/vblock.py                   |  2 +-
 tools/binman/fdt_test.py                       |  2 +-
 tools/binman/fmap_util.py                      |  2 +-
 tools/binman/ftest.py                          |  8 ++++----
 tools/binman/image.py                          |  4 ++--
 tools/binman/main.py                           |  2 +-
 tools/binman/state.py                          |  4 ++--
 tools/buildman/builder.py                      |  8 ++++----
 tools/buildman/builderthread.py                |  4 ++--
 tools/buildman/control.py                      | 10 +++++-----
 tools/buildman/func_test.py                    |  9 ++++-----
 tools/buildman/main.py                         |  6 +++---
 tools/buildman/test.py                         | 10 +++++-----
 tools/buildman/toolchain.py                    |  6 +++---
 tools/dtoc/dtb_platdata.py                     |  6 +++---
 tools/dtoc/fdt.py                              |  4 ++--
 tools/dtoc/fdt_util.py                         |  4 ++--
 tools/dtoc/main.py                             |  5 +++--
 tools/dtoc/test_dtoc.py                        | 10 +++++-----
 tools/dtoc/test_fdt.py                         | 12 ++++++------
 tools/patman/checkpatch.py                     |  8 +++++---
 tools/patman/command.py                        |  5 +++--
 tools/patman/func_test.py                      |  8 ++++----
 tools/patman/get_maintainer.py                 |  5 +++--
 tools/patman/gitutil.py                        | 12 ++++++------
 tools/patman/main.py                           | 18 +++++++++---------
 tools/patman/patchstream.py                    |  8 ++++----
 tools/patman/project.py                        |  2 +-
 tools/patman/series.py                         | 10 +++++-----
 tools/patman/settings.py                       |  6 +++---
 tools/patman/test.py                           | 10 +++++-----
 tools/patman/test_util.py                      |  3 ++-
 tools/patman/tools.py                          |  4 ++--
 tools/patman/tout.py                           |  2 +-
 tools/rmboard.py                               |  2 +-
 58 files changed, 154 insertions(+), 149 deletions(-)

diff --git a/tools/binman/cbfs_util.py b/tools/binman/cbfs_util.py
index f7c3cd0d0e..39973371b9 100644
--- a/tools/binman/cbfs_util.py
+++ b/tools/binman/cbfs_util.py
@@ -21,8 +21,8 @@ import struct
 import sys
 
 from binman import elf
-import command
-import tools
+from patman import command
+from patman import tools
 
 # Set to True to enable printing output while working
 DEBUG = False
diff --git a/tools/binman/cbfs_util_test.py b/tools/binman/cbfs_util_test.py
index a929612b19..2c62c8a0f8 100755
--- a/tools/binman/cbfs_util_test.py
+++ b/tools/binman/cbfs_util_test.py
@@ -19,8 +19,8 @@ import unittest
 from binman import cbfs_util
 from binman.cbfs_util import CbfsWriter
 from binman import elf
-import test_util
-import tools
+from patman import test_util
+from patman import tools
 
 U_BOOT_DATA           = b'1234'
 U_BOOT_DTB_DATA       = b'udtb'
diff --git a/tools/binman/control.py b/tools/binman/control.py
index d715b601b9..dc1dd2a7dc 100644
--- a/tools/binman/control.py
+++ b/tools/binman/control.py
@@ -8,12 +8,12 @@
 from collections import OrderedDict
 import os
 import sys
-import tools
+from patman import tools
 
 from binman import cbfs_util
 from binman import elf
-import command
-import tout
+from patman import command
+from patman import tout
 
 # List of images we plan to create
 # Make this global so that it can be referenced from tests
diff --git a/tools/binman/elf.py b/tools/binman/elf.py
index 335d411303..f88031c2bf 100644
--- a/tools/binman/elf.py
+++ b/tools/binman/elf.py
@@ -13,9 +13,9 @@ import shutil
 import struct
 import tempfile
 
-import command
-import tools
-import tout
+from patman import command
+from patman import tools
+from patman import tout
 
 ELF_TOOLS = True
 try:
diff --git a/tools/binman/elf_test.py b/tools/binman/elf_test.py
index e4497f30fc..37e1b423cf 100644
--- a/tools/binman/elf_test.py
+++ b/tools/binman/elf_test.py
@@ -11,10 +11,10 @@ import tempfile
 import unittest
 
 from binman import elf
-import command
-import test_util
-import tools
-import tout
+from patman import command
+from patman import test_util
+from patman import tools
+from patman import tout
 
 binman_dir = os.path.dirname(os.path.realpath(sys.argv[0]))
 
diff --git a/tools/binman/entry.py b/tools/binman/entry.py
index 9f62322bed..90ffd27617 100644
--- a/tools/binman/entry.py
+++ b/tools/binman/entry.py
@@ -10,9 +10,9 @@ import os
 import sys
 
 from dtoc import fdt_util
-import tools
+from patman import tools
 from patman.tools import ToHex, ToHexSize
-import tout
+from patman import tout
 
 modules = {}
 
diff --git a/tools/binman/entry_test.py b/tools/binman/entry_test.py
index ca5bb0fe1b..80802f33de 100644
--- a/tools/binman/entry_test.py
+++ b/tools/binman/entry_test.py
@@ -12,7 +12,7 @@ import unittest
 from binman import entry
 from dtoc import fdt
 from dtoc import fdt_util
-import tools
+from patman import tools
 
 class TestEntry(unittest.TestCase):
     def setUp(self):
diff --git a/tools/binman/etype/_testing.py b/tools/binman/etype/_testing.py
index 4cde8df6f5..ed718eed14 100644
--- a/tools/binman/etype/_testing.py
+++ b/tools/binman/etype/_testing.py
@@ -9,7 +9,7 @@ from collections import OrderedDict
 
 from binman.entry import Entry, EntryArg
 from dtoc import fdt_util
-import tools
+from patman import tools
 
 
 class Entry__testing(Entry):
diff --git a/tools/binman/etype/blob.py b/tools/binman/etype/blob.py
index 409beaadcc..ede7a7a68c 100644
--- a/tools/binman/etype/blob.py
+++ b/tools/binman/etype/blob.py
@@ -7,8 +7,8 @@
 
 from binman.entry import Entry
 from dtoc import fdt_util
-import tools
-import tout
+from patman import tools
+from patman import tout
 
 class Entry_blob(Entry):
     """Entry containing an arbitrary binary blob
diff --git a/tools/binman/etype/fdtmap.py b/tools/binman/etype/fdtmap.py
index 820f34515a..aa8807990b 100644
--- a/tools/binman/etype/fdtmap.py
+++ b/tools/binman/etype/fdtmap.py
@@ -9,8 +9,8 @@ image.
 """
 
 from binman.entry import Entry
-import tools
-import tout
+from patman import tools
+from patman import tout
 
 FDTMAP_MAGIC   = b'_FDTMAP_'
 FDTMAP_HDR_LEN = 16
diff --git a/tools/binman/etype/files.py b/tools/binman/etype/files.py
index 7b4fc7db91..10ab585f0e 100644
--- a/tools/binman/etype/files.py
+++ b/tools/binman/etype/files.py
@@ -11,7 +11,7 @@ import os
 
 from binman.etype.section import Entry_section
 from dtoc import fdt_util
-import tools
+from patman import tools
 
 
 class Entry_files(Entry_section):
diff --git a/tools/binman/etype/fill.py b/tools/binman/etype/fill.py
index 1124ef26ea..860410ed6e 100644
--- a/tools/binman/etype/fill.py
+++ b/tools/binman/etype/fill.py
@@ -5,7 +5,7 @@
 
 from binman.entry import Entry
 from dtoc import fdt_util
-import tools
+from patman import tools
 
 class Entry_fill(Entry):
     """An entry which is filled to a particular byte value
diff --git a/tools/binman/etype/fmap.py b/tools/binman/etype/fmap.py
index a155beb617..a43fac38de 100644
--- a/tools/binman/etype/fmap.py
+++ b/tools/binman/etype/fmap.py
@@ -7,9 +7,9 @@
 
 from binman.entry import Entry
 from binman import fmap_util
-import tools
+from patman import tools
 from patman.tools import ToHexSize
-import tout
+from patman import tout
 
 
 class Entry_fmap(Entry):
diff --git a/tools/binman/etype/gbb.py b/tools/binman/etype/gbb.py
index 0fc7667908..dd10599717 100644
--- a/tools/binman/etype/gbb.py
+++ b/tools/binman/etype/gbb.py
@@ -8,11 +8,11 @@
 
 from collections import OrderedDict
 
-import command
+from patman import command
 from binman.entry import Entry, EntryArg
 
 from dtoc import fdt_util
-import tools
+from patman import tools
 
 # Build GBB flags.
 # (src/platform/vboot_reference/firmware/include/gbb_header.h)
diff --git a/tools/binman/etype/intel_ifwi.py b/tools/binman/etype/intel_ifwi.py
index 1545476f8f..6a96f6be55 100644
--- a/tools/binman/etype/intel_ifwi.py
+++ b/tools/binman/etype/intel_ifwi.py
@@ -10,7 +10,7 @@ from collections import OrderedDict
 from binman.entry import Entry
 from binman.etype.blob import Entry_blob
 from dtoc import fdt_util
-import tools
+from patman import tools
 
 class Entry_intel_ifwi(Entry_blob):
     """Entry containing an Intel Integrated Firmware Image (IFWI) file
diff --git a/tools/binman/etype/section.py b/tools/binman/etype/section.py
index 5893249e11..91b8e0c110 100644
--- a/tools/binman/etype/section.py
+++ b/tools/binman/etype/section.py
@@ -14,8 +14,8 @@ import sys
 
 from binman.entry import Entry
 from dtoc import fdt_util
-import tools
-import tout
+from patman import tools
+from patman import tout
 
 
 class Entry_section(Entry):
diff --git a/tools/binman/etype/text.py b/tools/binman/etype/text.py
index cde816aec5..3577135adb 100644
--- a/tools/binman/etype/text.py
+++ b/tools/binman/etype/text.py
@@ -7,7 +7,7 @@ from collections import OrderedDict
 
 from binman.entry import Entry, EntryArg
 from dtoc import fdt_util
-import tools
+from patman import tools
 
 
 class Entry_text(Entry):
diff --git a/tools/binman/etype/u_boot_dtb_with_ucode.py b/tools/binman/etype/u_boot_dtb_with_ucode.py
index c802f477b4..aec145533e 100644
--- a/tools/binman/etype/u_boot_dtb_with_ucode.py
+++ b/tools/binman/etype/u_boot_dtb_with_ucode.py
@@ -7,7 +7,7 @@
 
 from binman.entry import Entry
 from binman.etype.blob_dtb import Entry_blob_dtb
-import tools
+from patman import tools
 
 class Entry_u_boot_dtb_with_ucode(Entry_blob_dtb):
     """A U-Boot device tree file, with the microcode removed
diff --git a/tools/binman/etype/u_boot_elf.py b/tools/binman/etype/u_boot_elf.py
index 5123b9dc1e..5f906e520c 100644
--- a/tools/binman/etype/u_boot_elf.py
+++ b/tools/binman/etype/u_boot_elf.py
@@ -9,7 +9,7 @@ from binman.entry import Entry
 from binman.etype.blob import Entry_blob
 
 from dtoc import fdt_util
-import tools
+from patman import tools
 
 class Entry_u_boot_elf(Entry_blob):
     """U-Boot ELF image
diff --git a/tools/binman/etype/u_boot_spl_bss_pad.py b/tools/binman/etype/u_boot_spl_bss_pad.py
index cfcca6b7c5..a6a177a128 100644
--- a/tools/binman/etype/u_boot_spl_bss_pad.py
+++ b/tools/binman/etype/u_boot_spl_bss_pad.py
@@ -9,9 +9,9 @@
 
 from binman import elf
 from binman.entry import Entry
-import command
+from patman import command
 from binman.etype.blob import Entry_blob
-import tools
+from patman import tools
 
 class Entry_u_boot_spl_bss_pad(Entry_blob):
     """U-Boot SPL binary padded with a BSS region
diff --git a/tools/binman/etype/u_boot_tpl_with_ucode_ptr.py b/tools/binman/etype/u_boot_tpl_with_ucode_ptr.py
index ca1f436c61..7f7fab7105 100644
--- a/tools/binman/etype/u_boot_tpl_with_ucode_ptr.py
+++ b/tools/binman/etype/u_boot_tpl_with_ucode_ptr.py
@@ -7,11 +7,11 @@
 
 import struct
 
-import command
+from patman import command
 from binman.entry import Entry
 from binman.etype.blob import Entry_blob
 from binman.etype.u_boot_with_ucode_ptr import Entry_u_boot_with_ucode_ptr
-import tools
+from patman import tools
 
 class Entry_u_boot_tpl_with_ucode_ptr(Entry_u_boot_with_ucode_ptr):
     """U-Boot TPL with embedded microcode pointer
diff --git a/tools/binman/etype/u_boot_ucode.py b/tools/binman/etype/u_boot_ucode.py
index 692ccceb71..d9e1a605ef 100644
--- a/tools/binman/etype/u_boot_ucode.py
+++ b/tools/binman/etype/u_boot_ucode.py
@@ -7,7 +7,7 @@
 
 from binman.entry import Entry
 from binman.etype.blob import Entry_blob
-import tools
+from patman import tools
 
 class Entry_u_boot_ucode(Entry_blob):
     """U-Boot microcode block
diff --git a/tools/binman/etype/u_boot_with_ucode_ptr.py b/tools/binman/etype/u_boot_with_ucode_ptr.py
index 47ee33caba..06047b654d 100644
--- a/tools/binman/etype/u_boot_with_ucode_ptr.py
+++ b/tools/binman/etype/u_boot_with_ucode_ptr.py
@@ -11,8 +11,8 @@ from binman import elf
 from binman.entry import Entry
 from binman.etype.blob import Entry_blob
 from dtoc import fdt_util
-import tools
-import command
+from patman import tools
+from patman import command
 
 class Entry_u_boot_with_ucode_ptr(Entry_blob):
     """U-Boot with embedded microcode pointer
diff --git a/tools/binman/etype/vblock.py b/tools/binman/etype/vblock.py
index c13ceda796..5753de7ec7 100644
--- a/tools/binman/etype/vblock.py
+++ b/tools/binman/etype/vblock.py
@@ -12,7 +12,7 @@ import os
 from binman.entry import Entry, EntryArg
 
 from dtoc import fdt_util
-import tools
+from patman import tools
 
 class Entry_vblock(Entry):
     """An entry which contains a Chromium OS verified boot block
diff --git a/tools/binman/fdt_test.py b/tools/binman/fdt_test.py
index a9ab04e80d..c491d40e9e 100644
--- a/tools/binman/fdt_test.py
+++ b/tools/binman/fdt_test.py
@@ -12,7 +12,7 @@ import unittest
 from dtoc import fdt
 from dtoc import fdt_util
 from dtoc.fdt import FdtScan
-import tools
+from patman import tools
 
 class TestFdt(unittest.TestCase):
     @classmethod
diff --git a/tools/binman/fmap_util.py b/tools/binman/fmap_util.py
index d0f956b622..25fe60a9cc 100644
--- a/tools/binman/fmap_util.py
+++ b/tools/binman/fmap_util.py
@@ -10,7 +10,7 @@ import collections
 import struct
 import sys
 
-import tools
+from patman import tools
 
 # constants imported from lib/fmap.h
 FMAP_SIGNATURE = b'__FMAP__'
diff --git a/tools/binman/ftest.py b/tools/binman/ftest.py
index a11675d9aa..5e24920088 100644
--- a/tools/binman/ftest.py
+++ b/tools/binman/ftest.py
@@ -29,10 +29,10 @@ from dtoc import fdt_util
 from binman.etype import fdtmap
 from binman.etype import image_header
 from image import Image
-import command
-import test_util
-import tools
-import tout
+from patman import command
+from patman import test_util
+from patman import tools
+from patman import tout
 
 # Contents of test files, corresponding to different entry types
 U_BOOT_DATA           = b'1234'
diff --git a/tools/binman/image.py b/tools/binman/image.py
index 50bd57cdcb..523b274c31 100644
--- a/tools/binman/image.py
+++ b/tools/binman/image.py
@@ -18,8 +18,8 @@ from binman.etype import image_header
 from binman.etype import section
 from dtoc import fdt
 from dtoc import fdt_util
-import tools
-import tout
+from patman import tools
+from patman import tout
 
 class Image(section.Entry_section):
     """A Image, representing an output from binman
diff --git a/tools/binman/main.py b/tools/binman/main.py
index 8736938d11..97a8a02034 100755
--- a/tools/binman/main.py
+++ b/tools/binman/main.py
@@ -36,7 +36,7 @@ sys.path.append(get_python_lib())
 
 from binman import cmdline
 from binman import control
-import test_util
+from patman import test_util
 
 def RunTests(debug, verbosity, processes, test_preserve_dirs, args, toolpath):
     """Run the functional tests and any embedded doctests
diff --git a/tools/binman/state.py b/tools/binman/state.py
index 7f85ab1f98..36bc513535 100644
--- a/tools/binman/state.py
+++ b/tools/binman/state.py
@@ -10,8 +10,8 @@ import re
 
 from dtoc import fdt
 import os
-import tools
-import tout
+from patman import tools
+from patman import tout
 
 # Records the device-tree files known to binman, keyed by entry type (e.g.
 # 'u-boot-spl-dtb'). These are the output FDT files, which can be updated by
diff --git a/tools/buildman/builder.py b/tools/buildman/builder.py
index b7f2c426e3..f8e71de427 100644
--- a/tools/buildman/builder.py
+++ b/tools/buildman/builder.py
@@ -19,10 +19,10 @@ import time
 
 from buildman import builderthread
 from buildman import toolchain
-import command
-import gitutil
-import terminal
-from terminal import Print
+from patman import command
+from patman import gitutil
+from patman import terminal
+from patman.terminal import Print
 
 """
 Theory of Operation
diff --git a/tools/buildman/builderthread.py b/tools/buildman/builderthread.py
index f673f386e4..48fcd6cf7e 100644
--- a/tools/buildman/builderthread.py
+++ b/tools/buildman/builderthread.py
@@ -9,8 +9,8 @@ import shutil
 import sys
 import threading
 
-import command
-import gitutil
+from patman import command
+from patman import gitutil
 
 RETURN_CODE_RETRY = -1
 
diff --git a/tools/buildman/control.py b/tools/buildman/control.py
index e05234c08f..071c2613ec 100644
--- a/tools/buildman/control.py
+++ b/tools/buildman/control.py
@@ -12,11 +12,11 @@ from buildman import board
 from buildman import bsettings
 from buildman import toolchain
 from buildman.builder import Builder
-import command
-import gitutil
-import patchstream
-import terminal
-from terminal import Print
+from patman import command
+from patman import gitutil
+from patman import patchstream
+from patman import terminal
+from patman.terminal import Print
 
 def GetPlural(count):
     """Returns a plural 's' if count is not 1"""
diff --git a/tools/buildman/func_test.py b/tools/buildman/func_test.py
index 9bfdd53698..418677f9cc 100644
--- a/tools/buildman/func_test.py
+++ b/tools/buildman/func_test.py
@@ -13,11 +13,10 @@ from buildman import bsettings
 from buildman import cmdline
 from buildman import control
 from buildman import toolchain
-import command
-import gitutil
-import terminal
-import toolchain
-import tools
+from patman import command
+from patman import gitutil
+from patman import terminal
+from patman import tools
 
 settings_data = '''
 # Buildman settings file
diff --git a/tools/buildman/main.py b/tools/buildman/main.py
index 94d495c40b..52a83fce7d 100755
--- a/tools/buildman/main.py
+++ b/tools/buildman/main.py
@@ -25,9 +25,9 @@ from buildman import builder
 from buildman import cmdline
 from buildman import control
 from buildman import toolchain
-import patchstream
-import gitutil
-import terminal
+from patman import patchstream
+from patman import gitutil
+from patman import terminal
 
 def RunTests(skip_net_tests):
     import func_test
diff --git a/tools/buildman/test.py b/tools/buildman/test.py
index 87175eeb63..b37c37b2fa 100644
--- a/tools/buildman/test.py
+++ b/tools/buildman/test.py
@@ -18,11 +18,11 @@ from buildman import bsettings
 from buildman import builder
 from buildman import control
 from buildman import toolchain
-import commit
-import command
-import terminal
-import test_util
-import tools
+from patman import commit
+from patman import command
+from patman import terminal
+from patman import test_util
+from patman import tools
 
 use_network = True
 
diff --git a/tools/buildman/toolchain.py b/tools/buildman/toolchain.py
index a3540491ec..acb5a29c8f 100644
--- a/tools/buildman/toolchain.py
+++ b/tools/buildman/toolchain.py
@@ -11,9 +11,9 @@ import tempfile
 import urllib.request, urllib.error, urllib.parse
 
 from buildman import bsettings
-import command
-import terminal
-import tools
+from patman import command
+from patman import terminal
+from patman import tools
 
 (PRIORITY_FULL_PREFIX, PRIORITY_PREFIX_GCC, PRIORITY_PREFIX_GCC_PATH,
     PRIORITY_CALC) = list(range(4))
diff --git a/tools/dtoc/dtb_platdata.py b/tools/dtoc/dtb_platdata.py
index 037e82c8bb..b86922b675 100644
--- a/tools/dtoc/dtb_platdata.py
+++ b/tools/dtoc/dtb_platdata.py
@@ -15,9 +15,9 @@ import collections
 import copy
 import sys
 
-import fdt
-import fdt_util
-import tools
+from dtoc import fdt
+from dtoc import fdt_util
+from patman import tools
 
 # When we see these properties we ignore them - i.e. do not create a structure member
 PROP_IGNORE_LIST = [
diff --git a/tools/dtoc/fdt.py b/tools/dtoc/fdt.py
index 1b7b730359..188490b728 100644
--- a/tools/dtoc/fdt.py
+++ b/tools/dtoc/fdt.py
@@ -8,10 +8,10 @@
 import struct
 import sys
 
-import fdt_util
+from dtoc import fdt_util
 import libfdt
 from libfdt import QUIET_NOTFOUND
-import tools
+from patman import tools
 
 # This deals with a device tree, presenting it as an assortment of Node and
 # Prop objects, representing nodes and properties, respectively. This file
diff --git a/tools/dtoc/fdt_util.py b/tools/dtoc/fdt_util.py
index b105faec74..b040793772 100644
--- a/tools/dtoc/fdt_util.py
+++ b/tools/dtoc/fdt_util.py
@@ -13,8 +13,8 @@ import struct
 import sys
 import tempfile
 
-import command
-import tools
+from patman import command
+from patman import tools
 
 def fdt32_to_cpu(val):
     """Convert a device tree cell to an integer
diff --git a/tools/dtoc/main.py b/tools/dtoc/main.py
index ac0e364bf2..8f3ec1deef 100755
--- a/tools/dtoc/main.py
+++ b/tools/dtoc/main.py
@@ -33,14 +33,15 @@ import unittest
 # Bring in the patman libraries
 our_path = os.path.dirname(os.path.realpath(__file__))
 sys.path.append(os.path.join(our_path, '../patman'))
+sys.path.append(os.path.join(our_path, '..'))
 
 # Bring in the libfdt module
 sys.path.insert(0, 'scripts/dtc/pylibfdt')
 sys.path.insert(0, os.path.join(our_path,
                 '../../build-sandbox_spl/scripts/dtc/pylibfdt'))
 
-import dtb_platdata
-import test_util
+from dtoc import dtb_platdata
+from patman import test_util
 
 def run_tests(args):
     """Run all the test we have for dtoc
diff --git a/tools/dtoc/test_dtoc.py b/tools/dtoc/test_dtoc.py
index 9db97489d4..8498e8303c 100755
--- a/tools/dtoc/test_dtoc.py
+++ b/tools/dtoc/test_dtoc.py
@@ -14,15 +14,15 @@ import os
 import struct
 import unittest
 
-import dtb_platdata
+from dtoc import dtb_platdata
 from dtb_platdata import conv_name_to_c
 from dtb_platdata import get_compat_name
 from dtb_platdata import get_value
 from dtb_platdata import tab_to
-import fdt
-import fdt_util
-import test_util
-import tools
+from dtoc import fdt
+from dtoc import fdt_util
+from patman import test_util
+from patman import tools
 
 our_path = os.path.dirname(os.path.realpath(__file__))
 
diff --git a/tools/dtoc/test_fdt.py b/tools/dtoc/test_fdt.py
index 4f39a5589f..d68230713e 100755
--- a/tools/dtoc/test_fdt.py
+++ b/tools/dtoc/test_fdt.py
@@ -17,14 +17,14 @@ our_path = os.path.dirname(os.path.realpath(__file__))
 for dirname in ['../patman', '..']:
     sys.path.insert(0, os.path.join(our_path, dirname))
 
-import command
-import fdt
+from dtoc import fdt
+from dtoc import fdt_util
+from dtoc.fdt_util import fdt32_to_cpu
 from fdt import TYPE_BYTE, TYPE_INT, TYPE_STRING, TYPE_BOOL, BytesToValue
-import fdt_util
-from fdt_util import fdt32_to_cpu
 import libfdt
-import test_util
-import tools
+from patman import command
+from patman import test_util
+from patman import tools
 
 def _GetPropertyValue(dtb, node, prop_name):
     """Low-level function to get the property value based on its offset
diff --git a/tools/patman/checkpatch.py b/tools/patman/checkpatch.py
index d47ea438b7..795b519314 100644
--- a/tools/patman/checkpatch.py
+++ b/tools/patman/checkpatch.py
@@ -3,12 +3,14 @@
 #
 
 import collections
-import command
-import gitutil
 import os
 import re
 import sys
-import terminal
+
+from patman import command
+from patman import gitutil
+from patman import terminal
+from patman import tools
 
 def FindCheckPatch():
     top_level = gitutil.GetTopLevel()
diff --git a/tools/patman/command.py b/tools/patman/command.py
index 5fbd2c4a3e..e67ac159e5 100644
--- a/tools/patman/command.py
+++ b/tools/patman/command.py
@@ -3,8 +3,9 @@
 #
 
 import os
-import cros_subprocess
-import tools
+
+from patman import cros_subprocess
+from patman import tools
 
 """Shell command ease-ups for Python."""
 
diff --git a/tools/patman/func_test.py b/tools/patman/func_test.py
index 748e225446..b7e2825de8 100644
--- a/tools/patman/func_test.py
+++ b/tools/patman/func_test.py
@@ -14,10 +14,10 @@ import unittest
 
 from io import StringIO
 
-import gitutil
-import patchstream
-import settings
-import tools
+from patman import gitutil
+from patman import patchstream
+from patman import settings
+from patman import tools
 
 
 @contextlib.contextmanager
diff --git a/tools/patman/get_maintainer.py b/tools/patman/get_maintainer.py
index 0ffb55a821..473f0feebf 100644
--- a/tools/patman/get_maintainer.py
+++ b/tools/patman/get_maintainer.py
@@ -2,10 +2,11 @@
 # Copyright (c) 2012 The Chromium OS Authors.
 #
 
-import command
-import gitutil
 import os
 
+from patman import command
+from patman import gitutil
+
 def FindGetMaintainer():
     """Look for the get_maintainer.pl script.
 
diff --git a/tools/patman/gitutil.py b/tools/patman/gitutil.py
index a2a225c6b9..770a051014 100644
--- a/tools/patman/gitutil.py
+++ b/tools/patman/gitutil.py
@@ -2,17 +2,17 @@
 # Copyright (c) 2011 The Chromium OS Authors.
 #
 
-import command
 import re
 import os
-import series
 import subprocess
 import sys
-import terminal
 
-import checkpatch
-import settings
-import tools
+from patman import checkpatch
+from patman import command
+from patman import series
+from patman import settings
+from patman import terminal
+from patman import tools
 
 # True to use --no-decorate - we check this in Setup()
 use_no_decorate = True
diff --git a/tools/patman/main.py b/tools/patman/main.py
index b642c2ed03..f59367fafb 100755
--- a/tools/patman/main.py
+++ b/tools/patman/main.py
@@ -18,14 +18,14 @@ if __name__ == "__main__":
     sys.path.append(os.path.join(our_path, '..'))
 
 # Our modules
-import checkpatch
-import command
-import gitutil
-import patchstream
-import project
-import settings
-import terminal
-import test
+from patman import checkpatch
+from patman import command
+from patman import gitutil
+from patman import patchstream
+from patman import project
+from patman import settings
+from patman import terminal
+from patman import test
 
 
 parser = OptionParser()
@@ -86,7 +86,7 @@ if __name__ != "__main__":
 # Run our meagre tests
 elif options.test:
     import doctest
-    import func_test
+    from patman import func_test
 
     sys.argv = [sys.argv[0]]
     result = unittest.TestResult()
diff --git a/tools/patman/patchstream.py b/tools/patman/patchstream.py
index df3eb7483b..405297505c 100644
--- a/tools/patman/patchstream.py
+++ b/tools/patman/patchstream.py
@@ -9,10 +9,10 @@ import re
 import shutil
 import tempfile
 
-import command
-import commit
-import gitutil
-from series import Series
+from patman import command
+from patman import commit
+from patman import gitutil
+from patman.series import Series
 
 # Tags that we detect and remove
 re_remove = re.compile('^BUG=|^TEST=|^BRANCH=|^Review URL:'
diff --git a/tools/patman/project.py b/tools/patman/project.py
index 1d9cfc0625..2dfc303729 100644
--- a/tools/patman/project.py
+++ b/tools/patman/project.py
@@ -4,7 +4,7 @@
 
 import os.path
 
-import gitutil
+from patman import gitutil
 
 def DetectProject():
     """Autodetect the name of the current project.
diff --git a/tools/patman/series.py b/tools/patman/series.py
index 3869696abc..e5e28cebdf 100644
--- a/tools/patman/series.py
+++ b/tools/patman/series.py
@@ -5,11 +5,11 @@
 import itertools
 import os
 
-import get_maintainer
-import gitutil
-import settings
-import terminal
-import tools
+from patman import get_maintainer
+from patman import gitutil
+from patman import settings
+from patman import terminal
+from patman import tools
 
 # Series-xxx tags that we understand
 valid_series = ['to', 'cc', 'version', 'changes', 'prefix', 'notes', 'name',
diff --git a/tools/patman/settings.py b/tools/patman/settings.py
index 21e8fc41a9..ca74fc611f 100644
--- a/tools/patman/settings.py
+++ b/tools/patman/settings.py
@@ -10,9 +10,9 @@ except:
 import os
 import re
 
-import command
-import gitutil
-import tools
+from patman import command
+from patman import gitutil
+from patman import tools
 
 """Default settings per-project.
 
diff --git a/tools/patman/test.py b/tools/patman/test.py
index 889e186606..e7f709e34c 100644
--- a/tools/patman/test.py
+++ b/tools/patman/test.py
@@ -8,11 +8,11 @@ import os
 import tempfile
 import unittest
 
-import checkpatch
-import gitutil
-import patchstream
-import series
-import commit
+from patman import checkpatch
+from patman import gitutil
+from patman import patchstream
+from patman import series
+from patman import commit
 
 
 class TestPatch(unittest.TestCase):
diff --git a/tools/patman/test_util.py b/tools/patman/test_util.py
index bb5a298e39..4d28d9fc92 100644
--- a/tools/patman/test_util.py
+++ b/tools/patman/test_util.py
@@ -10,7 +10,8 @@ import os
 import sys
 import unittest
 
-import command
+from patman import command
+from patman import test_util
 
 from io import StringIO
 
diff --git a/tools/patman/tools.py b/tools/patman/tools.py
index 7b21a128f3..b50370dfe8 100644
--- a/tools/patman/tools.py
+++ b/tools/patman/tools.py
@@ -3,7 +3,6 @@
 # Copyright (c) 2016 Google, Inc
 #
 
-import command
 import glob
 import os
 import shutil
@@ -11,7 +10,8 @@ import struct
 import sys
 import tempfile
 
-import tout
+from patman import command
+from patman import tout
 
 # Output directly (generally this is temporary)
 outdir = None
diff --git a/tools/patman/tout.py b/tools/patman/tout.py
index ee3c519c80..c7e3272096 100644
--- a/tools/patman/tout.py
+++ b/tools/patman/tout.py
@@ -6,7 +6,7 @@
 
 import sys
 
-import terminal
+from patman import terminal
 
 # Output verbosity levels that we support
 ERROR, WARNING, NOTICE, INFO, DETAIL, DEBUG = range(6)
diff --git a/tools/rmboard.py b/tools/rmboard.py
index 446e5d6ee2..1ed2527d0e 100755
--- a/tools/rmboard.py
+++ b/tools/rmboard.py
@@ -32,7 +32,7 @@ import sys
 our_path = os.path.dirname(os.path.realpath(__file__))
 sys.path.append(os.path.join(our_path, '../tools/patman'))
 
-import command
+from patman import command
 
 def rm_kconfig_include(path):
     """Remove a path from Kconfig files
-- 
2.26.1.301.g55bc3eb7cb9-goog



More information about the U-Boot mailing list