[sdk/kde-builder] kde_builder: feat: Support showing version from uv

Andrew Shark <[email protected]>
Newsgroups gmane.comp.kde.cvs
Message-ID <[email protected]>
Git commit f56782160ca40a96104b823c1317ee33f0cd7ead by Andrew Shark.
Committed on 08/08/2026 at 22:54.
Pushed by ashark into branch 'master'.

feat: Support showing version from uv

M  +13   -8    kde_builder/version.py

https://invent.kde.org/sdk/kde-builder/-/commit/f56782160ca40a96104b823c1317ee33f0cd7ead

diff --git a/kde_builder/version.py b/kde_builder/version.py
index e8141537..15d568ef 100644
--- a/kde_builder/version.py
+++ b/kde_builder/version.py
@@ -3,6 +3,7 @@
 #
 # SPDX-License-Identifier: GPL-2.0-or-later
 
+from importlib.metadata import version, PackageNotFoundError
 import os
 import subprocess
 from typing import NoReturn
@@ -28,14 +29,18 @@ class Version:
         current checkout and append the ID (in ``git-describe`` format) to the output
         string as well.
         """
-        can_run_git = subprocess.call("type " + "git", shell=True, stdout=subprocess.PIPE, stderr=subprocess.PIPE) == 0
-        if KB_REPO_DIR and can_run_git and os.path.isdir(f"{KB_REPO_DIR}/.git"):
-            result = subprocess.run(['printf "r%s.%s" "$(git rev-list --count HEAD)" "$(git rev-parse --short=7 HEAD)"'], shell=True, capture_output=True, check=False, cwd=KB_REPO_DIR)
-            output = result.stdout.decode("utf-8").removesuffix("\n")
-            ok = result.returncode == 0
-            if ok and output:
-                return f"{output}"
-        return "Unknown version"
+        try:
+            current_version = version("kde-builder")
+            return current_version
+        except PackageNotFoundError:
+            can_run_git = subprocess.call("type " + "git", shell=True, stdout=subprocess.PIPE, stderr=subprocess.PIPE) == 0
+            if KB_REPO_DIR and can_run_git and os.path.isdir(f"{KB_REPO_DIR}/.git"):
+                result = subprocess.run(['printf "r%s.%s" "$(git rev-list --count HEAD)" "$(git rev-parse --short=7 HEAD)"'], shell=True, capture_output=True, check=False, cwd=KB_REPO_DIR)
+                output = result.stdout.decode("utf-8").removesuffix("\n")
+                ok = result.returncode == 0
+                if ok and output:
+                    return f"{output}"
+            return "Unknown version"
 
     @staticmethod
     def self_update() -> NoReturn:
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.