From 96c57814a646a92787e312628a2e492492ff12b4 Mon Sep 17 00:00:00 2001 From: Charlie Marsh Date: Thu, 25 Jul 2024 20:19:07 -0400 Subject: [PATCH] Remove pin --- crates/uv-cli/src/lib.rs | 5 +++++ crates/uv/src/commands/python/install.rs | 12 +++++------- crates/uv/src/commands/python/pin.rs | 4 ++-- crates/uv/src/lib.rs | 8 ++------ crates/uv/src/settings.rs | 3 +++ 5 files changed, 17 insertions(+), 15 deletions(-) diff --git a/crates/uv-cli/src/lib.rs b/crates/uv-cli/src/lib.rs index 41cb4fafeb69f..d6159b789abf6 100644 --- a/crates/uv-cli/src/lib.rs +++ b/crates/uv-cli/src/lib.rs @@ -2487,6 +2487,11 @@ pub struct PythonPinArgs { #[arg(long, overrides_with("no_resolved"), hide = true)] pub no_resolved: bool, + + /// Avoid validating the Python pin against the workspace in the current directory or any parent + /// directory. + #[arg(long)] + pub no_workspace: bool, } #[derive(Args)] diff --git a/crates/uv/src/commands/python/install.rs b/crates/uv/src/commands/python/install.rs index b258314f2ed1b..d0ed29de39078 100644 --- a/crates/uv/src/commands/python/install.rs +++ b/crates/uv/src/commands/python/install.rs @@ -8,7 +8,6 @@ use std::collections::BTreeSet; use std::fmt::Write; use std::path::PathBuf; use tracing::debug; -use uv_cache::Cache; use uv_client::Connectivity; use uv_configuration::PreviewMode; use uv_python::downloads::{DownloadResult, ManagedPythonDownload, PythonDownloadRequest}; @@ -30,8 +29,7 @@ pub(crate) async fn install( native_tls: bool, connectivity: Connectivity, preview: PreviewMode, - isolated: bool, - _cache: &Cache, + no_config: bool, printer: Printer, ) -> Result { if preview.is_disabled() { @@ -46,12 +44,12 @@ pub(crate) async fn install( let targets = targets.into_iter().collect::>(); let requests: Vec<_> = if targets.is_empty() { - // Read from the version file, unless `isolated` was requested - let version_file_requests = if isolated { + // Read from the version file, unless `--no-config` was requested + let version_file_requests = if no_config { if PathBuf::from(PYTHON_VERSION_FILENAME).exists() { - debug!("Ignoring `.python-version` file due to isolated mode"); + debug!("Ignoring `.python-version` file due to `--no-config`"); } else if PathBuf::from(PYTHON_VERSIONS_FILENAME).exists() { - debug!("Ignoring `.python-versions` file due to isolated mode"); + debug!("Ignoring `.python-versions` file due to `--no-config`"); } None } else { diff --git a/crates/uv/src/commands/python/pin.rs b/crates/uv/src/commands/python/pin.rs index 8f756a13a801f..dca463e5688c5 100644 --- a/crates/uv/src/commands/python/pin.rs +++ b/crates/uv/src/commands/python/pin.rs @@ -25,7 +25,7 @@ pub(crate) async fn pin( resolved: bool, python_preference: PythonPreference, preview: PreviewMode, - isolated: bool, + no_workspace: bool, cache: &Cache, printer: Printer, ) -> Result { @@ -33,7 +33,7 @@ pub(crate) async fn pin( warn_user_once!("`uv python pin` is experimental and may change without warning"); } - let virtual_project = if isolated { + let virtual_project = if no_workspace { None } else { match VirtualProject::discover(&std::env::current_dir()?, &DiscoveryOptions::default()) diff --git a/crates/uv/src/lib.rs b/crates/uv/src/lib.rs index cc3f65898df94..3746d87ed878b 100644 --- a/crates/uv/src/lib.rs +++ b/crates/uv/src/lib.rs @@ -769,17 +769,13 @@ async fn run(cli: Cli) -> Result { let args = settings::PythonInstallSettings::resolve(args, filesystem); show_settings!(args); - // Initialize the cache. - let cache = cache.init()?; - commands::python_install( args.targets, args.reinstall, globals.native_tls, globals.connectivity, globals.preview, - globals.isolated, - &cache, + cli.no_config || globals.isolated, printer, ) .await @@ -825,7 +821,7 @@ async fn run(cli: Cli) -> Result { args.resolved, globals.python_preference, globals.preview, - globals.isolated, + args.no_workspace || globals.isolated, &cache, printer, ) diff --git a/crates/uv/src/settings.rs b/crates/uv/src/settings.rs index 4fcc19b28931f..72b90fe7cf0de 100644 --- a/crates/uv/src/settings.rs +++ b/crates/uv/src/settings.rs @@ -503,6 +503,7 @@ impl PythonFindSettings { pub(crate) struct PythonPinSettings { pub(crate) request: Option, pub(crate) resolved: bool, + pub(crate) no_workspace: bool, } impl PythonPinSettings { @@ -513,11 +514,13 @@ impl PythonPinSettings { request, no_resolved, resolved, + no_workspace, } = args; Self { request, resolved: flag(resolved, no_resolved).unwrap_or(false), + no_workspace, } } }