Make > operator exclude post and local releases (#2471)

## Summary

This PR attempts to use a similar trick to that we added in
https://github.com/astral-sh/uv/pull/1878, but for post-releases.

In https://github.com/astral-sh/uv/pull/1878, we added a fake "minimum"
version to enable us to treat `< 1.0.0` as _excluding_ pre-releases of
1.0.0.

Today, on `main`, we accept post-releases and local versions in `>
1.0.0`. But per PEP 440, that should _exclude_ post-releases and local
versions, unless the specifier is itself a pre-release, in which case,
pre-releases are allowed (e.g., `> 1.0.0.post0` should allow `>
1.0.0.post1`).

To support this, we add a fake "maximum" version that's greater than all
the post and local releases for a given version. This leverages our last
remaining free bit in the compact representation.
This commit is contained in:
Charlie Marsh 2024-03-15 07:02:06 -07:00 committed by GitHub
parent c296da34bf
commit e69b76bc72
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
6 changed files with 222 additions and 110 deletions

View file

@ -537,7 +537,7 @@ impl CacheBucket {
Self::FlatIndex => "flat-index-v0",
Self::Git => "git-v0",
Self::Interpreter => "interpreter-v0",
Self::Simple => "simple-v3",
Self::Simple => "simple-v4",
Self::Wheels => "wheels-v0",
Self::Archive => "archive-v0",
}