Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update the Toolchain::find_requested API to take a parsed request #4215

Merged
merged 1 commit into from
Jun 10, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading