From 5f0118e7925ea0e6f11b83b3109c07ff03db103f Mon Sep 17 00:00:00 2001 From: Mariam Ahhttouche Date: Sun, 22 Feb 2026 10:32:21 +0100 Subject: [PATCH] uv_python module: fail module if used uv version is less than the minimal supported version --- plugins/modules/uv_python.py | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/plugins/modules/uv_python.py b/plugins/modules/uv_python.py index 7792d364af..4c6a12c2c3 100644 --- a/plugins/modules/uv_python.py +++ b/plugins/modules/uv_python.py @@ -63,6 +63,7 @@ class UV: def __init__(self, module): self.module = module + self._ensure_min_uv_version() python_version = module.params["version"] try: self.python_version = LooseVersion(python_version) @@ -73,6 +74,18 @@ class UV: ) + def _ensure_min_uv_version(self): + cmd = [self.module.get_bin_path("uv", required=True), "--version"] + _, out, _ = self.module.run_command(cmd, check_rc=True) + detected = out.strip().split()[-1] + if LooseVersion(detected) < LooseVersion(MINIMUM_UV_VERSION): + self.module.fail_json( + msg=f"uv_python module requires uv >= {MINIMUM_UV_VERSION}", + detected_version=detected, + required_version=MINIMUM_UV_VERSION, + ) + + def install_python(self): """ Runs command 'uv python install X.Y.Z' which installs specified python version.