Respect the user's upper-bound in requires-python (#6824)

## Summary

We now respect the user-provided upper-bound in for `requires-python`.
So, if the user has `requires-python = "==3.11.*"`, we won't explore
forks that have `python_version >= '3.12'`, for example.

However, we continue to _only_ compare the lower bounds when assessing
whether a dependency is compatible with a given Python range.

Closes https://github.com/astral-sh/uv/issues/6150.
This commit is contained in:
Charlie Marsh 2024-08-29 14:37:05 -04:00 committed by GitHub
parent a17c1e8e40
commit 34d74501ac
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
10 changed files with 308 additions and 77 deletions

View file

@ -1,7 +1,7 @@
use pep440_rs::{Version, VersionSpecifiers};
use uv_python::{Interpreter, PythonVersion};
use crate::{RequiresPython, RequiresPythonBound};
use crate::{RequiresPython, RequiresPythonRange};
#[derive(Debug, Clone, Eq, PartialEq)]
pub struct PythonRequirement {
@ -49,7 +49,7 @@ impl PythonRequirement {
/// Narrow the [`PythonRequirement`] to the given version, if it's stricter (i.e., greater)
/// than the current `Requires-Python` minimum.
pub fn narrow(&self, target: &RequiresPythonBound) -> Option<Self> {
pub fn narrow(&self, target: &RequiresPythonRange) -> Option<Self> {
let Some(PythonTarget::RequiresPython(requires_python)) = self.target.as_ref() else {
return None;
};