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:
parent
67d363a2ce
commit
5f0118e792
1 changed files with 13 additions and 0 deletions
|
|
@ -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.
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue