mirror of
https://github.com/astral-sh/uv.git
synced 2025-11-20 03:49:54 +00:00
Show tag hints when failing to find a compatible wheel in pylock.toml (#13136)
Some checks are pending
CI / Determine changes (push) Waiting to run
CI / lint (push) Waiting to run
CI / cargo clippy | ubuntu (push) Blocked by required conditions
CI / cargo clippy | windows (push) Blocked by required conditions
CI / cargo dev generate-all (push) Blocked by required conditions
CI / cargo shear (push) Waiting to run
CI / cargo test | ubuntu (push) Blocked by required conditions
CI / cargo test | macos (push) Blocked by required conditions
CI / cargo test | windows (push) Blocked by required conditions
CI / check windows trampoline | aarch64 (push) Blocked by required conditions
CI / check windows trampoline | i686 (push) Blocked by required conditions
CI / build binary | linux libc (push) Blocked by required conditions
CI / check windows trampoline | x86_64 (push) Blocked by required conditions
CI / test windows trampoline | i686 (push) Blocked by required conditions
CI / test windows trampoline | x86_64 (push) Blocked by required conditions
CI / typos (push) Waiting to run
CI / mkdocs (push) Waiting to run
CI / integration test | pypy on windows (push) Blocked by required conditions
CI / build binary | linux musl (push) Blocked by required conditions
CI / build binary | macos aarch64 (push) Blocked by required conditions
CI / build binary | macos x86_64 (push) Blocked by required conditions
CI / build binary | windows x86_64 (push) Blocked by required conditions
CI / build binary | windows aarch64 (push) Blocked by required conditions
CI / integration test | uv publish (push) Blocked by required conditions
CI / cargo build (msrv) (push) Blocked by required conditions
CI / build binary | freebsd (push) Blocked by required conditions
CI / ecosystem test | pydantic/pydantic-core (push) Blocked by required conditions
CI / ecosystem test | prefecthq/prefect (push) Blocked by required conditions
CI / integration test | pypy on ubuntu (push) Blocked by required conditions
CI / ecosystem test | pallets/flask (push) Blocked by required conditions
CI / smoke test | linux (push) Blocked by required conditions
CI / check system | alpine (push) Blocked by required conditions
CI / smoke test | macos (push) Blocked by required conditions
CI / smoke test | windows x86_64 (push) Blocked by required conditions
CI / smoke test | windows aarch64 (push) Blocked by required conditions
CI / integration test | conda on ubuntu (push) Blocked by required conditions
CI / integration test | deadsnakes python3.9 on ubuntu (push) Blocked by required conditions
CI / integration test | free-threaded on linux (push) Blocked by required conditions
CI / integration test | free-threaded on windows (push) Blocked by required conditions
CI / integration test | graalpy on ubuntu (push) Blocked by required conditions
CI / integration test | graalpy on windows (push) Blocked by required conditions
CI / integration test | github actions (push) Blocked by required conditions
CI / integration test | free-threaded python on github actions (push) Blocked by required conditions
CI / integration test | determine publish changes (push) Blocked by required conditions
CI / integration test | uv_build (push) Blocked by required conditions
CI / check cache | ubuntu (push) Blocked by required conditions
CI / check cache | macos aarch64 (push) Blocked by required conditions
CI / check system | python on debian (push) Blocked by required conditions
CI / check system | python on fedora (push) Blocked by required conditions
CI / check system | python on ubuntu (push) Blocked by required conditions
CI / check system | python on opensuse (push) Blocked by required conditions
CI / check system | python on rocky linux 8 (push) Blocked by required conditions
CI / check system | python on rocky linux 9 (push) Blocked by required conditions
CI / check system | pypy on ubuntu (push) Blocked by required conditions
CI / check system | pyston (push) Blocked by required conditions
CI / check system | python on macos aarch64 (push) Blocked by required conditions
CI / check system | homebrew python on macos aarch64 (push) Blocked by required conditions
CI / check system | python on macos x86-64 (push) Blocked by required conditions
CI / check system | python3.10 on windows x86-64 (push) Blocked by required conditions
CI / check system | python3.10 on windows x86 (push) Blocked by required conditions
CI / check system | python3.13 on windows x86-64 (push) Blocked by required conditions
CI / check system | x86-64 python3.13 on windows aarch64 (push) Blocked by required conditions
CI / check system | windows registry (push) Blocked by required conditions
CI / check system | python3.12 via chocolatey (push) Blocked by required conditions
CI / check system | conda3.8 on linux x86-64 (push) Blocked by required conditions
CI / check system | python3.9 via pyenv (push) Blocked by required conditions
CI / check system | python3.13 (push) Blocked by required conditions
CI / check system | conda3.11 on macos aarch64 (push) Blocked by required conditions
CI / check system | conda3.8 on macos aarch64 (push) Blocked by required conditions
CI / check system | conda3.11 on linux x86-64 (push) Blocked by required conditions
CI / check system | conda3.11 on windows x86-64 (push) Blocked by required conditions
CI / check system | conda3.8 on windows x86-64 (push) Blocked by required conditions
CI / check system | amazonlinux (push) Blocked by required conditions
CI / check system | embedded python3.10 on windows x86-64 (push) Blocked by required conditions
CI / benchmarks (push) Blocked by required conditions
Some checks are pending
CI / Determine changes (push) Waiting to run
CI / lint (push) Waiting to run
CI / cargo clippy | ubuntu (push) Blocked by required conditions
CI / cargo clippy | windows (push) Blocked by required conditions
CI / cargo dev generate-all (push) Blocked by required conditions
CI / cargo shear (push) Waiting to run
CI / cargo test | ubuntu (push) Blocked by required conditions
CI / cargo test | macos (push) Blocked by required conditions
CI / cargo test | windows (push) Blocked by required conditions
CI / check windows trampoline | aarch64 (push) Blocked by required conditions
CI / check windows trampoline | i686 (push) Blocked by required conditions
CI / build binary | linux libc (push) Blocked by required conditions
CI / check windows trampoline | x86_64 (push) Blocked by required conditions
CI / test windows trampoline | i686 (push) Blocked by required conditions
CI / test windows trampoline | x86_64 (push) Blocked by required conditions
CI / typos (push) Waiting to run
CI / mkdocs (push) Waiting to run
CI / integration test | pypy on windows (push) Blocked by required conditions
CI / build binary | linux musl (push) Blocked by required conditions
CI / build binary | macos aarch64 (push) Blocked by required conditions
CI / build binary | macos x86_64 (push) Blocked by required conditions
CI / build binary | windows x86_64 (push) Blocked by required conditions
CI / build binary | windows aarch64 (push) Blocked by required conditions
CI / integration test | uv publish (push) Blocked by required conditions
CI / cargo build (msrv) (push) Blocked by required conditions
CI / build binary | freebsd (push) Blocked by required conditions
CI / ecosystem test | pydantic/pydantic-core (push) Blocked by required conditions
CI / ecosystem test | prefecthq/prefect (push) Blocked by required conditions
CI / integration test | pypy on ubuntu (push) Blocked by required conditions
CI / ecosystem test | pallets/flask (push) Blocked by required conditions
CI / smoke test | linux (push) Blocked by required conditions
CI / check system | alpine (push) Blocked by required conditions
CI / smoke test | macos (push) Blocked by required conditions
CI / smoke test | windows x86_64 (push) Blocked by required conditions
CI / smoke test | windows aarch64 (push) Blocked by required conditions
CI / integration test | conda on ubuntu (push) Blocked by required conditions
CI / integration test | deadsnakes python3.9 on ubuntu (push) Blocked by required conditions
CI / integration test | free-threaded on linux (push) Blocked by required conditions
CI / integration test | free-threaded on windows (push) Blocked by required conditions
CI / integration test | graalpy on ubuntu (push) Blocked by required conditions
CI / integration test | graalpy on windows (push) Blocked by required conditions
CI / integration test | github actions (push) Blocked by required conditions
CI / integration test | free-threaded python on github actions (push) Blocked by required conditions
CI / integration test | determine publish changes (push) Blocked by required conditions
CI / integration test | uv_build (push) Blocked by required conditions
CI / check cache | ubuntu (push) Blocked by required conditions
CI / check cache | macos aarch64 (push) Blocked by required conditions
CI / check system | python on debian (push) Blocked by required conditions
CI / check system | python on fedora (push) Blocked by required conditions
CI / check system | python on ubuntu (push) Blocked by required conditions
CI / check system | python on opensuse (push) Blocked by required conditions
CI / check system | python on rocky linux 8 (push) Blocked by required conditions
CI / check system | python on rocky linux 9 (push) Blocked by required conditions
CI / check system | pypy on ubuntu (push) Blocked by required conditions
CI / check system | pyston (push) Blocked by required conditions
CI / check system | python on macos aarch64 (push) Blocked by required conditions
CI / check system | homebrew python on macos aarch64 (push) Blocked by required conditions
CI / check system | python on macos x86-64 (push) Blocked by required conditions
CI / check system | python3.10 on windows x86-64 (push) Blocked by required conditions
CI / check system | python3.10 on windows x86 (push) Blocked by required conditions
CI / check system | python3.13 on windows x86-64 (push) Blocked by required conditions
CI / check system | x86-64 python3.13 on windows aarch64 (push) Blocked by required conditions
CI / check system | windows registry (push) Blocked by required conditions
CI / check system | python3.12 via chocolatey (push) Blocked by required conditions
CI / check system | conda3.8 on linux x86-64 (push) Blocked by required conditions
CI / check system | python3.9 via pyenv (push) Blocked by required conditions
CI / check system | python3.13 (push) Blocked by required conditions
CI / check system | conda3.11 on macos aarch64 (push) Blocked by required conditions
CI / check system | conda3.8 on macos aarch64 (push) Blocked by required conditions
CI / check system | conda3.11 on linux x86-64 (push) Blocked by required conditions
CI / check system | conda3.11 on windows x86-64 (push) Blocked by required conditions
CI / check system | conda3.8 on windows x86-64 (push) Blocked by required conditions
CI / check system | amazonlinux (push) Blocked by required conditions
CI / check system | embedded python3.10 on windows x86-64 (push) Blocked by required conditions
CI / benchmarks (push) Blocked by required conditions
## Summary Closes #13135.
This commit is contained in:
parent
78756de027
commit
dc5b3762f3
6 changed files with 294 additions and 184 deletions
|
|
@ -52,7 +52,7 @@ use uv_workspace::WorkspaceMember;
|
|||
use crate::fork_strategy::ForkStrategy;
|
||||
pub(crate) use crate::lock::export::PylockTomlPackage;
|
||||
pub use crate::lock::export::RequirementsTxtExport;
|
||||
pub use crate::lock::export::{PylockToml, PylockTomlError};
|
||||
pub use crate::lock::export::{PylockToml, PylockTomlErrorKind};
|
||||
pub use crate::lock::installable::Installable;
|
||||
pub use crate::lock::map::PackageMap;
|
||||
pub use crate::lock::tree::TreeDisplay;
|
||||
|
|
@ -2305,78 +2305,19 @@ impl Package {
|
|||
}
|
||||
}
|
||||
|
||||
/// Generate a [`LockErrorHint`] based on wheel-tag incompatibilities.
|
||||
fn tag_hint(&self, tag_policy: TagPolicy<'_>) -> Option<LockErrorHint> {
|
||||
let incompatibility = self
|
||||
/// Generate a [`WheelTagHint`] based on wheel-tag incompatibilities.
|
||||
fn tag_hint(&self, tag_policy: TagPolicy<'_>) -> Option<WheelTagHint> {
|
||||
let filenames = self
|
||||
.wheels
|
||||
.iter()
|
||||
.map(|wheel| {
|
||||
tag_policy.tags().compatibility(
|
||||
wheel.filename.python_tags(),
|
||||
wheel.filename.abi_tags(),
|
||||
wheel.filename.platform_tags(),
|
||||
)
|
||||
})
|
||||
.max()?;
|
||||
match incompatibility {
|
||||
TagCompatibility::Incompatible(IncompatibleTag::Python) => {
|
||||
let best = tag_policy.tags().python_tag();
|
||||
let tags = self.python_tags().collect::<BTreeSet<_>>();
|
||||
if tags.is_empty() {
|
||||
None
|
||||
} else {
|
||||
Some(LockErrorHint::LanguageTags {
|
||||
package: self.id.name.clone(),
|
||||
version: self.id.version.clone(),
|
||||
tags,
|
||||
best,
|
||||
})
|
||||
}
|
||||
}
|
||||
TagCompatibility::Incompatible(IncompatibleTag::Abi) => {
|
||||
let best = tag_policy.tags().abi_tag();
|
||||
let tags = self
|
||||
.abi_tags()
|
||||
// Ignore `none`, which is universally compatible.
|
||||
//
|
||||
// As an example, `none` can appear here if we're solving for Python 3.13, and
|
||||
// the distribution includes a wheel for `cp312-none-macosx_11_0_arm64`.
|
||||
//
|
||||
// In that case, the wheel isn't compatible, but when solving for Python 3.13,
|
||||
// the `cp312` Python tag _can_ be compatible (e.g., for `cp312-abi3-macosx_11_0_arm64.whl`),
|
||||
// so this is considered an ABI incompatibility rather than Python incompatibility.
|
||||
.filter(|tag| *tag != AbiTag::None)
|
||||
.collect::<BTreeSet<_>>();
|
||||
if tags.is_empty() {
|
||||
None
|
||||
} else {
|
||||
Some(LockErrorHint::AbiTags {
|
||||
package: self.id.name.clone(),
|
||||
version: self.id.version.clone(),
|
||||
tags,
|
||||
best,
|
||||
})
|
||||
}
|
||||
}
|
||||
TagCompatibility::Incompatible(IncompatibleTag::Platform) => {
|
||||
let best = tag_policy.tags().platform_tag().cloned();
|
||||
let tags = self
|
||||
.platform_tags(tag_policy.tags())
|
||||
.cloned()
|
||||
.collect::<BTreeSet<_>>();
|
||||
if tags.is_empty() {
|
||||
None
|
||||
} else {
|
||||
Some(LockErrorHint::PlatformTags {
|
||||
package: self.id.name.clone(),
|
||||
version: self.id.version.clone(),
|
||||
tags,
|
||||
best,
|
||||
})
|
||||
}
|
||||
}
|
||||
_ => None,
|
||||
}
|
||||
.map(|wheel| &wheel.filename)
|
||||
.collect::<Vec<_>>();
|
||||
WheelTagHint::from_wheels(
|
||||
&self.id.name,
|
||||
self.id.version.as_ref(),
|
||||
&filenames,
|
||||
tag_policy.tags(),
|
||||
)
|
||||
}
|
||||
|
||||
/// Convert the source of this [`Package`] to a [`SourceDist`] that can be used in installation.
|
||||
|
|
@ -2729,43 +2670,6 @@ impl Package {
|
|||
Ok(table)
|
||||
}
|
||||
|
||||
/// Returns an iterator over the compatible Python tags of the available wheels.
|
||||
fn python_tags(&self) -> impl Iterator<Item = LanguageTag> + '_ {
|
||||
self.wheels
|
||||
.iter()
|
||||
.flat_map(|wheel| wheel.filename.python_tags())
|
||||
.copied()
|
||||
}
|
||||
|
||||
/// Returns an iterator over the compatible Python tags of the available wheels.
|
||||
fn abi_tags(&self) -> impl Iterator<Item = AbiTag> + '_ {
|
||||
self.wheels
|
||||
.iter()
|
||||
.flat_map(|wheel| wheel.filename.abi_tags())
|
||||
.copied()
|
||||
}
|
||||
|
||||
/// Returns the set of platform tags for the distribution that are ABI-compatible with the given
|
||||
/// tags.
|
||||
pub fn platform_tags<'a>(
|
||||
&'a self,
|
||||
tags: &'a Tags,
|
||||
) -> impl Iterator<Item = &'a PlatformTag> + 'a {
|
||||
self.wheels.iter().flat_map(move |wheel| {
|
||||
if wheel.filename.python_tags().iter().any(|wheel_py| {
|
||||
wheel
|
||||
.filename
|
||||
.abi_tags()
|
||||
.iter()
|
||||
.any(|wheel_abi| tags.is_compatible_abi(*wheel_py, *wheel_abi))
|
||||
}) {
|
||||
wheel.filename.platform_tags().iter()
|
||||
} else {
|
||||
[].iter()
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
fn find_best_wheel(&self, tag_policy: TagPolicy<'_>) -> Option<usize> {
|
||||
type WheelPriority<'lock> = (TagPriority, Option<&'lock BuildTag>);
|
||||
|
||||
|
|
@ -4782,7 +4686,7 @@ fn normalize_requirement(
|
|||
#[derive(Debug)]
|
||||
pub struct LockError {
|
||||
kind: Box<LockErrorKind>,
|
||||
hint: Option<LockErrorHint>,
|
||||
hint: Option<WheelTagHint>,
|
||||
}
|
||||
|
||||
impl std::error::Error for LockError {
|
||||
|
|
@ -4822,7 +4726,7 @@ where
|
|||
|
||||
#[derive(Debug, Clone, PartialEq, Eq)]
|
||||
#[allow(clippy::enum_variant_names)]
|
||||
enum LockErrorHint {
|
||||
enum WheelTagHint {
|
||||
/// None of the available wheels for a package have a compatible Python language tag (e.g.,
|
||||
/// `cp310` in `cp310-abi3-manylinux_2_17_x86_64.whl`).
|
||||
LanguageTags {
|
||||
|
|
@ -4849,7 +4753,123 @@ enum LockErrorHint {
|
|||
},
|
||||
}
|
||||
|
||||
impl std::fmt::Display for LockErrorHint {
|
||||
impl WheelTagHint {
|
||||
/// Generate a [`WheelTagHint`] from the given (incompatible) wheels.
|
||||
fn from_wheels(
|
||||
name: &PackageName,
|
||||
version: Option<&Version>,
|
||||
filenames: &[&WheelFilename],
|
||||
tags: &Tags,
|
||||
) -> Option<WheelTagHint> {
|
||||
let incompatibility = filenames
|
||||
.iter()
|
||||
.map(|filename| {
|
||||
tags.compatibility(
|
||||
filename.python_tags(),
|
||||
filename.abi_tags(),
|
||||
filename.platform_tags(),
|
||||
)
|
||||
})
|
||||
.max()?;
|
||||
match incompatibility {
|
||||
TagCompatibility::Incompatible(IncompatibleTag::Python) => {
|
||||
let best = tags.python_tag();
|
||||
let tags = Self::python_tags(filenames.iter().copied()).collect::<BTreeSet<_>>();
|
||||
if tags.is_empty() {
|
||||
None
|
||||
} else {
|
||||
Some(WheelTagHint::LanguageTags {
|
||||
package: name.clone(),
|
||||
version: version.cloned(),
|
||||
tags,
|
||||
best,
|
||||
})
|
||||
}
|
||||
}
|
||||
TagCompatibility::Incompatible(IncompatibleTag::Abi) => {
|
||||
let best = tags.abi_tag();
|
||||
let tags = Self::abi_tags(filenames.iter().copied())
|
||||
// Ignore `none`, which is universally compatible.
|
||||
//
|
||||
// As an example, `none` can appear here if we're solving for Python 3.13, and
|
||||
// the distribution includes a wheel for `cp312-none-macosx_11_0_arm64`.
|
||||
//
|
||||
// In that case, the wheel isn't compatible, but when solving for Python 3.13,
|
||||
// the `cp312` Python tag _can_ be compatible (e.g., for `cp312-abi3-macosx_11_0_arm64.whl`),
|
||||
// so this is considered an ABI incompatibility rather than Python incompatibility.
|
||||
.filter(|tag| *tag != AbiTag::None)
|
||||
.collect::<BTreeSet<_>>();
|
||||
if tags.is_empty() {
|
||||
None
|
||||
} else {
|
||||
Some(WheelTagHint::AbiTags {
|
||||
package: name.clone(),
|
||||
version: version.cloned(),
|
||||
tags,
|
||||
best,
|
||||
})
|
||||
}
|
||||
}
|
||||
TagCompatibility::Incompatible(IncompatibleTag::Platform) => {
|
||||
let best = tags.platform_tag().cloned();
|
||||
let tags = Self::platform_tags(filenames.iter().copied(), tags)
|
||||
.cloned()
|
||||
.collect::<BTreeSet<_>>();
|
||||
if tags.is_empty() {
|
||||
None
|
||||
} else {
|
||||
Some(WheelTagHint::PlatformTags {
|
||||
package: name.clone(),
|
||||
version: version.cloned(),
|
||||
tags,
|
||||
best,
|
||||
})
|
||||
}
|
||||
}
|
||||
_ => None,
|
||||
}
|
||||
}
|
||||
|
||||
/// Returns an iterator over the compatible Python tags of the available wheels.
|
||||
fn python_tags<'a>(
|
||||
filenames: impl Iterator<Item = &'a WheelFilename> + 'a,
|
||||
) -> impl Iterator<Item = LanguageTag> + 'a {
|
||||
filenames
|
||||
.flat_map(uv_distribution_filename::WheelFilename::python_tags)
|
||||
.copied()
|
||||
}
|
||||
|
||||
/// Returns an iterator over the compatible Python tags of the available wheels.
|
||||
fn abi_tags<'a>(
|
||||
filenames: impl Iterator<Item = &'a WheelFilename> + 'a,
|
||||
) -> impl Iterator<Item = AbiTag> + 'a {
|
||||
filenames
|
||||
.flat_map(uv_distribution_filename::WheelFilename::abi_tags)
|
||||
.copied()
|
||||
}
|
||||
|
||||
/// Returns the set of platform tags for the distribution that are ABI-compatible with the given
|
||||
/// tags.
|
||||
fn platform_tags<'a>(
|
||||
filenames: impl Iterator<Item = &'a WheelFilename> + 'a,
|
||||
tags: &'a Tags,
|
||||
) -> impl Iterator<Item = &'a PlatformTag> + 'a {
|
||||
filenames.flat_map(move |filename| {
|
||||
if filename.python_tags().iter().any(|wheel_py| {
|
||||
filename
|
||||
.abi_tags()
|
||||
.iter()
|
||||
.any(|wheel_abi| tags.is_compatible_abi(*wheel_py, *wheel_abi))
|
||||
}) {
|
||||
filename.platform_tags().iter()
|
||||
} else {
|
||||
[].iter()
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
impl std::fmt::Display for WheelTagHint {
|
||||
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
|
||||
match self {
|
||||
Self::LanguageTags {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue