diff --git a/crates/uv/src/commands/project/export.rs b/crates/uv/src/commands/project/export.rs index 1875a5d9d..0b0f92455 100644 --- a/crates/uv/src/commands/project/export.rs +++ b/crates/uv/src/commands/project/export.rs @@ -18,7 +18,7 @@ use uv_workspace::{DiscoveryOptions, MemberDiscovery, VirtualProject, Workspace} use crate::commands::pip::loggers::DefaultResolveLogger; use crate::commands::project::lock::do_safe_lock; -use crate::commands::project::{FoundInterpreter, ProjectError}; +use crate::commands::project::{ProjectError, ProjectInterpreter}; use crate::commands::{diagnostics, pip, ExitStatus, OutputWriter}; use crate::printer::Printer; use crate::settings::ResolverSettings; @@ -74,7 +74,7 @@ pub(crate) async fn export( }; // Find an interpreter for the project - let interpreter = FoundInterpreter::discover( + let interpreter = ProjectInterpreter::discover( project.workspace(), python.as_deref().map(PythonRequest::parse), python_preference, diff --git a/crates/uv/src/commands/project/lock.rs b/crates/uv/src/commands/project/lock.rs index c27724b67..e6920d6b3 100644 --- a/crates/uv/src/commands/project/lock.rs +++ b/crates/uv/src/commands/project/lock.rs @@ -35,7 +35,9 @@ use uv_warnings::{warn_user, warn_user_once}; use uv_workspace::{DiscoveryOptions, Workspace}; use crate::commands::pip::loggers::{DefaultResolveLogger, ResolveLogger, SummaryResolveLogger}; -use crate::commands::project::{find_requires_python, FoundInterpreter, ProjectError, SharedState}; +use crate::commands::project::{ + find_requires_python, ProjectError, ProjectInterpreter, SharedState, +}; use crate::commands::{diagnostics, pip, ExitStatus}; use crate::printer::Printer; use crate::settings::{ResolverSettings, ResolverSettingsRef}; @@ -84,7 +86,7 @@ pub(crate) async fn lock( let workspace = Workspace::discover(project_dir, &DiscoveryOptions::default()).await?; // Find an interpreter for the project - let interpreter = FoundInterpreter::discover( + let interpreter = ProjectInterpreter::discover( &workspace, python.as_deref().map(PythonRequest::parse), python_preference, diff --git a/crates/uv/src/commands/project/mod.rs b/crates/uv/src/commands/project/mod.rs index 3a0bb9b9d..14d8fcf61 100644 --- a/crates/uv/src/commands/project/mod.rs +++ b/crates/uv/src/commands/project/mod.rs @@ -280,10 +280,13 @@ pub(crate) fn validate_requires_python( } } +/// An interpreter suitable for the project. #[derive(Debug)] #[allow(clippy::large_enum_variant)] -pub(crate) enum FoundInterpreter { +pub(crate) enum ProjectInterpreter { + /// An interpreter from outside the project, to create a new project virtual environment. Interpreter(Interpreter), + /// An interpreter from an existing project virtual environment. Environment(PythonEnvironment), } @@ -351,7 +354,7 @@ impl WorkspacePython { } } -impl FoundInterpreter { +impl ProjectInterpreter { /// Discover the interpreter to use in the current [`Workspace`]. pub(crate) async fn discover( workspace: &Workspace, @@ -478,11 +481,11 @@ impl FoundInterpreter { Ok(Self::Interpreter(interpreter)) } - /// Convert the [`FoundInterpreter`] into an [`Interpreter`]. + /// Convert the [`ProjectInterpreter`] into an [`Interpreter`]. pub(crate) fn into_interpreter(self) -> Interpreter { match self { - FoundInterpreter::Interpreter(interpreter) => interpreter, - FoundInterpreter::Environment(venv) => venv.into_interpreter(), + ProjectInterpreter::Interpreter(interpreter) => interpreter, + ProjectInterpreter::Environment(venv) => venv.into_interpreter(), } } } @@ -498,7 +501,7 @@ pub(crate) async fn get_or_init_environment( cache: &Cache, printer: Printer, ) -> Result { - match FoundInterpreter::discover( + match ProjectInterpreter::discover( workspace, python, python_preference, @@ -511,10 +514,10 @@ pub(crate) async fn get_or_init_environment( .await? { // If we found an existing, compatible environment, use it. - FoundInterpreter::Environment(environment) => Ok(environment), + ProjectInterpreter::Environment(environment) => Ok(environment), // Otherwise, create a virtual environment with the discovered interpreter. - FoundInterpreter::Interpreter(interpreter) => { + ProjectInterpreter::Interpreter(interpreter) => { let venv = workspace.venv(); // Avoid removing things that are not virtual environments diff --git a/crates/uv/src/commands/project/tree.rs b/crates/uv/src/commands/project/tree.rs index 63e9f2768..0ddbec93f 100644 --- a/crates/uv/src/commands/project/tree.rs +++ b/crates/uv/src/commands/project/tree.rs @@ -12,7 +12,7 @@ use uv_workspace::{DiscoveryOptions, Workspace}; use crate::commands::pip::loggers::DefaultResolveLogger; use crate::commands::pip::resolution_markers; -use crate::commands::project::FoundInterpreter; +use crate::commands::project::ProjectInterpreter; use crate::commands::{project, ExitStatus}; use crate::printer::Printer; use crate::settings::ResolverSettings; @@ -45,7 +45,7 @@ pub(crate) async fn tree( let workspace = Workspace::discover(project_dir, &DiscoveryOptions::default()).await?; // Find an interpreter for the project - let interpreter = FoundInterpreter::discover( + let interpreter = ProjectInterpreter::discover( &workspace, python.as_deref().map(PythonRequest::parse), python_preference,