add an 'annotations' helper script
authorAndrea Righi <andrea.righi@canonical.com>
Mon, 4 Dec 2023 11:05:17 +0000 (12:05 +0100)
committerAndrea Righi <andrea.righi@canonical.com>
Mon, 11 Dec 2023 10:00:49 +0000 (11:00 +0100)
Add a simple 'annotations' script that allows to run the main
"annotations binary" from source without installing anything in the
system.

Signed-off-by: Andrea Righi <andrea.righi@canonical.com>
annotations [new file with mode: 0755]

diff --git a/annotations b/annotations
new file mode 100755 (executable)
index 0000000..bddfe40
--- /dev/null
@@ -0,0 +1,22 @@
+#!/usr/bin/env python3
+# -*- mode: python -*-
+
+# This file is not installed; it's just to run annotations from inside a source
+# distribution without installing it in the system.
+
+import os
+import sys
+from kconfig import run
+
+
+# Update PATH to make sure that annotations can be executed directly from the
+# source directory.
+def update_path():
+    script_dir = os.path.dirname(os.path.abspath(__file__))
+    current_path = os.environ.get("PATH", "")
+    new_path = f"{script_dir}:{current_path}"
+    os.environ["PATH"] = new_path
+
+
+update_path()
+exit(run.main())