[PATCH v2 20/24] binman: Use importlib to find the help

Simon Glass sjg at chromium.org
Fri Feb 24 02:18:20 CET 2023


Use this function so that the help can be found even when binman is
running from a package.

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

Changes in v2:
- Add new patch to use importlib to find the help

 tools/binman/control.py | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/tools/binman/control.py b/tools/binman/control.py
index 3e27b72f881..e7f81b9deb5 100644
--- a/tools/binman/control.py
+++ b/tools/binman/control.py
@@ -7,6 +7,7 @@
 
 from collections import OrderedDict
 import glob
+import importlib.resources
 import os
 import pkg_resources
 import re
@@ -641,9 +642,8 @@ def Binman(args):
     global state
 
     if args.full_help:
-        tools.print_full_help(
-            os.path.join(os.path.dirname(os.path.realpath(sys.argv[0])), 'README.rst')
-        )
+        with importlib.resources.path('binman', 'README.rst') as readme:
+            tools.print_full_help(str(readme))
         return 0
 
     # Put these here so that we can import this module without libfdt
-- 
2.39.2.637.g21b0678d19-goog



More information about the U-Boot mailing list