Hint at tool.uv.required-environments (#13575)

For the case where there was no matching wheel on sync, we previously
added a note about which wheels are available vs. on which platform you
are on. We extend this error message to link directly towards
`tool.uv.required-environments`, which otherwise has a discovery
problem.

On Linux (Setting `tool.uv.required-environments` doesn't help here
either, but it's a clear example):

```
[project]
name = "debug"
version = "0.1.0"
requires-python = "==3.10.*"
dependencies = ["tensorflow-macos>=2.13.1"]
```

```
Resolved 41 packages in 24ms
error: Distribution `tensorflow-macos==2.16.2 @ registry+https://pypi.org/simple` can't be installed because it doesn't have a source distribution or wheel for the current platform

hint: You're on Linux (`manylinux_2_39_x86_64`), but there are no wheels for the current platform, consider configuring `tool.uv.required-environments`.
hint: `tensorflow-macos` (v2.16.2) only has wheels for the following platform: `macosx_12_0_arm64`.
```


![image](https://github.com/user-attachments/assets/b6b49461-10d6-4e1d-bc0a-5d35d98e33d0)

---------

Co-authored-by: Zanie Blue <contact@zanie.dev>
This commit is contained in:
konsti 2025-06-06 21:15:52 +02:00 committed by GitHub
parent 7aefbe8dc5
commit 5b0133c0ec
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
3 changed files with 84 additions and 25 deletions

View file

@ -5084,32 +5084,23 @@ impl std::fmt::Display for WheelTagHint {
} else {
format!("`{}`", best.cyan())
};
if let Some(version) = version {
write!(
f,
"{}{} You're on {}, but `{}` ({}) only has wheels for the following platform{s}: {}",
"hint".bold().cyan(),
":".bold(),
best,
package.cyan(),
format!("v{version}").cyan(),
tags.iter()
.map(|tag| format!("`{}`", tag.cyan()))
.join(", "),
)
let package_ref = if let Some(version) = version {
format!("`{}` ({})", package.cyan(), format!("v{version}").cyan())
} else {
write!(
f,
"{}{} You're on {}, but `{}` only has wheels for the following platform{s}: {}",
"hint".bold().cyan(),
":".bold(),
best,
package.cyan(),
tags.iter()
.map(|tag| format!("`{}`", tag.cyan()))
.join(", "),
)
}
format!("`{}`", package.cyan())
};
writeln!(
f,
"{}{} You're on {}, but {} only has wheels for the following platform{s}: {}; consider adding your platform to `{}` to ensure uv resolves to a version with compatible wheels",
"hint".bold().cyan(),
":".bold(),
best,
package_ref,
tags.iter()
.map(|tag| format!("`{}`", tag.cyan()))
.join(", "),
"tool.uv.required-environments".green()
)
} else {
if let Some(version) = version {
write!(