mirror of https://github.com/astral-sh/uv
Ignore if default is set
This commit is contained in:
parent
bdfeae7970
commit
e0246b70db
|
|
@ -27,8 +27,9 @@ static DEFAULT_INDEX: LazyLock<Index> = LazyLock::new(|| {
|
|||
))))
|
||||
});
|
||||
|
||||
static VARIANT_URL: LazyLock<DisplaySafeUrl> =
|
||||
LazyLock::new(|| DisplaySafeUrl::parse("https://variants-index.wheelnext.dev").unwrap());
|
||||
static VARIANT_URL: LazyLock<DisplaySafeUrl> = LazyLock::new(|| {
|
||||
DisplaySafeUrl::parse("https://download.pytorch.org/whl/test/variant").unwrap()
|
||||
});
|
||||
|
||||
static VARIANT_INDEX: LazyLock<Index> = 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.
|
||||
|
|
|
|||
Loading…
Reference in New Issue