diff --git a/crates/uv-distribution-types/src/index_url.rs b/crates/uv-distribution-types/src/index_url.rs index 0e7b17a3f..774ecb205 100644 --- a/crates/uv-distribution-types/src/index_url.rs +++ b/crates/uv-distribution-types/src/index_url.rs @@ -27,8 +27,9 @@ static DEFAULT_INDEX: LazyLock = LazyLock::new(|| { )))) }); -static VARIANT_URL: LazyLock = - LazyLock::new(|| DisplaySafeUrl::parse("https://variants-index.wheelnext.dev").unwrap()); +static VARIANT_URL: LazyLock = LazyLock::new(|| { + DisplaySafeUrl::parse("https://download.pytorch.org/whl/test/variant").unwrap() +}); static VARIANT_INDEX: LazyLock = LazyLock::new(|| { Index::from_extra_index_url(IndexUrl::Url(Arc::new(VerbatimUrl::from_url( @@ -334,13 +335,24 @@ impl<'a> IndexLocations { if self.no_index { Either::Left(std::iter::empty()) } else { + // Determine whether the user defined a default index. + let mut seen = FxHashSet::default(); + let has_default = self + .indexes + .iter() + .filter(move |index| index.name.as_ref().is_none_or(|name| seen.insert(name))) + .any(|index| index.default); + let mut seen = FxHashSet::default(); Either::Right( self.indexes .iter() .filter(move |index| index.name.as_ref().is_none_or(|name| seen.insert(name))) .filter(|index| !index.default && !index.explicit) - .chain(std::iter::once(&*VARIANT_INDEX)), + .chain(Some(&*VARIANT_INDEX).filter(move |_| { + // If the user defined a default index, omit the variant index. + !has_default + })), ) } } @@ -370,8 +382,7 @@ impl<'a> IndexLocations { Either::Right( self.indexes .iter() - .filter(move |index| index.name.as_ref().is_none_or(|name| seen.insert(name))) - .chain(std::iter::once(&*VARIANT_INDEX)), + .filter(move |index| index.name.as_ref().is_none_or(|name| seen.insert(name))), ) } } @@ -413,7 +424,6 @@ impl<'a> IndexLocations { .iter() .chain(self.flat_index.iter()) .filter(move |index| index.name.as_ref().is_none_or(|name| seen.insert(name))) - .chain(std::iter::once(&*VARIANT_INDEX)) } { if index.default { if default { @@ -424,6 +434,7 @@ impl<'a> IndexLocations { indexes.push(index); } if !default { + indexes.push(&*VARIANT_INDEX); indexes.push(&*DEFAULT_INDEX); } @@ -555,13 +566,24 @@ impl<'a> IndexUrls { if self.no_index { Either::Left(std::iter::empty()) } else { + // Determine whether the user defined a default index. + let mut seen = FxHashSet::default(); + let has_default = self + .indexes + .iter() + .filter(move |index| index.name.as_ref().is_none_or(|name| seen.insert(name))) + .any(|index| index.default); + let mut seen = FxHashSet::default(); Either::Right( self.indexes .iter() .filter(move |index| index.name.as_ref().is_none_or(|name| seen.insert(name))) .filter(|index| !index.default && !index.explicit) - .chain(std::iter::once(&*VARIANT_INDEX)), + .chain(Some(&*VARIANT_INDEX).filter(move |_| { + // If the user defined a default index, omit the variant index. + !has_default + })), ) } } @@ -624,7 +646,7 @@ impl<'a> IndexUrls { return index.status_code_strategy(); } } - IndexStatusCodeStrategy::Default + IndexStatusCodeStrategy::from_index_url(url) } /// Return the Simple API cache control header for an [`IndexUrl`], if configured.