mirror of
https://github.com/astral-sh/uv.git
synced 2025-07-07 13:25:00 +00:00
Improve 'any' search message during uv python install
(#4940)
Special cases the `Any` request in output e.g., ``` ❯ cargo run -q -- python install --isolated warning: `uv python install` is experimental and may change without warning. Searching for Python installations Found existing installation: cpython-3.12.3-macos-aarch64-none Python is already available. Use `uv python install <request>` to install a specific version. ``` instead of ``` ❯ cargo run -q -- python install --isolated warning: `uv python install` is experimental and may change without warning. Searching for Python versions matching: any Python Found existing installation for any Python: cpython-3.12.3-macos-aarch64-none Python is already available. Use `uv python install <request>` to install a specific version. ```
This commit is contained in:
parent
42ccce9641
commit
d497adaacb
2 changed files with 27 additions and 12 deletions
|
@ -26,6 +26,7 @@ pub(crate) async fn install(
|
|||
native_tls: bool,
|
||||
connectivity: Connectivity,
|
||||
preview: PreviewMode,
|
||||
isolated: bool,
|
||||
_cache: &Cache,
|
||||
printer: Printer,
|
||||
) -> Result<ExitStatus> {
|
||||
|
@ -41,7 +42,12 @@ pub(crate) async fn install(
|
|||
|
||||
let targets = targets.into_iter().collect::<BTreeSet<_>>();
|
||||
let requests: Vec<_> = if targets.is_empty() {
|
||||
if let Some(requests) = requests_from_version_file().await? {
|
||||
// Read from the version file, unless `isolated` was requested
|
||||
if let Some(requests) = if isolated {
|
||||
None
|
||||
} else {
|
||||
requests_from_version_file().await?
|
||||
} {
|
||||
requests
|
||||
} else {
|
||||
vec![PythonRequest::Any]
|
||||
|
@ -61,21 +67,29 @@ pub(crate) async fn install(
|
|||
let installed_installations: Vec<_> = installations.find_all()?.collect();
|
||||
let mut unfilled_requests = Vec::new();
|
||||
for (request, download_request) in requests.iter().zip(download_requests) {
|
||||
writeln!(
|
||||
printer.stderr(),
|
||||
"Searching for Python versions matching: {}",
|
||||
request.cyan()
|
||||
)?;
|
||||
if matches!(requests.as_slice(), [PythonRequest::Any]) {
|
||||
writeln!(printer.stderr(), "Searching for Python installations")?;
|
||||
} else {
|
||||
writeln!(
|
||||
printer.stderr(),
|
||||
"Searching for Python versions matching: {}",
|
||||
request.cyan()
|
||||
)?;
|
||||
}
|
||||
if let Some(installation) = installed_installations
|
||||
.iter()
|
||||
.find(|installation| download_request.satisfied_by_key(installation.key()))
|
||||
{
|
||||
writeln!(
|
||||
printer.stderr(),
|
||||
"Found existing installation for {}: {}",
|
||||
request.cyan(),
|
||||
installation.key().green(),
|
||||
)?;
|
||||
if matches!(request, PythonRequest::Any) {
|
||||
writeln!(printer.stderr(), "Found: {}", installation.key().green(),)?;
|
||||
} else {
|
||||
writeln!(
|
||||
printer.stderr(),
|
||||
"Found existing installation for {}: {}",
|
||||
request.cyan(),
|
||||
installation.key().green(),
|
||||
)?;
|
||||
}
|
||||
if force {
|
||||
writeln!(
|
||||
printer.stderr(),
|
||||
|
|
|
@ -776,6 +776,7 @@ async fn run() -> Result<ExitStatus> {
|
|||
globals.native_tls,
|
||||
globals.connectivity,
|
||||
globals.preview,
|
||||
globals.isolated,
|
||||
&cache,
|
||||
printer,
|
||||
)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue