mirror of
https://github.com/astral-sh/uv.git
synced 2025-07-07 21:35:00 +00:00
Remove unused methods from Resolution
(#3754)
This commit is contained in:
parent
0a87391d5d
commit
fe28b2c278
7 changed files with 11 additions and 24 deletions
1
Cargo.lock
generated
1
Cargo.lock
generated
|
@ -1111,7 +1111,6 @@ dependencies = [
|
|||
"platform-tags",
|
||||
"pypi-types",
|
||||
"rkyv",
|
||||
"rustc-hash",
|
||||
"schemars",
|
||||
"serde",
|
||||
"serde_json",
|
||||
|
|
|
@ -30,7 +30,6 @@ indexmap = { workspace = true }
|
|||
itertools = { workspace = true }
|
||||
once_cell = { workspace = true }
|
||||
rkyv = { workspace = true }
|
||||
rustc-hash = { workspace = true }
|
||||
schemars = { workspace = true, optional = true }
|
||||
serde = { workspace = true, features = ["derive"] }
|
||||
serde_json = { workspace = true }
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
use rustc_hash::FxHashMap;
|
||||
use std::collections::BTreeMap;
|
||||
|
||||
use pep508_rs::VerbatimUrl;
|
||||
use uv_normalize::PackageName;
|
||||
|
@ -10,19 +10,14 @@ use crate::{
|
|||
|
||||
/// A set of packages pinned at specific versions.
|
||||
#[derive(Debug, Default, Clone)]
|
||||
pub struct Resolution(FxHashMap<PackageName, ResolvedDist>);
|
||||
pub struct Resolution(BTreeMap<PackageName, ResolvedDist>);
|
||||
|
||||
impl Resolution {
|
||||
/// Create a new resolution from the given pinned packages.
|
||||
pub fn new(packages: FxHashMap<PackageName, ResolvedDist>) -> Self {
|
||||
pub fn new(packages: BTreeMap<PackageName, ResolvedDist>) -> Self {
|
||||
Self(packages)
|
||||
}
|
||||
|
||||
/// Return the distribution for the given package name, if it exists.
|
||||
pub fn get(&self, package_name: &PackageName) -> Option<&ResolvedDist> {
|
||||
self.0.get(package_name)
|
||||
}
|
||||
|
||||
/// Return the remote distribution for the given package name, if it exists.
|
||||
pub fn get_remote(&self, package_name: &PackageName) -> Option<&Dist> {
|
||||
match self.0.get(package_name) {
|
||||
|
@ -44,11 +39,6 @@ impl Resolution {
|
|||
self.0.values()
|
||||
}
|
||||
|
||||
/// Iterate over the [`ResolvedDist`] entities in this resolution.
|
||||
pub fn into_distributions(self) -> impl Iterator<Item = ResolvedDist> {
|
||||
self.0.into_values()
|
||||
}
|
||||
|
||||
/// Return the number of distributions in this resolution.
|
||||
pub fn len(&self) -> usize {
|
||||
self.0.len()
|
||||
|
@ -60,10 +50,8 @@ impl Resolution {
|
|||
}
|
||||
|
||||
/// Return the set of [`Requirement`]s that this resolution represents.
|
||||
pub fn requirements(&self) -> Vec<Requirement> {
|
||||
let mut requirements: Vec<_> = self.0.values().map(Requirement::from).collect();
|
||||
requirements.sort_unstable_by(|a, b| a.name.cmp(&b.name));
|
||||
requirements
|
||||
pub fn requirements(&self) -> impl Iterator<Item = Requirement> + '_ {
|
||||
self.0.values().map(Requirement::from)
|
||||
}
|
||||
|
||||
/// Return an iterator over the [`LocalEditable`] entities in this resolution.
|
||||
|
|
|
@ -192,12 +192,14 @@ impl<'a> BuildContext for BuildDispatch<'a> {
|
|||
// Determine the set of installed packages.
|
||||
let site_packages = SitePackages::from_executable(venv)?;
|
||||
|
||||
let requirements = resolution.requirements().collect::<Vec<_>>();
|
||||
|
||||
let Plan {
|
||||
cached,
|
||||
remote,
|
||||
reinstalls,
|
||||
extraneous: _,
|
||||
} = Planner::with_requirements(&resolution.requirements()).build(
|
||||
} = Planner::with_requirements(&requirements).build(
|
||||
site_packages,
|
||||
&Reinstall::None,
|
||||
&NoBinary::None,
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
// as we build out universal locking.
|
||||
#![allow(dead_code, unreachable_code, unused_variables)]
|
||||
|
||||
use std::collections::VecDeque;
|
||||
use std::collections::{BTreeMap, VecDeque};
|
||||
use std::path::{Path, PathBuf};
|
||||
use std::str::FromStr;
|
||||
|
||||
|
@ -71,7 +71,7 @@ impl Lock {
|
|||
let mut queue: VecDeque<&Distribution> = VecDeque::new();
|
||||
queue.push_back(root);
|
||||
|
||||
let mut map = FxHashMap::default();
|
||||
let mut map = BTreeMap::default();
|
||||
while let Some(dist) = queue.pop_front() {
|
||||
for dep in &dist.dependencies {
|
||||
let dep_dist = self.find_by_id(&dep.id);
|
||||
|
|
|
@ -296,7 +296,6 @@ pub(crate) async fn install(
|
|||
// despite not being explicitly requested.
|
||||
let requirements = resolution
|
||||
.requirements()
|
||||
.into_iter()
|
||||
.filter(|requirement| {
|
||||
if requirement.source.is_editable() {
|
||||
!editables
|
||||
|
|
|
@ -285,7 +285,7 @@ pub(crate) async fn install(
|
|||
) -> Result<(), Error> {
|
||||
let start = std::time::Instant::now();
|
||||
|
||||
let requirements = resolution.requirements();
|
||||
let requirements = resolution.requirements().collect::<Vec<_>>();
|
||||
|
||||
// Partition into those that should be linked from the cache (`local`), those that need to be
|
||||
// downloaded (`remote`), and those that should be removed (`extraneous`).
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue