Rename EphemeralEnvironment to CachedEnvironment (#4804)

This commit is contained in:
Charlie Marsh 2024-07-04 09:57:12 -04:00 committed by GitHub
parent c6f72d333a
commit cf004fd644
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
17 changed files with 32 additions and 17 deletions

View file

@ -1,4 +1,5 @@
use owo_colors::OwoColorize; use owo_colors::OwoColorize;
use uv_cache::Cache; use uv_cache::Cache;
use uv_fs::Simplified; use uv_fs::Simplified;

View file

@ -17,16 +17,16 @@ use crate::settings::ResolverInstallerSettings;
/// An ephemeral [`PythonEnvironment`] stored in the cache. /// An ephemeral [`PythonEnvironment`] stored in the cache.
#[derive(Debug)] #[derive(Debug)]
pub(crate) struct EphemeralEnvironment(PythonEnvironment); pub(crate) struct CachedEnvironment(PythonEnvironment);
impl From<EphemeralEnvironment> for PythonEnvironment { impl From<CachedEnvironment> for PythonEnvironment {
fn from(ephemeral: EphemeralEnvironment) -> Self { fn from(ephemeral: CachedEnvironment) -> Self {
ephemeral.0 ephemeral.0
} }
} }
impl EphemeralEnvironment { impl CachedEnvironment {
/// Get or create an [`EphemeralEnvironment`] based on a given set of requirements and a base /// Get or create an [`CachedEnvironment`] based on a given set of requirements and a base
/// interpreter. /// interpreter.
pub(crate) async fn get_or_create( pub(crate) async fn get_or_create(
requirements: Vec<Requirement>, requirements: Vec<Requirement>,

View file

@ -31,7 +31,7 @@ use crate::printer::Printer;
use crate::settings::{InstallerSettingsRef, ResolverInstallerSettings, ResolverSettingsRef}; use crate::settings::{InstallerSettingsRef, ResolverInstallerSettings, ResolverSettingsRef};
pub(crate) mod add; pub(crate) mod add;
pub(crate) mod ephemeral; pub(crate) mod environment;
pub(crate) mod lock; pub(crate) mod lock;
pub(crate) mod remove; pub(crate) mod remove;
pub(crate) mod run; pub(crate) mod run;

View file

@ -1,5 +1,6 @@
use anyhow::Context; use anyhow::Context;
use owo_colors::OwoColorize; use owo_colors::OwoColorize;
use uv_configuration::PreviewMode; use uv_configuration::PreviewMode;
use uv_fs::Simplified; use uv_fs::Simplified;
use uv_python::managed::ManagedPythonInstallations; use uv_python::managed::ManagedPythonInstallations;

View file

@ -1,6 +1,7 @@
use anyhow::Result;
use std::fmt::Write; use std::fmt::Write;
use anyhow::Result;
use uv_cache::Cache; use uv_cache::Cache;
use uv_configuration::PreviewMode; use uv_configuration::PreviewMode;
use uv_fs::Simplified; use uv_fs::Simplified;

View file

@ -1,6 +1,8 @@
use std::fmt::Write;
use anyhow::Result; use anyhow::Result;
use futures::StreamExt; use futures::StreamExt;
use std::fmt::Write;
use uv_cache::Cache; use uv_cache::Cache;
use uv_client::Connectivity; use uv_client::Connectivity;
use uv_configuration::PreviewMode; use uv_configuration::PreviewMode;

View file

@ -1,8 +1,10 @@
use std::collections::BTreeSet;
use std::fmt::Write;
use anyhow::Result; use anyhow::Result;
use futures::StreamExt; use futures::StreamExt;
use itertools::Itertools; use itertools::Itertools;
use std::collections::BTreeSet;
use std::fmt::Write;
use uv_configuration::PreviewMode; use uv_configuration::PreviewMode;
use uv_python::downloads::{self, PythonDownloadRequest}; use uv_python::downloads::{self, PythonDownloadRequest};
use uv_python::managed::ManagedPythonInstallations; use uv_python::managed::ManagedPythonInstallations;

View file

@ -4,6 +4,7 @@ use anyhow::Result;
use axoupdater::{AxoUpdater, AxoupdateError}; use axoupdater::{AxoUpdater, AxoupdateError};
use owo_colors::OwoColorize; use owo_colors::OwoColorize;
use tracing::debug; use tracing::debug;
use uv_client::WrappedReqwestError; use uv_client::WrappedReqwestError;
use crate::commands::ExitStatus; use crate::commands::ExitStatus;

View file

@ -1,5 +1,6 @@
use anyhow::Context; use anyhow::Context;
use owo_colors::OwoColorize; use owo_colors::OwoColorize;
use uv_configuration::PreviewMode; use uv_configuration::PreviewMode;
use uv_fs::Simplified; use uv_fs::Simplified;
use uv_tool::InstalledTools; use uv_tool::InstalledTools;

View file

@ -23,7 +23,7 @@ use uv_python::{
use uv_tool::InstalledTools; use uv_tool::InstalledTools;
use uv_warnings::warn_user_once; use uv_warnings::warn_user_once;
use crate::commands::project::ephemeral::EphemeralEnvironment; use crate::commands::project::environment::CachedEnvironment;
use crate::commands::tool::common::resolve_requirements; use crate::commands::tool::common::resolve_requirements;
use crate::commands::{ExitStatus, SharedState}; use crate::commands::{ExitStatus, SharedState};
use crate::printer::Printer; use crate::printer::Printer;
@ -248,7 +248,7 @@ async fn get_or_create_environment(
// TODO(zanieb): When implementing project-level tools, discover the project and check if it has the tool. // TODO(zanieb): When implementing project-level tools, discover the project and check if it has the tool.
// TODO(zanieb): Determine if we should layer on top of the project environment if it is present. // TODO(zanieb): Determine if we should layer on top of the project environment if it is present.
let environment = EphemeralEnvironment::get_or_create( let environment = CachedEnvironment::get_or_create(
requirements, requirements,
interpreter, interpreter,
settings, settings,

View file

@ -2,8 +2,8 @@ use std::fmt::Write;
use anyhow::{bail, Result}; use anyhow::{bail, Result};
use itertools::Itertools; use itertools::Itertools;
use tracing::debug; use tracing::debug;
use uv_configuration::PreviewMode; use uv_configuration::PreviewMode;
use uv_fs::Simplified; use uv_fs::Simplified;
use uv_normalize::PackageName; use uv_normalize::PackageName;

View file

@ -1,7 +1,8 @@
//! Code for representing uv's release version number. //! Code for representing uv's release version number.
use std::fmt;
// See also <https://github.com/astral-sh/ruff/blob/8118d29419055b779719cc96cdf3dacb29ac47c9/crates/ruff/src/version.rs> // See also <https://github.com/astral-sh/ruff/blob/8118d29419055b779719cc96cdf3dacb29ac47c9/crates/ruff/src/version.rs>
use serde::Serialize; use serde::Serialize;
use std::fmt;
/// Information about the git repository where uv was built from. /// Information about the git repository where uv was built from.
#[derive(Serialize)] #[derive(Serialize)]

View file

@ -1,4 +1,5 @@
use assert_fs::fixture::PathChild; use assert_fs::fixture::PathChild;
use common::{uv_snapshot, TestContext}; use common::{uv_snapshot, TestContext};
mod common; mod common;

View file

@ -1,6 +1,7 @@
#![cfg(all(feature = "python", feature = "pypi"))] #![cfg(all(feature = "python", feature = "pypi"))]
use assert_fs::fixture::PathChild; use assert_fs::fixture::PathChild;
use common::{uv_snapshot, TestContext}; use common::{uv_snapshot, TestContext};
mod common; mod common;

View file

@ -6,10 +6,11 @@ use assert_fs::{
assert::PathAssert, assert::PathAssert,
fixture::{FileTouch, PathChild}, fixture::{FileTouch, PathChild},
}; };
use common::{uv_snapshot, TestContext};
use insta::assert_snapshot; use insta::assert_snapshot;
use predicates::prelude::predicate; use predicates::prelude::predicate;
use common::{uv_snapshot, TestContext};
mod common; mod common;
/// Test installing a tool with `uv tool install` /// Test installing a tool with `uv tool install`

View file

@ -1,11 +1,12 @@
#![cfg(all(feature = "python", feature = "pypi"))] #![cfg(all(feature = "python", feature = "pypi"))]
use fs_err as fs;
use anyhow::Result; use anyhow::Result;
use assert_cmd::assert::OutputAssertExt; use assert_cmd::assert::OutputAssertExt;
use assert_fs::fixture::PathChild; use assert_fs::fixture::PathChild;
use fs_err as fs;
use common::{uv_snapshot, TestContext}; use common::{uv_snapshot, TestContext};
mod common; mod common;
#[test] #[test]

View file

@ -2,6 +2,7 @@
use assert_cmd::assert::OutputAssertExt; use assert_cmd::assert::OutputAssertExt;
use assert_fs::fixture::PathChild; use assert_fs::fixture::PathChild;
use common::{uv_snapshot, TestContext}; use common::{uv_snapshot, TestContext};
mod common; mod common;