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.