mirror of
https://github.com/astral-sh/uv.git
synced 2025-10-30 11:37:24 +00:00
Add PythonEnvironment::find API (#4423)
Restores the `PythonEnvironment::find` API which was removed a while back in favor of `Toolchain::find`. As mentioned in #4416, I'm attempting to separate the case where you want an active environment from the case where you want an installed toolchain in order to create environments. I wanted to drop `EnvironmentPreference` from `Toolchain::find` and just have us consistently consider (or not consider) virtual environments when discovering toolchains for creating environments. Unfortunately this caused a few things to break so I reverted that change and will explore it separately. Because I was exploring that change, there are some minor changes to the `Toolchain` API here.
This commit is contained in:
parent
baa86f2edf
commit
e783a79955
17 changed files with 285 additions and 295 deletions
|
|
@ -3,7 +3,7 @@ use std::path::PathBuf;
|
|||
use clap::Parser;
|
||||
use tracing::info;
|
||||
use uv_cache::{Cache, CacheArgs};
|
||||
use uv_toolchain::{EnvironmentPreference, Toolchain, ToolchainPreference};
|
||||
use uv_toolchain::{EnvironmentPreference, PythonEnvironment, ToolchainRequest};
|
||||
|
||||
#[derive(Parser)]
|
||||
pub(crate) struct CompileArgs {
|
||||
|
|
@ -20,10 +20,9 @@ pub(crate) async fn compile(args: CompileArgs) -> anyhow::Result<()> {
|
|||
let interpreter = if let Some(python) = args.python {
|
||||
python
|
||||
} else {
|
||||
let interpreter = Toolchain::find(
|
||||
None,
|
||||
let interpreter = PythonEnvironment::find(
|
||||
&ToolchainRequest::default(),
|
||||
EnvironmentPreference::OnlyVirtual,
|
||||
ToolchainPreference::default(),
|
||||
&cache,
|
||||
)?
|
||||
.into_interpreter();
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue