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

Always accept already-installed pre-releases #5419

Merged
merged 1 commit into from
Jul 24, 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
24 changes: 8 additions & 16 deletions crates/uv-resolver/src/candidate_selector.rs
Original file line number Diff line number Diff line change
Expand Up @@ -120,14 +120,6 @@ impl CandidateSelector {
break 'preference;
}

// Respect the pre-release strategy for this fork.
if version.any_prerelease()
&& self.prerelease_strategy.allows(package_name, markers)
!= AllowPreRelease::Yes
{
break 'preference;
}

// Check for a locally installed distribution that matches the preferred version
if !exclusions.contains(package_name) {
let installed_dists = installed_packages.get_packages(package_name);
Expand Down Expand Up @@ -155,6 +147,14 @@ impl CandidateSelector {
}
}

// Respect the pre-release strategy for this fork.
if version.any_prerelease()
&& self.prerelease_strategy.allows(package_name, markers)
!= AllowPreRelease::Yes
{
break 'preference;
}

// Check for a remote distribution that matches the preferred version
if let Some(file) = version_maps
.iter()
Expand Down Expand Up @@ -183,14 +183,6 @@ impl CandidateSelector {
return None;
}

// Respect the pre-release strategy for this fork.
if version.any_prerelease()
&& self.prerelease_strategy.allows(package_name, markers)
!= AllowPreRelease::Yes
{
return None;
}

debug!("Found installed version of {dist} that satisfies {range}");
return Some(Candidate {
name: package_name,
Expand Down
43 changes: 43 additions & 0 deletions crates/uv/tests/pip_install.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6105,3 +6105,46 @@ fn local_index_fallback() -> Result<()> {

Ok(())
}

#[test]
fn accept_existing_prerelease() -> Result<()> {
let context = TestContext::new("3.12").with_filtered_counts();
let requirements_txt = context.temp_dir.child("requirements.txt");
requirements_txt.write_str("Flask==2.0.0rc1")?;

// Install a pre-release version of `flask`.
uv_snapshot!(context.filters(), context.pip_install().arg("Flask==2.0.0rc1"), @r###"
success: true
exit_code: 0
----- stdout -----

----- stderr -----
Resolved [N] packages in [TIME]
Prepared [N] packages in [TIME]
Installed [N] packages in [TIME]
+ click==8.1.7
+ flask==2.0.0rc1
+ itsdangerous==2.1.2
+ jinja2==3.1.3
+ markupsafe==2.1.5
+ werkzeug==3.0.1
"###
);

// Install `flask-login`, without enabling pre-releases. The existing version of `flask` should
// still be accepted.
uv_snapshot!(context.filters(), context.pip_install().arg("flask-login==0.6.0"), @r###"
success: true
exit_code: 0
----- stdout -----

----- stderr -----
Resolved [N] packages in [TIME]
Prepared [N] packages in [TIME]
Installed [N] packages in [TIME]
+ flask-login==0.6.0
"###
);

Ok(())
}
Loading