Downgrade cache state log message

This commit is contained in:
konstin 2025-04-15 19:19:39 +02:00
parent 5941e4d9c2
commit 5398542be7
4 changed files with 74 additions and 29 deletions

View file

@ -14,7 +14,7 @@ use crate::{
/// for a given package.
#[derive(Debug, Default, Clone)]
pub struct Resolution {
graph: petgraph::graph::DiGraph<Node, Edge>,
pub graph: petgraph::graph::DiGraph<Node, Edge>,
diagnostics: Vec<ResolutionDiagnostic>,
}

View file

@ -6,6 +6,9 @@ use std::sync::Arc;
use anyhow::{Context, Result};
use itertools::Itertools;
use owo_colors::OwoColorize;
use petgraph::visit::EdgeRef;
use petgraph::Direction;
use tracing::trace;
use uv_auth::UrlAuthPolicies;
use uv_cache::Cache;
@ -16,7 +19,7 @@ use uv_configuration::{
};
use uv_dispatch::BuildDispatch;
use uv_distribution_types::{
DirectorySourceDist, Dist, Index, Requirement, Resolution, ResolvedDist, SourceDist,
DirectorySourceDist, Dist, Index, Name, Node, Requirement, Resolution, ResolvedDist, SourceDist,
};
use uv_fs::Simplified;
use uv_installer::SitePackages;
@ -767,22 +770,59 @@ pub(super) async fn do_sync(
}
/// Filter out any virtual workspace members.
fn apply_no_virtual_project(resolution: Resolution) -> Resolution {
resolution.filter(|dist| {
fn apply_no_virtual_project(mut resolution: Resolution) -> Resolution {
for node in resolution.graph.node_indices() {
if let Some(first) = resolution
.graph
.edges_directed(node, Direction::Incoming)
.filter(|edge| match &resolution.graph[edge.source()] {
Node::Root => false,
Node::Dist { dist: source, .. } => match &resolution.graph[node] {
// Root does not have incoming edges
Node::Root => {
if cfg!(debug_assertions) {
unreachable!()
} else {
false
}
}
// Ignore recursive self-inclusions that are used for dependency groups and
// extras that include other extras.
Node::Dist { dist: target, .. } => source.name() != target.name(),
},
})
.next()
{
tracing::debug!("Has incoming: {:?} {:?}", resolution.graph[node], first);
continue;
}
let Node::Dist { dist, install, .. } = &mut resolution.graph[node] else {
continue;
};
let ResolvedDist::Installable { dist, .. } = dist else {
return true;
continue;
};
let Dist::Source(dist) = dist.as_ref() else {
return true;
continue;
};
let SourceDist::Directory(dist) = dist else {
return true;
continue;
};
!dist.r#virtual
})
if dist.r#virtual {
trace!(
"Virtual package {} is not a dependency of any other package, not building",
dist.name()
);
*install = false;
}
}
resolution
}
/// If necessary, convert any editable requirements to non-editable.

View file

@ -17169,19 +17169,20 @@ fn lock_implicit_virtual_path() -> Result<()> {
"###);
// Install from the lockfile. The virtual project should _not_ be installed.
uv_snapshot!(context.filters(), context.sync().arg("--frozen"), @r###"
uv_snapshot!(context.filters(), context.sync().arg("--frozen"), @r"
success: true
exit_code: 0
----- stdout -----
----- stderr -----
Prepared 4 packages in [TIME]
Installed 4 packages in [TIME]
Prepared 5 packages in [TIME]
Installed 5 packages in [TIME]
+ anyio==4.3.0
+ child==0.1.0 (from file://[TEMP_DIR]/child)
+ idna==3.6
+ iniconfig==2.0.0
+ sniffio==1.3.1
"###);
");
Ok(())
}

View file

@ -1094,18 +1094,19 @@ fn extra_unconditional() -> Result<()> {
"###);
// This is fine because we are only enabling one
// extra, and thus, there is no conflict.
uv_snapshot!(context.filters(), context.sync().arg("--frozen"), @r###"
uv_snapshot!(context.filters(), context.sync().arg("--frozen"), @r"
success: true
exit_code: 0
----- stdout -----
----- stderr -----
Prepared 3 packages in [TIME]
Installed 3 packages in [TIME]
Prepared 4 packages in [TIME]
Installed 4 packages in [TIME]
+ anyio==4.1.0
+ idna==3.6
+ proxy1==0.1.0 (from file://[TEMP_DIR]/proxy1)
+ sniffio==1.3.1
"###);
");
// And same thing for the other extra.
root_pyproject_toml.write_str(
@ -1215,18 +1216,19 @@ fn extra_unconditional_non_conflicting() -> Result<()> {
// `uv sync` wasn't correctly propagating extras in a way
// that would satisfy the conflict markers that got added
// to the `proxy1[extra1]` dependency.
uv_snapshot!(context.filters(), context.sync().arg("--frozen"), @r###"
uv_snapshot!(context.filters(), context.sync().arg("--frozen"), @r"
success: true
exit_code: 0
----- stdout -----
----- stderr -----
Prepared 3 packages in [TIME]
Installed 3 packages in [TIME]
Prepared 4 packages in [TIME]
Installed 4 packages in [TIME]
+ anyio==4.1.0
+ idna==3.6
+ proxy1==0.1.0 (from file://[TEMP_DIR]/proxy1)
+ sniffio==1.3.1
"###);
");
Ok(())
}
@ -1301,16 +1303,17 @@ fn extra_unconditional_in_optional() -> Result<()> {
"###);
// This should install `sortedcontainers==2.3.0`.
uv_snapshot!(context.filters(), context.sync().arg("--frozen").arg("--extra=x1"), @r###"
uv_snapshot!(context.filters(), context.sync().arg("--frozen").arg("--extra=x1"), @r"
success: true
exit_code: 0
----- stdout -----
----- stderr -----
Prepared 1 package in [TIME]
Installed 1 package in [TIME]
Prepared 2 packages in [TIME]
Installed 2 packages in [TIME]
+ proxy1==0.1.0 (from file://[TEMP_DIR]/proxy1)
+ sortedcontainers==2.3.0
"###);
");
// This should install `sortedcontainers==2.4.0`.
uv_snapshot!(context.filters(), context.sync().arg("--frozen").arg("--extra=x2"), @r###"
@ -4460,19 +4463,20 @@ conflicts = [
error: Extra `x2` is not defined in the project's `optional-dependencies` table
"###);
uv_snapshot!(context.filters(), context.sync(), @r###"
uv_snapshot!(context.filters(), context.sync(), @r"
success: true
exit_code: 0
----- stdout -----
----- stderr -----
Resolved 7 packages in [TIME]
Prepared 3 packages in [TIME]
Installed 3 packages in [TIME]
Prepared 4 packages in [TIME]
Installed 4 packages in [TIME]
+ anyio==4.3.0
+ idna==3.6
+ proxy1==0.1.0 (from file://[TEMP_DIR]/proxy1)
+ sniffio==1.3.1
"###);
");
let lock = fs_err::read_to_string(context.temp_dir.join("uv.lock")).unwrap();
insta::with_settings!({