Allow conflicting prerelease strategies when forking (#5150)

## Summary

Similar to https://github.com/astral-sh/uv/pull/5232, we should also
track prerelease strategies per-fork, instead of globally per package.
The common functionality for tracking locals and prerelease versions
across forks is extracted into the `ForkMap` type.

Resolves https://github.com/astral-sh/uv/issues/4579. This doesn't quite
solve https://github.com/astral-sh/uv/issues/4959, as that issue relies
on overlapping markers.
This commit is contained in:
Ibraheem Ahmed
2024-07-23 11:57:14 -04:00
committed by GitHub
parent bea8bc6c61
commit c8ac8ee57a
9 changed files with 449 additions and 132 deletions
@@ -12,7 +12,7 @@ use pep440_rs::Version;
use crate::candidate_selector::CandidateSelector;
use crate::pubgrub::{PubGrubPackage, PubGrubPackageInner};
use crate::resolver::Request;
use crate::{InMemoryIndex, PythonRequirement, ResolveError, VersionsResponse};
use crate::{InMemoryIndex, PythonRequirement, ResolveError, ResolverMarkers, VersionsResponse};
enum BatchPrefetchStrategy {
/// Go through the next versions assuming the existing selection and its constraints
@@ -53,6 +53,7 @@ impl BatchPrefetcher {
request_sink: &Sender<Request>,
index: &InMemoryIndex,
selector: &CandidateSelector,
markers: &ResolverMarkers,
) -> anyhow::Result<(), ResolveError> {
let PubGrubPackageInner::Package {
name,
@@ -92,7 +93,7 @@ impl BatchPrefetcher {
previous,
} => {
if let Some(candidate) =
selector.select_no_preference(name, &compatible, version_map)
selector.select_no_preference(name, &compatible, version_map, markers)
{
let compatible = compatible.intersection(
&Range::singleton(candidate.version().clone()).complement(),
@@ -116,7 +117,7 @@ impl BatchPrefetcher {
Range::strictly_higher_than(previous)
};
if let Some(candidate) =
selector.select_no_preference(name, &range, version_map)
selector.select_no_preference(name, &range, version_map, markers)
{
phase = BatchPrefetchStrategy::InOrder {
previous: candidate.version().clone(),