mirror of
https://github.com/ansible-collections/community.general.git
synced 2026-03-23 13:50:30 +00:00
uv_python module: update latest state handling to sort versions without relying on uv behavior
This commit is contained in:
parent
473f758ec1
commit
d37009ae7b
1 changed files with 5 additions and 4 deletions
|
|
@ -103,7 +103,7 @@ class UV:
|
|||
detected_version = out.split()[0]
|
||||
latest_version = self._get_latest_patch_release()
|
||||
if rc == 0 and detected_version == latest_version:
|
||||
return False, out
|
||||
return False, latest_version
|
||||
if self.module.check_mode:
|
||||
return True, latest_version
|
||||
|
||||
|
|
@ -124,9 +124,10 @@ class UV:
|
|||
return rc, out, err
|
||||
|
||||
def _get_latest_patch_release(self):
|
||||
_, out, _ = self._list_python()
|
||||
result = json.loads(out)
|
||||
return result[0]["version"] # uv orders versions in descending order
|
||||
_, out, _ = self._list_python() # uv returns versions in descending order but we sort them just in case future uv behavior changes
|
||||
results = json.loads(out)
|
||||
versions = [StrictVersion(result["version"]) for result in results]
|
||||
return max(versions).__str__()
|
||||
|
||||
|
||||
def main():
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue