Skip to contentSkip to conversation

buildman: Fix full help for Python 3.8

PATCH In review Simon Glass 1 participant 2 messages Sep 4, 2023 – Sep 23, 2023

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 buildman: Fix full help for Python 3.8

With Python versions older than 3.9 Buildman produces an error on start-up. Fix this with a workaround for importlib.

There is already a workaround for v3.6 but I am not sure if that is still functioning.

---

 tools/buildman/main.py | 10 ++++++++--
 1 file changed, 8 insertions(+), 2 deletions(-)
tools/buildman/main.py +8 -2
index 5f42a58ddbb3..3cf877e5e688 100755
@@ -7,7 +7,7 @@
 """See README for more information"""
 
 try:
-    from importlib.resources import files
+    import importlib.resources
 except ImportError:
     # for Python 3.6
     import importlib_resources
@@ -83,7 +83,13 @@ def run_buildman():
         run_test_coverage()
 
     elif args.full_help:
-        tools.print_full_help(str(files('buildman').joinpath('README.rst')))
+        if hasattr(importlib.resources, 'files'):
+            dirpath = importlib.resources.files('buildman')
+            tools.print_full_help(str(dirpath.joinpath('README.rst')))
+        else:
+            with importlib.resources.path('buildman', 'README.rst') as readme:
+                tools.print_full_help(str(readme))
+
 
     # Build selected commits for selected boards
     else:
Signature · 1 line
2.42.0.283.g2d96d420d3-goog
#1 lore raw

With Python versions older than 3.9 Buildman produces an error on start-up. Fix this with a workaround for importlib.

There is already a workaround for v3.6 but I am not sure if that is still functioning.

---

 tools/buildman/main.py | 10 ++++++++--
 1 file changed, 8 insertions(+), 2 deletions(-)

Applied to u-boot-dm, thanks!