Skip to content

Commit

Permalink
Update the Toolchain::find_requested API to take a parsed request (#…
Browse files Browse the repository at this point in the history
…4215)

Pulled out of #4206, need this for
#4214
  • Loading branch information
zanieb authored Jun 10, 2024
1 parent d7e10bb commit fd52fe7
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 6 deletions.
8 changes: 4 additions & 4 deletions crates/uv-toolchain/src/toolchain.rs
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,8 @@ impl Toolchain {
cache: &Cache,
) -> Result<Self, Error> {
if let Some(python) = python {
Self::find_requested(python, system, preview, cache)
let request = ToolchainRequest::parse(python);
Self::find_requested(&request, system, preview, cache)
} else if system.is_preferred() {
Self::find_default(preview, cache)
} else {
Expand All @@ -60,14 +61,13 @@ impl Toolchain {

/// Find an installed [`Toolchain`] that satisfies a request.
pub fn find_requested(
request: &str,
request: &ToolchainRequest,
system: SystemPython,
preview: PreviewMode,
cache: &Cache,
) -> Result<Self, Error> {
let sources = ToolchainSources::from_settings(system, preview);
let request = ToolchainRequest::parse(request);
let toolchain = find_toolchain(&request, system, &sources, cache)??;
let toolchain = find_toolchain(request, system, &sources, cache)??;

Ok(toolchain)
}
Expand Down
3 changes: 2 additions & 1 deletion crates/uv/src/commands/pip/compile.rs
Original file line number Diff line number Diff line change
Expand Up @@ -161,7 +161,8 @@ pub(crate) async fn pip_compile(
SystemPython::Allowed
};
let interpreter = if let Some(python) = python.as_ref() {
Toolchain::find_requested(python, system, preview, &cache)
let request = ToolchainRequest::parse(python);
Toolchain::find_requested(&request, system, preview, &cache)
} else {
// TODO(zanieb): The split here hints at a problem with the abstraction; we should be able to use
// `Toolchain::find(...)` here.
Expand Down
3 changes: 2 additions & 1 deletion crates/uv/src/commands/project/lock.rs
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,8 @@ pub(crate) async fn lock(
if request.satisfied(&interpreter, cache) {
interpreter
} else {
Toolchain::find_requested(python, SystemPython::Allowed, preview, cache)?
let request = ToolchainRequest::parse(python);
Toolchain::find_requested(&request, SystemPython::Allowed, preview, cache)?
.into_interpreter()
}
} else {
Expand Down

0 comments on commit fd52fe7

Please sign in to comment.