1
0
Fork 0
mirror of https://github.com/ansible-collections/community.general.git synced 2026-03-22 21:29:19 +00:00

uv_python module: fail module if used uv version is less than the minimal supported version

This commit is contained in:
Mariam Ahhttouche 2026-02-22 10:32:21 +01:00
parent 67d363a2ce
commit 5f0118e792

View file

@ -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.