From 52771476f4d24e530f58aa2001f6532eea2f2fca Mon Sep 17 00:00:00 2001 From: konsti Date: Wed, 6 Aug 2025 15:06:49 +0200 Subject: [PATCH] Support `UV_NO_EDITABLE` where `--no-editable` is supported (#15107) Specifically, support `UV_NO_EDITABLE=1 uv export`. It's now also supported in `uv add`, though it's default there anyway and the env var exists only for completeness. Fixes #15103 --- crates/uv-cli/src/lib.rs | 4 ++-- crates/uv-static/src/env_vars.rs | 4 ++-- crates/uv/tests/it/export.rs | 32 ++++++++++++++++++++++++++++++++ docs/reference/cli.md | 2 +- docs/reference/environment.md | 4 ++-- 5 files changed, 39 insertions(+), 7 deletions(-) diff --git a/crates/uv-cli/src/lib.rs b/crates/uv-cli/src/lib.rs index 6bea81e84..f436f41ba 100644 --- a/crates/uv-cli/src/lib.rs +++ b/crates/uv-cli/src/lib.rs @@ -3662,7 +3662,7 @@ pub struct AddArgs { #[arg(long, overrides_with = "no_editable")] pub editable: bool, - #[arg(long, overrides_with = "editable", hide = true)] + #[arg(long, overrides_with = "editable", hide = true, value_parser = clap::builder::BoolishValueParser::new(), env = EnvVars::UV_NO_EDITABLE)] pub no_editable: bool, /// Add a dependency as provided. @@ -4164,7 +4164,7 @@ pub struct ExportArgs { /// Export any editable dependencies, including the project and any workspace members, as /// non-editable. - #[arg(long)] + #[arg(long, value_parser = clap::builder::BoolishValueParser::new(), env = EnvVars::UV_NO_EDITABLE)] pub no_editable: bool, /// Include hashes for all dependencies. diff --git a/crates/uv-static/src/env_vars.rs b/crates/uv-static/src/env_vars.rs index 5032d42b6..4649b9f21 100644 --- a/crates/uv-static/src/env_vars.rs +++ b/crates/uv-static/src/env_vars.rs @@ -166,8 +166,8 @@ impl EnvVars { pub const UV_COMPILE_BYTECODE_TIMEOUT: &'static str = "UV_COMPILE_BYTECODE_TIMEOUT"; /// Equivalent to the `--no-editable` command-line argument. If set, uv - /// installs any editable dependencies, including the project and any workspace members, as - /// non-editable + /// installs or exports any editable dependencies, including the project and any workspace + /// members, as non-editable. pub const UV_NO_EDITABLE: &'static str = "UV_NO_EDITABLE"; /// Equivalent to the `--no-binary` command-line argument. If set, uv will install diff --git a/crates/uv/tests/it/export.rs b/crates/uv/tests/it/export.rs index fde3e7e1f..45dbabf86 100644 --- a/crates/uv/tests/it/export.rs +++ b/crates/uv/tests/it/export.rs @@ -12,6 +12,7 @@ use insta::assert_snapshot; use std::path::Path; use std::process::Stdio; use uv_fs::Simplified; +use uv_static::EnvVars; #[test] fn requirements_txt_dependency() -> Result<()> { @@ -4433,3 +4434,34 @@ fn pep_751_https_credentials() -> Result<()> { Ok(()) } + +/// Support `UV_NO_EDITABLE=1 uv export`. +/// +/// +#[test] +fn no_editable_env_var() -> Result<()> { + let context = TestContext::new("3.12"); + + context + .init() + .arg("--lib") + .arg("--name") + .arg("project") + .arg(".") + .assert() + .success(); + + uv_snapshot!(context.filters(), context.export().env(EnvVars::UV_NO_EDITABLE, "1"), @r" + success: true + exit_code: 0 + ----- stdout ----- + # This file was autogenerated by uv via the following command: + # uv export --cache-dir [CACHE_DIR] + . + + ----- stderr ----- + Resolved 1 package in [TIME] + "); + + Ok(()) +} diff --git a/docs/reference/cli.md b/docs/reference/cli.md index 01b5184c8..f75f629d2 100644 --- a/docs/reference/cli.md +++ b/docs/reference/cli.md @@ -1531,7 +1531,7 @@ uv export [OPTIONS]
--no-dev

Disable the development dependency group.

This option is an alias of --no-group dev. See --no-default-groups to disable all default groups instead.

--no-editable

Export any editable dependencies, including the project and any workspace members, as non-editable

-
--no-emit-package, --no-install-package no-emit-package

Do not emit the given package(s).

+

May also be set with the UV_NO_EDITABLE environment variable.

--no-emit-package, --no-install-package no-emit-package

Do not emit the given package(s).

By default, all of the project's dependencies are included in the exported requirements file. The --no-emit-package option allows exclusion of specific packages.

--no-emit-project, --no-install-project

Do not emit the current project.

By default, the current project is included in the exported requirements file with all of its dependencies. The --no-emit-project option allows the project to be excluded, but all of its dependencies to remain included.

diff --git a/docs/reference/environment.md b/docs/reference/environment.md index a7c1b530d..50083d99e 100644 --- a/docs/reference/environment.md +++ b/docs/reference/environment.md @@ -252,8 +252,8 @@ directories. ### `UV_NO_EDITABLE` Equivalent to the `--no-editable` command-line argument. If set, uv -installs any editable dependencies, including the project and any workspace members, as -non-editable +installs or exports any editable dependencies, including the project and any workspace +members, as non-editable. ### `UV_NO_ENV_FILE`