All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH 0/4] binman: Add support for Python installation
@ 2020-08-05 19:27 Simon Glass
  2020-08-05 19:27 ` [PATCH 1/4] binman: Move GetEntryModules() to control Simon Glass
                   ` (7 more replies)
  0 siblings, 8 replies; 9+ messages in thread
From: Simon Glass @ 2020-08-05 19:27 UTC (permalink / raw)
  To: u-boot

This series adds Python setup scripts for binman (and dtoc, since binman
uses that) so that it can be installed as a tool.

It also includes a few features found while getting this to work with
portage in Chrome OS.


Simon Glass (4):
  binman: Move GetEntryModules() to control
  binman: Correct some import statements
  dtoc: Add a setup script for Python
  binman: Add a setup script for Python

 tools/binman/control.py    | 17 +++++++++++++++--
 tools/binman/ftest.py      |  7 +++----
 tools/binman/image_test.py |  2 +-
 tools/binman/main.py       | 17 ++---------------
 tools/binman/setup.py      | 12 ++++++++++++
 tools/dtoc/setup.py        | 12 ++++++++++++
 6 files changed, 45 insertions(+), 22 deletions(-)
 create mode 100644 tools/binman/setup.py
 create mode 100644 tools/dtoc/setup.py

-- 
2.28.0.163.g6104cc2f0b6-goog

^ permalink raw reply	[flat|nested] 9+ messages in thread

* [PATCH 1/4] binman: Move GetEntryModules() to control
  2020-08-05 19:27 [PATCH 0/4] binman: Add support for Python installation Simon Glass
@ 2020-08-05 19:27 ` Simon Glass
  2020-08-05 19:27 ` [PATCH 2/4] binman: Correct some import statements Simon Glass
                   ` (6 subsequent siblings)
  7 siblings, 0 replies; 9+ messages in thread
From: Simon Glass @ 2020-08-05 19:27 UTC (permalink / raw)
  To: u-boot

When binman is installed its main program is in a different directory
to its modules. This means that __file__ is different and we cannot use
it to obtain the path to etype/ from main.py

To fix this, move the function to the 'control' module, since it is
installed with all the other modules, including the etype/ directory.

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

 tools/binman/control.py | 13 +++++++++++++
 tools/binman/ftest.py   |  5 ++---
 tools/binman/main.py    | 16 ++--------------
 3 files changed, 17 insertions(+), 17 deletions(-)

diff --git a/tools/binman/control.py b/tools/binman/control.py
index 343b0a0c35b..69c36ed6582 100644
--- a/tools/binman/control.py
+++ b/tools/binman/control.py
@@ -6,6 +6,7 @@
 #
 
 from collections import OrderedDict
+import glob
 import os
 import sys
 from patman import tools
@@ -51,6 +52,18 @@ def _FindBinmanNode(dtb):
             return node
     return None
 
+def GetEntryModules(include_testing=True):
+    """Get a set of entry class implementations
+
+    Returns:
+        Set of paths to entry class filenames
+    """
+    our_path = os.path.dirname(os.path.realpath(__file__))
+    glob_list = glob.glob(os.path.join(our_path, 'etype/*.py'))
+    return set([os.path.splitext(os.path.basename(item))[0]
+                for item in glob_list
+                if include_testing or '_testing' not in item])
+
 def WriteEntryDocs(modules, test_missing=None):
     """Write out documentation for all entries
 
diff --git a/tools/binman/ftest.py b/tools/binman/ftest.py
index bf7f59fb841..fedcc1ada1b 100644
--- a/tools/binman/ftest.py
+++ b/tools/binman/ftest.py
@@ -24,7 +24,6 @@ from binman import control
 from binman import elf
 from binman import elf_test
 from binman import fmap_util
-from binman import main
 from binman import state
 from dtoc import fdt
 from dtoc import fdt_util
@@ -1440,14 +1439,14 @@ class TestFunctional(unittest.TestCase):
     def testEntryDocs(self):
         """Test for creation of entry documentation"""
         with test_util.capture_sys_output() as (stdout, stderr):
-            control.WriteEntryDocs(main.GetEntryModules())
+            control.WriteEntryDocs(control.GetEntryModules())
         self.assertTrue(len(stdout.getvalue()) > 0)
 
     def testEntryDocsMissing(self):
         """Test handling of missing entry documentation"""
         with self.assertRaises(ValueError) as e:
             with test_util.capture_sys_output() as (stdout, stderr):
-                control.WriteEntryDocs(main.GetEntryModules(), 'u_boot')
+                control.WriteEntryDocs(control.GetEntryModules(), 'u_boot')
         self.assertIn('Documentation is missing for modules: u_boot',
                       str(e.exception))
 
diff --git a/tools/binman/main.py b/tools/binman/main.py
index e543a7d06a7..3e463b0119b 100755
--- a/tools/binman/main.py
+++ b/tools/binman/main.py
@@ -10,7 +10,6 @@
 """See README for more information"""
 
 from distutils.sysconfig import get_python_lib
-import glob
 import os
 import site
 import sys
@@ -78,20 +77,9 @@ def RunTests(debug, verbosity, processes, test_preserve_dirs, args, toolpath):
 
     return test_util.ReportResult('binman', test_name, result)
 
-def GetEntryModules(include_testing=True):
-    """Get a set of entry class implementations
-
-    Returns:
-        Set of paths to entry class filenames
-    """
-    glob_list = glob.glob(os.path.join(our_path, 'etype/*.py'))
-    return set([os.path.splitext(os.path.basename(item))[0]
-                for item in glob_list
-                if include_testing or '_testing' not in item])
-
 def RunTestCoverage(toolpath):
     """Run the tests and check that we get 100% coverage"""
-    glob_list = GetEntryModules(False)
+    glob_list = control.GetEntryModules(False)
     all_set = set([os.path.splitext(os.path.basename(item))[0]
                    for item in glob_list if '_testing' not in item])
     extra_args = ''
@@ -127,7 +115,7 @@ def RunBinman(args):
                                 args.toolpath)
 
     elif args.cmd == 'entry-docs':
-        control.WriteEntryDocs(GetEntryModules())
+        control.WriteEntryDocs(control.GetEntryModules())
 
     else:
         try:
-- 
2.28.0.163.g6104cc2f0b6-goog

^ permalink raw reply related	[flat|nested] 9+ messages in thread

* [PATCH 2/4] binman: Correct some import statements
  2020-08-05 19:27 [PATCH 0/4] binman: Add support for Python installation Simon Glass
  2020-08-05 19:27 ` [PATCH 1/4] binman: Move GetEntryModules() to control Simon Glass
@ 2020-08-05 19:27 ` Simon Glass
  2020-08-05 19:27 ` [PATCH 3/4] dtoc: Add a setup script for Python Simon Glass
                   ` (5 subsequent siblings)
  7 siblings, 0 replies; 9+ messages in thread
From: Simon Glass @ 2020-08-05 19:27 UTC (permalink / raw)
  To: u-boot

Some of these were not converted when binman moved to use absolute paths.
Fix them.

Also drop the import of 'test' which is a directory, not a module.

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

 tools/binman/control.py    | 4 ++--
 tools/binman/ftest.py      | 2 +-
 tools/binman/image_test.py | 2 +-
 tools/binman/main.py       | 1 -
 4 files changed, 4 insertions(+), 5 deletions(-)

diff --git a/tools/binman/control.py b/tools/binman/control.py
index 69c36ed6582..60e89d3776b 100644
--- a/tools/binman/control.py
+++ b/tools/binman/control.py
@@ -123,7 +123,7 @@ def ReadEntry(image_fname, entry_path, decomp=True):
         data extracted from the entry
     """
     global Image
-    from image import Image
+    from binman.image import Image
 
     image = Image.FromFile(image_fname)
     entry = image.FindEntryPath(entry_path)
@@ -496,7 +496,7 @@ def Binman(args):
         return 0
 
     # Put these here so that we can import this module without libfdt
-    from image import Image
+    from binman.image import Image
     from binman import state
 
     if args.cmd in ['ls', 'extract', 'replace']:
diff --git a/tools/binman/ftest.py b/tools/binman/ftest.py
index fedcc1ada1b..5f650b5f94c 100644
--- a/tools/binman/ftest.py
+++ b/tools/binman/ftest.py
@@ -29,7 +29,7 @@ from dtoc import fdt
 from dtoc import fdt_util
 from binman.etype import fdtmap
 from binman.etype import image_header
-from image import Image
+from binman.image import Image
 from patman import command
 from patman import test_util
 from patman import tools
diff --git a/tools/binman/image_test.py b/tools/binman/image_test.py
index f85c3c51c0f..e351fa84ab3 100644
--- a/tools/binman/image_test.py
+++ b/tools/binman/image_test.py
@@ -6,7 +6,7 @@
 
 import unittest
 
-from image import Image
+from binman.image import Image
 from patman.test_util import capture_sys_output
 
 class TestImage(unittest.TestCase):
diff --git a/tools/binman/main.py b/tools/binman/main.py
index 3e463b0119b..8c1e478d54c 100755
--- a/tools/binman/main.py
+++ b/tools/binman/main.py
@@ -61,7 +61,6 @@ def RunTests(debug, verbosity, processes, test_preserve_dirs, args, toolpath):
     from binman import fdt_test
     from binman import ftest
     from binman import image_test
-    from binman import test
     import doctest
 
     result = unittest.TestResult()
-- 
2.28.0.163.g6104cc2f0b6-goog

^ permalink raw reply related	[flat|nested] 9+ messages in thread

* [PATCH 3/4] dtoc: Add a setup script for Python
  2020-08-05 19:27 [PATCH 0/4] binman: Add support for Python installation Simon Glass
  2020-08-05 19:27 ` [PATCH 1/4] binman: Move GetEntryModules() to control Simon Glass
  2020-08-05 19:27 ` [PATCH 2/4] binman: Correct some import statements Simon Glass
@ 2020-08-05 19:27 ` Simon Glass
  2020-08-05 19:27 ` [PATCH 4/4] binman: " Simon Glass
                   ` (4 subsequent siblings)
  7 siblings, 0 replies; 9+ messages in thread
From: Simon Glass @ 2020-08-05 19:27 UTC (permalink / raw)
  To: u-boot

Allow dtoc to be installed by adding a suitable setup.py script.

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

 tools/dtoc/setup.py | 12 ++++++++++++
 1 file changed, 12 insertions(+)
 create mode 100644 tools/dtoc/setup.py

diff --git a/tools/dtoc/setup.py b/tools/dtoc/setup.py
new file mode 100644
index 00000000000..5e092fe0872
--- /dev/null
+++ b/tools/dtoc/setup.py
@@ -0,0 +1,12 @@
+# SPDX-License-Identifier: GPL-2.0+
+
+from distutils.core import setup
+setup(name='dtoc',
+      version='1.0',
+      license='GPL-2.0+',
+      scripts=['dtoc'],
+      packages=['dtoc'],
+      package_dir={'dtoc': ''},
+      package_data={'dtoc': ['README']},
+      classifiers=['Environment :: Console',
+                   'Topic :: Software Development :: Embedded Systems'])
-- 
2.28.0.163.g6104cc2f0b6-goog

^ permalink raw reply related	[flat|nested] 9+ messages in thread

* [PATCH 4/4] binman: Add a setup script for Python
  2020-08-05 19:27 [PATCH 0/4] binman: Add support for Python installation Simon Glass
                   ` (2 preceding siblings ...)
  2020-08-05 19:27 ` [PATCH 3/4] dtoc: Add a setup script for Python Simon Glass
@ 2020-08-05 19:27 ` Simon Glass
  2020-08-22 23:17 ` Simon Glass
                   ` (3 subsequent siblings)
  7 siblings, 0 replies; 9+ messages in thread
From: Simon Glass @ 2020-08-05 19:27 UTC (permalink / raw)
  To: u-boot

Allow binman to be installed by adding a suitable setup.py script.

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

 tools/binman/setup.py | 12 ++++++++++++
 1 file changed, 12 insertions(+)
 create mode 100644 tools/binman/setup.py

diff --git a/tools/binman/setup.py b/tools/binman/setup.py
new file mode 100644
index 00000000000..fe408ed6911
--- /dev/null
+++ b/tools/binman/setup.py
@@ -0,0 +1,12 @@
+# SPDX-License-Identifier: GPL-2.0+
+
+from distutils.core import setup
+setup(name='binman',
+      version='1.0',
+      license='GPL-2.0+',
+      scripts=['binman'],
+      packages=['binman', 'binman.etype'],
+      package_dir={'binman': ''},
+      package_data={'binman': ['README', 'README.entries']},
+      classifiers=['Environment :: Console',
+                   'Topic :: Software Development :: Embedded Systems'])
-- 
2.28.0.163.g6104cc2f0b6-goog

^ permalink raw reply related	[flat|nested] 9+ messages in thread

* [PATCH 4/4] binman: Add a setup script for Python
  2020-08-05 19:27 [PATCH 0/4] binman: Add support for Python installation Simon Glass
                   ` (3 preceding siblings ...)
  2020-08-05 19:27 ` [PATCH 4/4] binman: " Simon Glass
@ 2020-08-22 23:17 ` Simon Glass
  2020-08-22 23:17 ` [PATCH 3/4] dtoc: " Simon Glass
                   ` (2 subsequent siblings)
  7 siblings, 0 replies; 9+ messages in thread
From: Simon Glass @ 2020-08-22 23:17 UTC (permalink / raw)
  To: u-boot

Allow binman to be installed by adding a suitable setup.py script.

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

 tools/binman/setup.py | 12 ++++++++++++
 1 file changed, 12 insertions(+)
 create mode 100644 tools/binman/setup.py

Applied to u-boot-dm, thanks!

^ permalink raw reply	[flat|nested] 9+ messages in thread

* [PATCH 3/4] dtoc: Add a setup script for Python
  2020-08-05 19:27 [PATCH 0/4] binman: Add support for Python installation Simon Glass
                   ` (4 preceding siblings ...)
  2020-08-22 23:17 ` Simon Glass
@ 2020-08-22 23:17 ` Simon Glass
  2020-08-22 23:17 ` [PATCH 2/4] binman: Correct some import statements Simon Glass
  2020-08-22 23:17 ` [PATCH 1/4] binman: Move GetEntryModules() to control Simon Glass
  7 siblings, 0 replies; 9+ messages in thread
From: Simon Glass @ 2020-08-22 23:17 UTC (permalink / raw)
  To: u-boot

Allow dtoc to be installed by adding a suitable setup.py script.

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

 tools/dtoc/setup.py | 12 ++++++++++++
 1 file changed, 12 insertions(+)
 create mode 100644 tools/dtoc/setup.py

Applied to u-boot-dm, thanks!

^ permalink raw reply	[flat|nested] 9+ messages in thread

* [PATCH 2/4] binman: Correct some import statements
  2020-08-05 19:27 [PATCH 0/4] binman: Add support for Python installation Simon Glass
                   ` (5 preceding siblings ...)
  2020-08-22 23:17 ` [PATCH 3/4] dtoc: " Simon Glass
@ 2020-08-22 23:17 ` Simon Glass
  2020-08-22 23:17 ` [PATCH 1/4] binman: Move GetEntryModules() to control Simon Glass
  7 siblings, 0 replies; 9+ messages in thread
From: Simon Glass @ 2020-08-22 23:17 UTC (permalink / raw)
  To: u-boot

Some of these were not converted when binman moved to use absolute paths.
Fix them.

Also drop the import of 'test' which is a directory, not a module.

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

 tools/binman/control.py    | 4 ++--
 tools/binman/ftest.py      | 2 +-
 tools/binman/image_test.py | 2 +-
 tools/binman/main.py       | 1 -
 4 files changed, 4 insertions(+), 5 deletions(-)

Applied to u-boot-dm, thanks!

^ permalink raw reply	[flat|nested] 9+ messages in thread

* [PATCH 1/4] binman: Move GetEntryModules() to control
  2020-08-05 19:27 [PATCH 0/4] binman: Add support for Python installation Simon Glass
                   ` (6 preceding siblings ...)
  2020-08-22 23:17 ` [PATCH 2/4] binman: Correct some import statements Simon Glass
@ 2020-08-22 23:17 ` Simon Glass
  7 siblings, 0 replies; 9+ messages in thread
From: Simon Glass @ 2020-08-22 23:17 UTC (permalink / raw)
  To: u-boot

When binman is installed its main program is in a different directory
to its modules. This means that __file__ is different and we cannot use
it to obtain the path to etype/ from main.py

To fix this, move the function to the 'control' module, since it is
installed with all the other modules, including the etype/ directory.

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

 tools/binman/control.py | 13 +++++++++++++
 tools/binman/ftest.py   |  5 ++---
 tools/binman/main.py    | 16 ++--------------
 3 files changed, 17 insertions(+), 17 deletions(-)

Applied to u-boot-dm, thanks!

^ permalink raw reply	[flat|nested] 9+ messages in thread

end of thread, other threads:[~2020-08-22 23:17 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-08-05 19:27 [PATCH 0/4] binman: Add support for Python installation Simon Glass
2020-08-05 19:27 ` [PATCH 1/4] binman: Move GetEntryModules() to control Simon Glass
2020-08-05 19:27 ` [PATCH 2/4] binman: Correct some import statements Simon Glass
2020-08-05 19:27 ` [PATCH 3/4] dtoc: Add a setup script for Python Simon Glass
2020-08-05 19:27 ` [PATCH 4/4] binman: " Simon Glass
2020-08-22 23:17 ` Simon Glass
2020-08-22 23:17 ` [PATCH 3/4] dtoc: " Simon Glass
2020-08-22 23:17 ` [PATCH 2/4] binman: Correct some import statements Simon Glass
2020-08-22 23:17 ` [PATCH 1/4] binman: Move GetEntryModules() to control Simon Glass

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.