diff mbox series

[bug#60134,3/3] patman: locate README.rst via importlib

Message ID 20221217014530.27772-3-maxim.cournoyer@savoirfairelinux.com
State New
Headers show
Series [bug#60132,1/3] patman: remove extraneous imports | expand

Commit Message

Maxim Cournoyer Dec. 17, 2022, 1:45 a.m. UTC
Rationale: this is more robust than assumptions about the file
hierarchy layout of the installation of patman, for example on non
file-hierarchy standard (FHS) systems such as Guix System or Nix OS.

Signed-off-by: Maxim Cournoyer <maxim.cournoyer@savoirfairelinux.com>
---

 tools/patman/main.py | 8 +++-----
 1 file changed, 3 insertions(+), 5 deletions(-)

Comments

Simon Glass Dec. 17, 2022, 10:24 p.m. UTC | #1
On Fri, 16 Dec 2022 at 18:45, Maxim Cournoyer <maxim.cournoyer@gmail.com> wrote:
>
> Rationale: this is more robust than assumptions about the file
> hierarchy layout of the installation of patman, for example on non
> file-hierarchy standard (FHS) systems such as Guix System or Nix OS.
>
> Signed-off-by: Maxim Cournoyer <maxim.cournoyer@savoirfairelinux.com>
> ---
>
>  tools/patman/main.py | 8 +++-----
>  1 file changed, 3 insertions(+), 5 deletions(-)
>

Reviewed-by: Simon Glass <sjg@chromium.org>
Simon Glass Dec. 21, 2022, 12:28 a.m. UTC | #2
On Fri, 16 Dec 2022 at 18:45, Maxim Cournoyer <maxim.cournoyer@gmail.com> wrote:
>
> Rationale: this is more robust than assumptions about the file
> hierarchy layout of the installation of patman, for example on non
> file-hierarchy standard (FHS) systems such as Guix System or Nix OS.
>
> Signed-off-by: Maxim Cournoyer <maxim.cournoyer@savoirfairelinux.com>
> ---
>
>  tools/patman/main.py | 8 +++-----
>  1 file changed, 3 insertions(+), 5 deletions(-)
>

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

Applied to u-boot-dm/next, thanks!
diff mbox series

Patch

diff --git a/tools/patman/main.py b/tools/patman/main.py
index 8067a288ab..2a2a7eaa24 100755
--- a/tools/patman/main.py
+++ b/tools/patman/main.py
@@ -7,6 +7,7 @@ 
 """See README for more information"""
 
 from argparse import ArgumentParser
+import importlib.resources
 import os
 import re
 import sys
@@ -160,11 +161,8 @@  elif args.cmd == 'send':
         fd.close()
 
     elif 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('patman', 'README.rst') as readme:
+            tools.print_full_help(str(readme))
     else:
         # If we are not processing tags, no need to warning about bad ones
         if not args.process_tags: