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. /// for a given package.
#[derive(Debug, Default, Clone)] #[derive(Debug, Default, Clone)]
pub struct Resolution { pub struct Resolution {
graph: petgraph::graph::DiGraph<Node, Edge>, pub graph: petgraph::graph::DiGraph<Node, Edge>,
diagnostics: Vec<ResolutionDiagnostic>, diagnostics: Vec<ResolutionDiagnostic>,
} }

View file

@ -6,6 +6,9 @@ use std::sync::Arc;
use anyhow::{Context, Result}; use anyhow::{Context, Result};
use itertools::Itertools; use itertools::Itertools;
use owo_colors::OwoColorize; use owo_colors::OwoColorize;
use petgraph::visit::EdgeRef;
use petgraph::Direction;
use tracing::trace;
use uv_auth::UrlAuthPolicies; use uv_auth::UrlAuthPolicies;
use uv_cache::Cache; use uv_cache::Cache;
@ -16,7 +19,7 @@ use uv_configuration::{
}; };
use uv_dispatch::BuildDispatch; use uv_dispatch::BuildDispatch;
use uv_distribution_types::{ 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_fs::Simplified;
use uv_installer::SitePackages; use uv_installer::SitePackages;
@ -767,22 +770,59 @@ pub(super) async fn do_sync(
} }
/// Filter out any virtual workspace members. /// Filter out any virtual workspace members.
fn apply_no_virtual_project(resolution: Resolution) -> Resolution { fn apply_no_virtual_project(mut resolution: Resolution) -> Resolution {
resolution.filter(|dist| { 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 { let ResolvedDist::Installable { dist, .. } = dist else {
return true; continue;
}; };
let Dist::Source(dist) = dist.as_ref() else { let Dist::Source(dist) = dist.as_ref() else {
return true; continue;
}; };
let SourceDist::Directory(dist) = dist else { 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. /// 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. // 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 success: true
exit_code: 0 exit_code: 0
----- stdout ----- ----- stdout -----
----- stderr ----- ----- stderr -----
Prepared 4 packages in [TIME] Prepared 5 packages in [TIME]
Installed 4 packages in [TIME] Installed 5 packages in [TIME]
+ anyio==4.3.0 + anyio==4.3.0
+ child==0.1.0 (from file://[TEMP_DIR]/child)
+ idna==3.6 + idna==3.6
+ iniconfig==2.0.0 + iniconfig==2.0.0
+ sniffio==1.3.1 + sniffio==1.3.1
"###); ");
Ok(()) Ok(())
} }

View file

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