From ce5df77ecbf024b954a20ddbad59808d3f42705e Mon Sep 17 00:00:00 2001 From: Charlie Marsh Date: Thu, 28 Mar 2024 17:08:16 -0400 Subject: [PATCH] Add `UV_RESOLUTION` environment variable for `--resolution` (#2720) Closes https://github.com/astral-sh/uv/issues/2710. --- README.md | 6 ++++-- crates/uv/src/main.rs | 4 ++-- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/README.md b/README.md index f2bc5c579..8bba8c9fb 100644 --- a/README.md +++ b/README.md @@ -439,8 +439,10 @@ uv accepts the following command-line arguments as environment variables: directory for caching instead of the default cache directory. - `UV_NO_CACHE`: Equivalent to the `--no-cache` command-line argument. If set, uv will not use the cache for any operations. -- `UV_PRERELEASE`: Equivalent to the `--prerelease` command-line argument. If set to `allow`, uv - will allow pre-release versions for all dependencies. +- `UV_RESOLUTION`: Equivalent to the `--resolution` command-line argument. For example, if set to + `lowest-direct`, uv will install the lowest compatible versions of all direct dependencies. +- `UV_PRERELEASE`: Equivalent to the `--prerelease` command-line argument. For example, if set to + `allow`, uv will allow pre-release versions for all dependencies. - `UV_SYSTEM_PYTHON`: Equivalent to the `--system` command-line argument. If set to `true`, uv will use the first Python interpreter found in the system `PATH`. WARNING: `UV_SYSTEM_PYTHON=true` is intended for use in continuous integration (CI) environments and diff --git a/crates/uv/src/main.rs b/crates/uv/src/main.rs index 9d33b19ef..cc9e3477a 100644 --- a/crates/uv/src/main.rs +++ b/crates/uv/src/main.rs @@ -306,7 +306,7 @@ struct PipCompileArgs { #[clap(long)] no_deps: bool, - #[clap(long, value_enum, default_value_t = ResolutionMode::default())] + #[clap(long, value_enum, default_value_t = ResolutionMode::default(), env = "UV_RESOLUTION")] resolution: ResolutionMode, #[clap(long, value_enum, default_value_t = PreReleaseMode::default(), conflicts_with = "pre", env = "UV_PRERELEASE")] @@ -781,7 +781,7 @@ struct PipInstallArgs { #[clap(long, value_enum, default_value_t = install_wheel_rs::linker::LinkMode::default())] link_mode: install_wheel_rs::linker::LinkMode, - #[clap(long, value_enum, default_value_t = ResolutionMode::default())] + #[clap(long, value_enum, default_value_t = ResolutionMode::default(), env = "UV_RESOLUTION")] resolution: ResolutionMode, #[clap(long, value_enum, default_value_t = PreReleaseMode::default(), conflicts_with = "pre", env = "UV_PRERELEASE")]