Skip to content

uv-resolver: use disjointness checks instead of marker equality #8661

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

Merged
merged 1 commit into from
Oct 29, 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
8 changes: 6 additions & 2 deletions crates/uv-resolver/src/candidate_selector.rs
Original file line number Diff line number Diff line change
Expand Up @@ -178,11 +178,15 @@ impl CandidateSelector {
let preferences_match =
preferences.get(package_name).filter(|(marker, _version)| {
// `.unwrap_or(true)` because the universal marker is considered matching.
marker.map(|marker| marker == fork_markers).unwrap_or(true)
marker
.map(|marker| !marker.is_disjoint(fork_markers))
.unwrap_or(true)
});
let preferences_mismatch =
preferences.get(package_name).filter(|(marker, _version)| {
marker.map(|marker| marker != fork_markers).unwrap_or(false)
marker
.map(|marker| marker.is_disjoint(fork_markers))
.unwrap_or(false)
});
self.get_preferred_from_iter(
preferences_match.chain(preferences_mismatch),
Expand Down
18 changes: 7 additions & 11 deletions crates/uv/tests/it/edit.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2936,15 +2936,11 @@ fn add_update_marker() -> Result<()> {
----- stdout -----

----- stderr -----
Resolved 8 packages in [TIME]
Prepared 3 packages in [TIME]
Uninstalled 3 packages in [TIME]
Installed 3 packages in [TIME]
- idna==3.6
+ idna==2.7
Resolved 10 packages in [TIME]
Prepared 1 package in [TIME]
Uninstalled 1 package in [TIME]
Installed 1 package in [TIME]
~ project==0.1.0 (from file://[TEMP_DIR]/)
- urllib3==2.2.1
+ urllib3==1.23
Copy link
Member Author

Choose a reason for hiding this comment

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

@konstin It looks like this is the crux of the change here: when adding requests>=2.31 ; sys_platform == 'win32' and python_version > '3.11', idna==3.6 and urllib3==2.2.1 get dropped in favor of idna==2.7 and urllib3=1.23. It seems like this change is a good one because it keeps what was there and doesn't suddenly change the resolution.

I think what is shown above is correct (requests 2.31 is compatible with idna 2.7).

"###);

let pyproject_toml = context.read("pyproject.toml");
Expand Down Expand Up @@ -2979,7 +2975,7 @@ fn add_update_marker() -> Result<()> {
----- stdout -----

----- stderr -----
Resolved 8 packages in [TIME]
Resolved 10 packages in [TIME]
Prepared 1 package in [TIME]
Uninstalled 1 package in [TIME]
Installed 1 package in [TIME]
Expand Down Expand Up @@ -3026,10 +3022,10 @@ fn add_update_marker() -> Result<()> {
Installed 1 package in [TIME]
- certifi==2024.2.2
- charset-normalizer==3.3.2
- idna==2.7
- idna==3.6
~ project==0.1.0 (from file://[TEMP_DIR]/)
- requests==2.31.0
- urllib3==1.23
- urllib3==2.2.1
"###);

let pyproject_toml = context.read("pyproject.toml");
Expand Down
Loading