mirror of
https://github.com/astral-sh/uv.git
synced 2025-09-11 04:56:24 +00:00
Refactor incompatiblity tracking for distributions (#1298)
Extends the "compatibility" types introduced in #1293 to apply to source distributions as well as wheels. - We now track the most-relevant incompatible source distribution - Exclude newer, Python requirements, and yanked versions are all tracked as incompatibilities in the new model (this lets us remove `DistMetadata`!)
This commit is contained in:
parent
1181aa9be4
commit
10c4effbd3
16 changed files with 498 additions and 343 deletions
|
@ -1,5 +1,4 @@
|
|||
use distribution_types::{CompatibleDist, Dist};
|
||||
use pep440_rs::{Version, VersionSpecifiers};
|
||||
use pep440_rs::Version;
|
||||
use pep508_rs::MarkerEnvironment;
|
||||
use uv_interpreter::Interpreter;
|
||||
|
||||
|
@ -30,42 +29,4 @@ impl PythonRequirement {
|
|||
pub fn target(&self) -> &Version {
|
||||
&self.target
|
||||
}
|
||||
|
||||
/// If the dist doesn't match the given Python requirement, return the version specifiers.
|
||||
pub(crate) fn validate_dist<'a>(
|
||||
&self,
|
||||
dist: &'a CompatibleDist,
|
||||
) -> Option<&'a VersionSpecifiers> {
|
||||
// Validate the _installed_ file.
|
||||
let requires_python = dist.for_installation().requires_python.as_ref()?;
|
||||
|
||||
// If the dist doesn't support the target Python version, return the failing version
|
||||
// specifiers.
|
||||
if !requires_python.contains(self.target()) {
|
||||
return Some(requires_python);
|
||||
}
|
||||
|
||||
// If the dist is a source distribution, and doesn't support the installed Python
|
||||
// version, return the failing version specifiers, since we won't be able to build it.
|
||||
if matches!(dist.for_installation().dist, Dist::Source(_))
|
||||
&& !requires_python.contains(self.installed())
|
||||
{
|
||||
return Some(requires_python);
|
||||
}
|
||||
|
||||
// Validate the resolved file.
|
||||
let requires_python = dist.for_resolution().requires_python.as_ref()?;
|
||||
|
||||
// If the dist is a source distribution, and doesn't support the installed Python
|
||||
// version, return the failing version specifiers, since we won't be able to build it.
|
||||
// This isn't strictly necessary, since if `dist.resolve_metadata()` is a source distribution, it
|
||||
// should be the same file as `dist.install_metadata()` (validated above).
|
||||
if matches!(dist.for_resolution().dist, Dist::Source(_))
|
||||
&& !requires_python.contains(self.installed())
|
||||
{
|
||||
return Some(requires_python);
|
||||
}
|
||||
|
||||
None
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue