Normalize python_version markers to python_full_version (#6126)

## Summary

Normalize all `python_version` markers to their equivalent
`python_full_version` form. This avoids false positives in forking
because we currently cannot detect any relationships between the two
forms. It also avoids subtle bugs due to the truncating semantics of
`python_version`. For example, given `requires-python = ">3.12"`, we
currently simplify the marker `python_version <= 3.12` to `false`.
However, the version `3.12.1` will be truncated to `3.12` for
`python_version` comparisons, and thus it satisfies the python
requirement and evaluates to `true`.

It is possible to simplify back to `python_version` when writing markers
to the lockfile. However, the equivalent `python_full_version` markers
are often clearer and easier to simplify, so I lean towards leaving them
as `python_full_version`.

There are *a lot* of snapshot updates from this change. I'd like more
eyes on the transformation logic in `python_version_to_full_version` to
ensure that they are all correct.

Resolves https://github.com/astral-sh/uv/issues/6125.
This commit is contained in:
Ibraheem Ahmed 2024-08-15 21:42:15 -04:00 committed by GitHub
parent 1311127991
commit e6ddce0246
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
22 changed files with 1021 additions and 844 deletions

View file

@ -97,7 +97,7 @@ impl RequiresPython {
// Convert back to PEP 440 specifiers.
let specifiers = range
.iter()
.flat_map(VersionSpecifier::from_bounds)
.flat_map(VersionSpecifier::from_release_only_bounds)
.collect();
Ok(Some(Self { specifiers, bound }))