Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix bug in terms when collapsing unavailable versions in resolver errors #9877

Merged
merged 1 commit into from
Dec 13, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 14 additions & 4 deletions crates/uv-resolver/src/error.rs
Original file line number Diff line number Diff line change
Expand Up @@ -673,13 +673,18 @@ fn collapse_unavailable_versions(
// And the package and reason are the same...
if package == other_package && reason == other_reason {
// Collapse both into a new node, with a union of their ranges
let versions = other_versions.union(versions);
let mut terms = terms.clone();
if let Some(Term::Positive(range)) = terms.get_mut(package) {
*range = versions.clone();
}
*tree = DerivationTree::Derived(Derived {
terms: terms.clone(),
terms,
shared_id: *shared_id,
cause1: cause1.clone(),
cause2: Arc::new(DerivationTree::External(External::Custom(
package.clone(),
versions.union(other_versions),
versions,
reason.clone(),
))),
});
Expand All @@ -696,12 +701,17 @@ fn collapse_unavailable_versions(
// And the package and reason are the same...
if package == other_package && reason == other_reason {
// Collapse both into a new node, with a union of their ranges
let versions = other_versions.union(versions);
let mut terms = terms.clone();
if let Some(Term::Positive(range)) = terms.get_mut(package) {
*range = versions.clone();
}
*tree = DerivationTree::Derived(Derived {
terms: terms.clone(),
terms,
shared_id: *shared_id,
cause1: Arc::new(DerivationTree::External(External::Custom(
package.clone(),
versions.union(other_versions),
versions,
reason.clone(),
))),
cause2: cause2.clone(),
Expand Down
5 changes: 4 additions & 1 deletion crates/uv/tests/it/cache_prune.rs
Original file line number Diff line number Diff line change
Expand Up @@ -263,7 +263,10 @@ fn prune_unzipped() -> Result<()> {
and all of:
iniconfig<=0.1
iniconfig>=1.0.0
need to be downloaded from a registry, we can conclude that iniconfig<1.0.0 cannot be used.
need to be downloaded from a registry, we can conclude that all of:
iniconfig<=0.1
iniconfig>=1.0.0
cannot be used.
Comment on lines -266 to +269
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In brief, this "conclusion" is based on the terms which were previously not changed from their original contents during collapse of unavailable package versions. The conclusion was consequently only one part of the overall conclusion, but was being used for the merged nodes.

And because you require iniconfig, we can conclude that your requirements are unsatisfiable.

hint: Pre-releases are available for `iniconfig` in the requested range (e.g., 0.2.dev0), but pre-releases weren't enabled (try: `--prerelease=allow`)
Expand Down
2 changes: 1 addition & 1 deletion crates/uv/tests/it/pip_compile.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13796,7 +13796,7 @@ fn invalid_platform() -> Result<()> {
open3d==0.16.1
open3d==0.17.0
open3d==0.18.0
and open3d<=0.15.2 has no wheels with a matching Python ABI tag, we can conclude that open3d<0.9.0.0 cannot be used.
and open3d<=0.15.2 has no wheels with a matching Python ABI tag, we can conclude that open3d<=0.15.2 cannot be used.
And because open3d>=0.16.0 has no wheels with a matching platform tag and you require open3d, we can conclude that your requirements are unsatisfiable.
"###);

Expand Down
10 changes: 5 additions & 5 deletions crates/uv/tests/it/pip_install.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2182,11 +2182,11 @@ fn install_only_binary_all_and_no_binary_all() {
anyio>=3.7.0,<=3.7.1
anyio>=4.0.0
have no usable wheels and building from source is disabled, we can conclude that all of:
anyio<1.1.0
anyio>1.4.0,<2.0.0
anyio>2.2.0,<3.0.0
anyio>3.6.2,<3.7.0
anyio>3.7.1,<4.0.0
anyio>=1.0.0,<=1.4.0
anyio>=2.0.0,<=2.2.0
anyio>=3.0.0,<=3.6.2
anyio>=3.7.0,<=3.7.1
anyio>=4.0.0
cannot be used.
And because you require anyio, we can conclude that your requirements are unsatisfiable.

Expand Down
8 changes: 4 additions & 4 deletions crates/uv/tests/it/tool_list.rs
Original file line number Diff line number Diff line change
Expand Up @@ -276,7 +276,7 @@ fn tool_list_show_version_specifiers() {

uv_snapshot!(context.filters(), context.tool_list().arg("--show-version-specifiers")
.env(EnvVars::UV_TOOL_DIR, tool_dir.as_os_str())
.env(EnvVars::XDG_BIN_HOME, bin_dir.as_os_str()), @r#"
.env(EnvVars::XDG_BIN_HOME, bin_dir.as_os_str()), @r###"
success: true
exit_code: 0
----- stdout -----
Expand All @@ -287,12 +287,12 @@ fn tool_list_show_version_specifiers() {
- flask

----- stderr -----
"#);
"###);

// with paths
uv_snapshot!(context.filters(), context.tool_list().arg("--show-version-specifiers").arg("--show-paths")
.env(EnvVars::UV_TOOL_DIR, tool_dir.as_os_str())
.env(EnvVars::XDG_BIN_HOME, bin_dir.as_os_str()), @r#"
.env(EnvVars::XDG_BIN_HOME, bin_dir.as_os_str()), @r###"
success: true
exit_code: 0
----- stdout -----
Expand All @@ -303,5 +303,5 @@ fn tool_list_show_version_specifiers() {
- flask ([TEMP_DIR]/bin/flask)

----- stderr -----
"#);
"###);
}
Loading