From 0d21ff8b5f2b00a1c62cd667a2217a23c1ffe0f5 Mon Sep 17 00:00:00 2001 From: Zanie Blue Date: Thu, 8 Aug 2024 13:32:00 -0500 Subject: [PATCH] Deprecate `--system` and `--no-system` in `uv venv` (#5925) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit e.g. ``` ❯ cargo run -- venv --no-system Blocking waiting for file lock on build directory Compiling uv v0.2.34 (/Users/zb/workspace/uv/crates/uv) Finished `dev` profile [unoptimized + debuginfo] target(s) in 19.85s Running `target/debug/uv venv --no-system` warning: The `--no-system` flag has no effect, a system Python interpreter is always used in `uv venv` Using Python 3.12.4 interpreter at: /opt/homebrew/opt/python@3.12/bin/python3.12 Creating virtualenv at: .venv Activate with: source .venv/bin/activate ❯ cargo run -- venv --system Finished `dev` profile [unoptimized + debuginfo] target(s) in 0.15s Running `target/debug/uv venv --system` warning: The `--system` flag has no effect, a system Python interpreter is always used in `uv venv` Using Python 3.12.4 interpreter at: /opt/homebrew/opt/python@3.12/bin/python3.12 Creating virtualenv at: .venv Activate with: source .venv/bin/activate ``` --- crates/uv-cli/src/lib.rs | 11 +++++++++-- crates/uv/src/lib.rs | 10 +++++++++- 2 files changed, 18 insertions(+), 3 deletions(-) diff --git a/crates/uv-cli/src/lib.rs b/crates/uv-cli/src/lib.rs index 5758f20ed..65ac2ad0a 100644 --- a/crates/uv-cli/src/lib.rs +++ b/crates/uv-cli/src/lib.rs @@ -1837,15 +1837,22 @@ pub struct VenvArgs { )] pub python: Option, - // TODO(zanieb): Hide me, I do nothing. + /// Ignore virtual environments when searching for the Python interpreter. + /// + /// This is the default behavior and has no effect. #[arg( long, env = "UV_SYSTEM_PYTHON", value_parser = clap::builder::BoolishValueParser::new(), - overrides_with("no_system") + overrides_with("no_system"), + hide = true, )] pub system: bool, + /// This flag is included for compatibility only, it has no effect. + /// + /// uv will never search for interpreters in virtual environments when + /// creating a virtual environment. #[arg(long, overrides_with("system"), hide = true)] pub no_system: bool, diff --git a/crates/uv/src/lib.rs b/crates/uv/src/lib.rs index 499b1bbd0..1a3bc3783 100644 --- a/crates/uv/src/lib.rs +++ b/crates/uv/src/lib.rs @@ -24,7 +24,7 @@ use uv_configuration::Concurrency; use uv_fs::CWD; use uv_requirements::RequirementsSource; use uv_settings::{Combine, FilesystemOptions}; -use uv_warnings::warn_user; +use uv_warnings::{warn_user, warn_user_once}; use uv_workspace::{DiscoveryOptions, Workspace}; use crate::commands::{ExitStatus, ToolRunCommand}; @@ -630,6 +630,14 @@ async fn run(cli: Cli) -> Result { Commands::Venv(args) => { args.compat_args.validate()?; + if args.no_system { + warn_user_once!("The `--no-system` flag has no effect, a system Python interpreter is always used in `uv venv`"); + } + + if args.system { + warn_user_once!("The `--system` flag has no effect, a system Python interpreter is always used in `uv venv`"); + } + // Resolve the settings from the command-line arguments and workspace configuration. let args = settings::VenvSettings::resolve(args, filesystem); show_settings!(args);