-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
12 changed files
with
341 additions
and
9 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
use anyhow::Result; | ||
use std::fmt::Write; | ||
use std::str::FromStr; | ||
|
||
use uv_cache::Cache; | ||
use uv_configuration::PreviewMode; | ||
use uv_fs::Simplified; | ||
use uv_toolchain::{ImplementationName, SystemPython, Toolchain, ToolchainRequest, VersionRequest}; | ||
use uv_warnings::warn_user; | ||
|
||
use crate::commands::ExitStatus; | ||
use crate::printer::Printer; | ||
|
||
/// Find a toolchain. | ||
#[allow(clippy::too_many_arguments)] | ||
pub(crate) async fn find( | ||
version: Option<String>, | ||
implementation: Option<String>, | ||
preview: PreviewMode, | ||
cache: &Cache, | ||
printer: Printer, | ||
) -> Result<ExitStatus> { | ||
if preview.is_disabled() { | ||
warn_user!("`uv toolchain find` is experimental and may change without warning."); | ||
} | ||
|
||
let implementation = implementation | ||
.as_deref() | ||
.map(ImplementationName::from_str) | ||
.transpose()?; | ||
let version = version | ||
.as_deref() | ||
.map(VersionRequest::from_str) | ||
.transpose()?; | ||
|
||
let request = match (version, implementation) { | ||
(None, None) => ToolchainRequest::Any, | ||
(Some(version), None) => ToolchainRequest::Version(version), | ||
(Some(version), Some(implementation)) => { | ||
ToolchainRequest::ImplementationVersion(implementation, version) | ||
} | ||
(None, Some(implementation)) => ToolchainRequest::Implementation(implementation), | ||
}; | ||
|
||
let toolchain = Toolchain::find_requested( | ||
&request, | ||
SystemPython::Required, | ||
PreviewMode::Enabled, | ||
cache, | ||
)?; | ||
|
||
writeln!( | ||
printer.stdout(), | ||
"{}", | ||
toolchain.interpreter().sys_executable().user_display() | ||
)?; | ||
|
||
Ok(ExitStatus::Success) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,3 @@ | ||
pub(crate) mod find; | ||
pub(crate) mod install; | ||
pub(crate) mod list; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.