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
This commit is contained in:
@@ -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.
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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`.
|
||||
///
|
||||
/// <https://github.com/astral-sh/uv/issues/15103>
|
||||
#[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(())
|
||||
}
|
||||
|
||||
@@ -1531,7 +1531,7 @@ uv export [OPTIONS]
|
||||
</dd><dt id="uv-export--no-dev"><a href="#uv-export--no-dev"><code>--no-dev</code></a></dt><dd><p>Disable the development dependency group.</p>
|
||||
<p>This option is an alias of <code>--no-group dev</code>. See <code>--no-default-groups</code> to disable all default groups instead.</p>
|
||||
</dd><dt id="uv-export--no-editable"><a href="#uv-export--no-editable"><code>--no-editable</code></a></dt><dd><p>Export any editable dependencies, including the project and any workspace members, as non-editable</p>
|
||||
</dd><dt id="uv-export--no-emit-package"><a href="#uv-export--no-emit-package"><code>--no-emit-package</code></a>, <code>--no-install-package</code> <i>no-emit-package</i></dt><dd><p>Do not emit the given package(s).</p>
|
||||
<p>May also be set with the <code>UV_NO_EDITABLE</code> environment variable.</p></dd><dt id="uv-export--no-emit-package"><a href="#uv-export--no-emit-package"><code>--no-emit-package</code></a>, <code>--no-install-package</code> <i>no-emit-package</i></dt><dd><p>Do not emit the given package(s).</p>
|
||||
<p>By default, all of the project's dependencies are included in the exported requirements file. The <code>--no-emit-package</code> option allows exclusion of specific packages.</p>
|
||||
</dd><dt id="uv-export--no-emit-project"><a href="#uv-export--no-emit-project"><code>--no-emit-project</code></a>, <code>--no-install-project</code></dt><dd><p>Do not emit the current project.</p>
|
||||
<p>By default, the current project is included in the exported requirements file with all of its dependencies. The <code>--no-emit-project</code> option allows the project to be excluded, but all of its dependencies to remain included.</p>
|
||||
|
||||
@@ -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`
|
||||
|
||||
|
||||
Reference in New Issue
Block a user