mirror of
https://github.com/astral-sh/uv.git
synced 2025-10-02 15:01:16 +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,
|
||||
) -> 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 {
|
||||
|
@ -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)
|
||||
}
|
||||
|
|
|
@ -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.
|
||||
|
|
|
@ -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 {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue