mirror of
https://github.com/astral-sh/uv.git
synced 2025-08-31 15:57:26 +00:00
Convert to RequirementSource
rather than Requirement
(#9107)
## Summary This seems like a vestige left over from a refactor.
This commit is contained in:
parent
9339e55a11
commit
8c663d2a3f
2 changed files with 12 additions and 21 deletions
|
@ -1,8 +1,7 @@
|
|||
use std::collections::BTreeMap;
|
||||
use uv_distribution_filename::DistExtension;
|
||||
use uv_normalize::{ExtraName, GroupName, PackageName};
|
||||
use uv_pep508::MarkerTree;
|
||||
use uv_pypi_types::{HashDigest, Requirement, RequirementSource};
|
||||
use uv_pypi_types::{HashDigest, RequirementSource};
|
||||
|
||||
use crate::{BuiltDist, Diagnostic, Dist, Name, ResolvedDist, SourceDist};
|
||||
|
||||
|
@ -167,9 +166,9 @@ impl Diagnostic for ResolutionDiagnostic {
|
|||
}
|
||||
}
|
||||
|
||||
impl From<&ResolvedDist> for Requirement {
|
||||
impl From<&ResolvedDist> for RequirementSource {
|
||||
fn from(resolved_dist: &ResolvedDist) -> Self {
|
||||
let source = match resolved_dist {
|
||||
match resolved_dist {
|
||||
ResolvedDist::Installable { dist, .. } => match dist {
|
||||
Dist::Built(BuiltDist::Registry(wheels)) => RequirementSource::Registry {
|
||||
specifier: uv_pep440::VersionSpecifiers::from(
|
||||
|
@ -235,13 +234,6 @@ impl From<&ResolvedDist> for Requirement {
|
|||
),
|
||||
index: None,
|
||||
},
|
||||
};
|
||||
Requirement {
|
||||
name: resolved_dist.name().clone(),
|
||||
extras: vec![],
|
||||
marker: MarkerTree::TRUE,
|
||||
source,
|
||||
origin: None,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -13,7 +13,7 @@ use uv_distribution_types::{
|
|||
};
|
||||
use uv_fs::Simplified;
|
||||
use uv_platform_tags::Tags;
|
||||
use uv_pypi_types::Requirement;
|
||||
use uv_pypi_types::RequirementSource;
|
||||
use uv_python::PythonEnvironment;
|
||||
use uv_types::HashStrategy;
|
||||
|
||||
|
@ -76,29 +76,28 @@ impl<'a> Planner<'a> {
|
|||
let no_binary = build_options.no_binary_package(dist.name());
|
||||
let no_build = build_options.no_build_package(dist.name());
|
||||
|
||||
let requirement = Requirement::from(dist);
|
||||
|
||||
// Determine whether the distribution is already installed.
|
||||
let installed_dists = site_packages.remove_packages(&requirement.name);
|
||||
let installed_dists = site_packages.remove_packages(dist.name());
|
||||
if reinstall {
|
||||
reinstalls.extend(installed_dists);
|
||||
} else {
|
||||
match installed_dists.as_slice() {
|
||||
[] => {}
|
||||
[distribution] => {
|
||||
match RequirementSatisfaction::check(distribution, &requirement.source)? {
|
||||
[installed] => {
|
||||
let source = RequirementSource::from(dist);
|
||||
match RequirementSatisfaction::check(installed, &source)? {
|
||||
RequirementSatisfaction::Mismatch => {
|
||||
debug!("Requirement installed, but mismatched: {distribution:?}");
|
||||
debug!("Requirement installed, but mismatched: {installed:?}");
|
||||
}
|
||||
RequirementSatisfaction::Satisfied => {
|
||||
debug!("Requirement already installed: {distribution}");
|
||||
debug!("Requirement already installed: {installed}");
|
||||
continue;
|
||||
}
|
||||
RequirementSatisfaction::OutOfDate => {
|
||||
debug!("Requirement installed, but not fresh: {distribution}");
|
||||
debug!("Requirement installed, but not fresh: {installed}");
|
||||
}
|
||||
}
|
||||
reinstalls.push(distribution.clone());
|
||||
reinstalls.push(installed.clone());
|
||||
}
|
||||
// We reinstall installed distributions with multiple versions because
|
||||
// we do not want to keep multiple incompatible versions but removing
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue