mirror of https://github.com/astral-sh/uv
Rename `project::FoundInterpreter` to `ProjectInterpreter` (#7874)
This commit is contained in:
parent
5ff7dc99cb
commit
64c74ac552
|
|
@ -18,7 +18,7 @@ use uv_workspace::{DiscoveryOptions, MemberDiscovery, VirtualProject, Workspace}
|
||||||
|
|
||||||
use crate::commands::pip::loggers::DefaultResolveLogger;
|
use crate::commands::pip::loggers::DefaultResolveLogger;
|
||||||
use crate::commands::project::lock::do_safe_lock;
|
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::commands::{diagnostics, pip, ExitStatus, OutputWriter};
|
||||||
use crate::printer::Printer;
|
use crate::printer::Printer;
|
||||||
use crate::settings::ResolverSettings;
|
use crate::settings::ResolverSettings;
|
||||||
|
|
@ -74,7 +74,7 @@ pub(crate) async fn export(
|
||||||
};
|
};
|
||||||
|
|
||||||
// Find an interpreter for the project
|
// Find an interpreter for the project
|
||||||
let interpreter = FoundInterpreter::discover(
|
let interpreter = ProjectInterpreter::discover(
|
||||||
project.workspace(),
|
project.workspace(),
|
||||||
python.as_deref().map(PythonRequest::parse),
|
python.as_deref().map(PythonRequest::parse),
|
||||||
python_preference,
|
python_preference,
|
||||||
|
|
|
||||||
|
|
@ -35,7 +35,9 @@ use uv_warnings::{warn_user, warn_user_once};
|
||||||
use uv_workspace::{DiscoveryOptions, Workspace};
|
use uv_workspace::{DiscoveryOptions, Workspace};
|
||||||
|
|
||||||
use crate::commands::pip::loggers::{DefaultResolveLogger, ResolveLogger, SummaryResolveLogger};
|
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::commands::{diagnostics, pip, ExitStatus};
|
||||||
use crate::printer::Printer;
|
use crate::printer::Printer;
|
||||||
use crate::settings::{ResolverSettings, ResolverSettingsRef};
|
use crate::settings::{ResolverSettings, ResolverSettingsRef};
|
||||||
|
|
@ -84,7 +86,7 @@ pub(crate) async fn lock(
|
||||||
let workspace = Workspace::discover(project_dir, &DiscoveryOptions::default()).await?;
|
let workspace = Workspace::discover(project_dir, &DiscoveryOptions::default()).await?;
|
||||||
|
|
||||||
// Find an interpreter for the project
|
// Find an interpreter for the project
|
||||||
let interpreter = FoundInterpreter::discover(
|
let interpreter = ProjectInterpreter::discover(
|
||||||
&workspace,
|
&workspace,
|
||||||
python.as_deref().map(PythonRequest::parse),
|
python.as_deref().map(PythonRequest::parse),
|
||||||
python_preference,
|
python_preference,
|
||||||
|
|
|
||||||
|
|
@ -280,10 +280,13 @@ pub(crate) fn validate_requires_python(
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// An interpreter suitable for the project.
|
||||||
#[derive(Debug)]
|
#[derive(Debug)]
|
||||||
#[allow(clippy::large_enum_variant)]
|
#[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),
|
Interpreter(Interpreter),
|
||||||
|
/// An interpreter from an existing project virtual environment.
|
||||||
Environment(PythonEnvironment),
|
Environment(PythonEnvironment),
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -351,7 +354,7 @@ impl WorkspacePython {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl FoundInterpreter {
|
impl ProjectInterpreter {
|
||||||
/// Discover the interpreter to use in the current [`Workspace`].
|
/// Discover the interpreter to use in the current [`Workspace`].
|
||||||
pub(crate) async fn discover(
|
pub(crate) async fn discover(
|
||||||
workspace: &Workspace,
|
workspace: &Workspace,
|
||||||
|
|
@ -478,11 +481,11 @@ impl FoundInterpreter {
|
||||||
Ok(Self::Interpreter(interpreter))
|
Ok(Self::Interpreter(interpreter))
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Convert the [`FoundInterpreter`] into an [`Interpreter`].
|
/// Convert the [`ProjectInterpreter`] into an [`Interpreter`].
|
||||||
pub(crate) fn into_interpreter(self) -> Interpreter {
|
pub(crate) fn into_interpreter(self) -> Interpreter {
|
||||||
match self {
|
match self {
|
||||||
FoundInterpreter::Interpreter(interpreter) => interpreter,
|
ProjectInterpreter::Interpreter(interpreter) => interpreter,
|
||||||
FoundInterpreter::Environment(venv) => venv.into_interpreter(),
|
ProjectInterpreter::Environment(venv) => venv.into_interpreter(),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -498,7 +501,7 @@ pub(crate) async fn get_or_init_environment(
|
||||||
cache: &Cache,
|
cache: &Cache,
|
||||||
printer: Printer,
|
printer: Printer,
|
||||||
) -> Result<PythonEnvironment, ProjectError> {
|
) -> Result<PythonEnvironment, ProjectError> {
|
||||||
match FoundInterpreter::discover(
|
match ProjectInterpreter::discover(
|
||||||
workspace,
|
workspace,
|
||||||
python,
|
python,
|
||||||
python_preference,
|
python_preference,
|
||||||
|
|
@ -511,10 +514,10 @@ pub(crate) async fn get_or_init_environment(
|
||||||
.await?
|
.await?
|
||||||
{
|
{
|
||||||
// If we found an existing, compatible environment, use it.
|
// 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.
|
// Otherwise, create a virtual environment with the discovered interpreter.
|
||||||
FoundInterpreter::Interpreter(interpreter) => {
|
ProjectInterpreter::Interpreter(interpreter) => {
|
||||||
let venv = workspace.venv();
|
let venv = workspace.venv();
|
||||||
|
|
||||||
// Avoid removing things that are not virtual environments
|
// Avoid removing things that are not virtual environments
|
||||||
|
|
|
||||||
|
|
@ -12,7 +12,7 @@ use uv_workspace::{DiscoveryOptions, Workspace};
|
||||||
|
|
||||||
use crate::commands::pip::loggers::DefaultResolveLogger;
|
use crate::commands::pip::loggers::DefaultResolveLogger;
|
||||||
use crate::commands::pip::resolution_markers;
|
use crate::commands::pip::resolution_markers;
|
||||||
use crate::commands::project::FoundInterpreter;
|
use crate::commands::project::ProjectInterpreter;
|
||||||
use crate::commands::{project, ExitStatus};
|
use crate::commands::{project, ExitStatus};
|
||||||
use crate::printer::Printer;
|
use crate::printer::Printer;
|
||||||
use crate::settings::ResolverSettings;
|
use crate::settings::ResolverSettings;
|
||||||
|
|
@ -45,7 +45,7 @@ pub(crate) async fn tree(
|
||||||
let workspace = Workspace::discover(project_dir, &DiscoveryOptions::default()).await?;
|
let workspace = Workspace::discover(project_dir, &DiscoveryOptions::default()).await?;
|
||||||
|
|
||||||
// Find an interpreter for the project
|
// Find an interpreter for the project
|
||||||
let interpreter = FoundInterpreter::discover(
|
let interpreter = ProjectInterpreter::discover(
|
||||||
&workspace,
|
&workspace,
|
||||||
python.as_deref().map(PythonRequest::parse),
|
python.as_deref().map(PythonRequest::parse),
|
||||||
python_preference,
|
python_preference,
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue