mirror of
https://github.com/astral-sh/uv.git
synced 2025-10-02 06:51:14 +00:00
Update the Toolchain::find_requested
API to take a parsed request (#4215)
Pulled out of https://github.com/astral-sh/uv/pull/4206, need this for #4214
This commit is contained in:
parent
d7e10bb4a2
commit
fd52fe74ce
3 changed files with 8 additions and 6 deletions
|
@ -33,7 +33,8 @@ impl Toolchain {
|
||||||
cache: &Cache,
|
cache: &Cache,
|
||||||
) -> Result<Self, Error> {
|
) -> Result<Self, Error> {
|
||||||
if let Some(python) = python {
|
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() {
|
} else if system.is_preferred() {
|
||||||
Self::find_default(preview, cache)
|
Self::find_default(preview, cache)
|
||||||
} else {
|
} else {
|
||||||
|
@ -60,14 +61,13 @@ impl Toolchain {
|
||||||
|
|
||||||
/// Find an installed [`Toolchain`] that satisfies a request.
|
/// Find an installed [`Toolchain`] that satisfies a request.
|
||||||
pub fn find_requested(
|
pub fn find_requested(
|
||||||
request: &str,
|
request: &ToolchainRequest,
|
||||||
system: SystemPython,
|
system: SystemPython,
|
||||||
preview: PreviewMode,
|
preview: PreviewMode,
|
||||||
cache: &Cache,
|
cache: &Cache,
|
||||||
) -> Result<Self, Error> {
|
) -> Result<Self, Error> {
|
||||||
let sources = ToolchainSources::from_settings(system, preview);
|
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)
|
Ok(toolchain)
|
||||||
}
|
}
|
||||||
|
|
|
@ -161,7 +161,8 @@ pub(crate) async fn pip_compile(
|
||||||
SystemPython::Allowed
|
SystemPython::Allowed
|
||||||
};
|
};
|
||||||
let interpreter = if let Some(python) = python.as_ref() {
|
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 {
|
} else {
|
||||||
// TODO(zanieb): The split here hints at a problem with the abstraction; we should be able to use
|
// TODO(zanieb): The split here hints at a problem with the abstraction; we should be able to use
|
||||||
// `Toolchain::find(...)` here.
|
// `Toolchain::find(...)` here.
|
||||||
|
|
|
@ -49,7 +49,8 @@ pub(crate) async fn lock(
|
||||||
if request.satisfied(&interpreter, cache) {
|
if request.satisfied(&interpreter, cache) {
|
||||||
interpreter
|
interpreter
|
||||||
} else {
|
} else {
|
||||||
Toolchain::find_requested(python, SystemPython::Allowed, preview, cache)?
|
let request = ToolchainRequest::parse(python);
|
||||||
|
Toolchain::find_requested(&request, SystemPython::Allowed, preview, cache)?
|
||||||
.into_interpreter()
|
.into_interpreter()
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue