mirror of
https://github.com/astral-sh/uv.git
synced 2025-11-24 21:29:49 +00:00
Prune unreachable packages from lockfile (#6959)
In transformers, we have: * `tensorflow-text`: `tensorflow-macos; python_full_version >= '3.13' and platform_machine == 'arm64' and platform_system == 'Darwin'` * `tensorflow-macos`: `tensorflow-cpu-aws; (python_full_version < '3.10' and platform_machine == 'aarch64' and platform_system == 'Linux') or (python_full_version >= '3.13' and platform_machine == 'aarch64' and platform_system == 'Linux') or (python_full_version >= '3.13' and platform_machine == 'arm64' and platform_system == 'Linux')` * `tensorflow-macos`: `tensorflow-intel; python_full_version >= '3.13' and platform_system == 'Windows'` This means that `tensorflow-cpu-aws` and `tensorflow-intel` can never be installed, and we can drop them from the lockfile.
This commit is contained in:
parent
3d75df6ab2
commit
b9f2bd155a
3 changed files with 118 additions and 79 deletions
|
|
@ -11,6 +11,7 @@ use itertools::Itertools;
|
|||
use petgraph::visit::EdgeRef;
|
||||
use rustc_hash::{FxHashMap, FxHashSet};
|
||||
use toml_edit::{value, Array, ArrayOfTables, InlineTable, Item, Table, Value};
|
||||
use tracing::debug;
|
||||
use url::Url;
|
||||
|
||||
use cache_key::RepositoryUrl;
|
||||
|
|
@ -94,6 +95,10 @@ impl Lock {
|
|||
if !dist.is_base() {
|
||||
continue;
|
||||
}
|
||||
if graph.reachability[&node_index].is_false() {
|
||||
debug!("Removing unreachable package: `{}`", dist.package_id());
|
||||
continue;
|
||||
}
|
||||
let fork_markers = graph
|
||||
.fork_markers(dist.name(), &dist.version, dist.dist.version_or_url().url())
|
||||
.cloned()
|
||||
|
|
@ -108,6 +113,10 @@ impl Lock {
|
|||
else {
|
||||
continue;
|
||||
};
|
||||
// Prune edges leading to unreachable nodes.
|
||||
if graph.reachability[&edge.target()].is_false() {
|
||||
continue;
|
||||
}
|
||||
let marker = edge.weight().clone();
|
||||
package.add_dependency(&requires_python, dependency_dist, marker, root)?;
|
||||
}
|
||||
|
|
@ -126,6 +135,9 @@ impl Lock {
|
|||
let ResolutionGraphNode::Dist(dist) = &graph.petgraph[node_index] else {
|
||||
continue;
|
||||
};
|
||||
if graph.reachability[&node_index].is_false() {
|
||||
continue;
|
||||
}
|
||||
if let Some(extra) = dist.extra.as_ref() {
|
||||
let id = PackageId::from_annotated_dist(dist, root)?;
|
||||
let Some(package) = packages.get_mut(&id) else {
|
||||
|
|
@ -140,6 +152,10 @@ impl Lock {
|
|||
else {
|
||||
continue;
|
||||
};
|
||||
// Prune edges leading to unreachable nodes.
|
||||
if graph.reachability[&edge.target()].is_false() {
|
||||
continue;
|
||||
}
|
||||
let marker = edge.weight().clone();
|
||||
package.add_optional_dependency(
|
||||
&requires_python,
|
||||
|
|
@ -164,6 +180,10 @@ impl Lock {
|
|||
else {
|
||||
continue;
|
||||
};
|
||||
// Prune edges leading to unreachable nodes.
|
||||
if graph.reachability[&edge.target()].is_false() {
|
||||
continue;
|
||||
}
|
||||
let marker = edge.weight().clone();
|
||||
package.add_dev_dependency(
|
||||
&requires_python,
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue