Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support for UV_FROZEN and UV_LOCKED #8340

Merged
merged 1 commit into from
Oct 18, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 14 additions & 14 deletions crates/uv-cli/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2683,7 +2683,7 @@ pub struct RunArgs {
///
/// Requires that the lockfile is up-to-date. If the lockfile is missing or
/// needs to be updated, uv will exit with an error.
#[arg(long, conflicts_with = "frozen")]
#[arg(long, env = EnvVars::UV_LOCKED, value_parser = clap::builder::BoolishValueParser::new(), conflicts_with = "frozen")]
pub locked: bool,

/// Run without updating the `uv.lock` file.
Expand All @@ -2693,7 +2693,7 @@ pub struct RunArgs {
/// exit with an error. If the `pyproject.toml` includes changes to
/// dependencies that have not been included in the lockfile yet, they will
/// not be present in the environment.
#[arg(long, conflicts_with = "locked")]
#[arg(long, env = EnvVars::UV_FROZEN, value_parser = clap::builder::BoolishValueParser::new(), conflicts_with = "locked")]
pub frozen: bool,

/// Run the given path as a Python script.
Expand Down Expand Up @@ -2836,7 +2836,7 @@ pub struct SyncArgs {
///
/// Requires that the lockfile is up-to-date. If the lockfile is missing or
/// needs to be updated, uv will exit with an error.
#[arg(long, conflicts_with = "frozen")]
#[arg(long, env = EnvVars::UV_LOCKED, value_parser = clap::builder::BoolishValueParser::new(), conflicts_with = "frozen")]
pub locked: bool,

/// Sync without updating the `uv.lock` file.
Expand All @@ -2846,7 +2846,7 @@ pub struct SyncArgs {
/// exit with an error. If the `pyproject.toml` includes changes to dependencies
/// that have not been included in the lockfile yet, they will not be
/// present in the environment.
#[arg(long, conflicts_with = "locked")]
#[arg(long, env = EnvVars::UV_FROZEN, value_parser = clap::builder::BoolishValueParser::new(), conflicts_with = "locked")]
pub frozen: bool,

#[command(flatten)]
Expand Down Expand Up @@ -2896,11 +2896,11 @@ pub struct LockArgs {
///
/// Requires that the lockfile is up-to-date. If the lockfile is missing or
/// needs to be updated, uv will exit with an error.
#[arg(long, conflicts_with = "frozen")]
#[arg(long, env = EnvVars::UV_LOCKED, value_parser = clap::builder::BoolishValueParser::new(), conflicts_with = "frozen")]
pub locked: bool,

/// Assert that a `uv.lock` exists, without updating it.
#[arg(long, conflicts_with = "locked")]
#[arg(long, env = EnvVars::UV_FROZEN, value_parser = clap::builder::BoolishValueParser::new(), conflicts_with = "locked")]
pub frozen: bool,

#[command(flatten)]
Expand Down Expand Up @@ -3009,13 +3009,13 @@ pub struct AddArgs {
///
/// Requires that the lockfile is up-to-date. If the lockfile is missing or
/// needs to be updated, uv will exit with an error.
#[arg(long, conflicts_with = "frozen")]
#[arg(long, env = EnvVars::UV_LOCKED, value_parser = clap::builder::BoolishValueParser::new(), conflicts_with = "frozen")]
pub locked: bool,

/// Add dependencies without re-locking the project.
///
/// The project environment will not be synced.
#[arg(long, conflicts_with = "locked")]
#[arg(long, env = EnvVars::UV_FROZEN, value_parser = clap::builder::BoolishValueParser::new(), conflicts_with = "locked")]
pub frozen: bool,

#[command(flatten)]
Expand Down Expand Up @@ -3079,13 +3079,13 @@ pub struct RemoveArgs {
///
/// Requires that the lockfile is up-to-date. If the lockfile is missing or
/// needs to be updated, uv will exit with an error.
#[arg(long, conflicts_with = "frozen")]
#[arg(long, env = EnvVars::UV_LOCKED, value_parser = clap::builder::BoolishValueParser::new(), conflicts_with = "frozen")]
pub locked: bool,

/// Remove dependencies without re-locking the project.
///
/// The project environment will not be synced.
#[arg(long, conflicts_with = "locked")]
#[arg(long, env = EnvVars::UV_FROZEN, value_parser = clap::builder::BoolishValueParser::new(), conflicts_with = "locked")]
pub frozen: bool,

#[command(flatten)]
Expand Down Expand Up @@ -3154,13 +3154,13 @@ pub struct TreeArgs {
///
/// Requires that the lockfile is up-to-date. If the lockfile is missing or
/// needs to be updated, uv will exit with an error.
#[arg(long, conflicts_with = "frozen")]
#[arg(long, env = EnvVars::UV_LOCKED, value_parser = clap::builder::BoolishValueParser::new(), conflicts_with = "frozen")]
pub locked: bool,

/// Display the requirements without locking the project.
///
/// If the lockfile is missing, uv will exit with an error.
#[arg(long, conflicts_with = "locked")]
#[arg(long, env = EnvVars::UV_FROZEN, value_parser = clap::builder::BoolishValueParser::new(), conflicts_with = "locked")]
pub frozen: bool,

#[command(flatten)]
Expand Down Expand Up @@ -3302,13 +3302,13 @@ pub struct ExportArgs {
///
/// Requires that the lockfile is up-to-date. If the lockfile is missing or
/// needs to be updated, uv will exit with an error.
#[arg(long, conflicts_with = "frozen")]
#[arg(long, env = EnvVars::UV_LOCKED, value_parser = clap::builder::BoolishValueParser::new(), conflicts_with = "frozen")]
pub locked: bool,

/// Do not update the `uv.lock` before exporting.
///
/// If a `uv.lock` does not exist, uv will exit with an error.
#[arg(long, conflicts_with = "locked")]
#[arg(long, env = EnvVars::UV_FROZEN, value_parser = clap::builder::BoolishValueParser::new(), conflicts_with = "locked")]
pub frozen: bool,

#[command(flatten)]
Expand Down
6 changes: 6 additions & 0 deletions crates/uv-static/src/env_vars.rs
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,12 @@ impl EnvVars {
/// Equivalent to the `--no-sync` argument. Skips syncing the environment.
pub const UV_NO_SYNC: &'static str = "UV_NO_SYNC";

/// Equivalent to the `--locked` argument. Assert that the `uv.lock` will remain unchanged.
pub const UV_LOCKED: &'static str = "UV_LOCKED";

/// Equivalent to the `--frozen` argument. Run without updating the `uv.lock` file.
pub const UV_FROZEN: &'static str = "UV_FROZEN";

/// Equivalent to the `--preview` argument. Enables preview mode.
pub const UV_PREVIEW: &'static str = "UV_PREVIEW";

Expand Down
4 changes: 4 additions & 0 deletions docs/configuration/environment.md
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,10 @@ uv accepts the following command-line arguments as environment variables:
set, uv will use this password for publishing.
- `UV_NO_SYNC`: Equivalent to the `--no-sync` command-line argument. If set, uv will skip updating
the environment.
- `UV_LOCKED`: Equivalent to the `--locked` command-line argument. If set, uv will assert that the
`uv.lock` remains unchanged.
- `UV_FROZEN`: Equivalent to the `--frozen` command-line argument. If set, uv will run without
updating the `uv.lock` file.

In each case, the corresponding command-line argument takes precedence over an environment variable.

Expand Down
14 changes: 14 additions & 0 deletions docs/reference/cli.md
Original file line number Diff line number Diff line change
Expand Up @@ -160,6 +160,7 @@ uv run [OPTIONS] [COMMAND]

<p>Instead of checking if the lockfile is up-to-date, uses the versions in the lockfile as the source of truth. If the lockfile is missing, uv will exit with an error. If the <code>pyproject.toml</code> includes changes to dependencies that have not been included in the lockfile yet, they will not be present in the environment.</p>

<p>May also be set with the <code>UV_FROZEN</code> environment variable.</p>
</dd><dt><code>--help</code>, <code>-h</code></dt><dd><p>Display the concise help for this command</p>

</dd><dt><code>--index</code> <i>index</i></dt><dd><p>The URLs to use when resolving dependencies, in addition to the default index.</p>
Expand Down Expand Up @@ -232,6 +233,7 @@ uv run [OPTIONS] [COMMAND]

<p>Requires that the lockfile is up-to-date. If the lockfile is missing or needs to be updated, uv will exit with an error.</p>

<p>May also be set with the <code>UV_LOCKED</code> environment variable.</p>
</dd><dt><code>--module</code>, <code>-m</code></dt><dd><p>Run a Python module.</p>

<p>Equivalent to <code>python -m &lt;module&gt;</code>.</p>
Expand Down Expand Up @@ -749,6 +751,7 @@ uv add [OPTIONS] <PACKAGES|--requirements <REQUIREMENTS>>

<p>The project environment will not be synced.</p>

<p>May also be set with the <code>UV_FROZEN</code> environment variable.</p>
</dd><dt><code>--help</code>, <code>-h</code></dt><dd><p>Display the concise help for this command</p>

</dd><dt><code>--index</code> <i>index</i></dt><dd><p>The URLs to use when resolving dependencies, in addition to the default index.</p>
Expand Down Expand Up @@ -813,6 +816,7 @@ uv add [OPTIONS] <PACKAGES|--requirements <REQUIREMENTS>>

<p>Requires that the lockfile is up-to-date. If the lockfile is missing or needs to be updated, uv will exit with an error.</p>

<p>May also be set with the <code>UV_LOCKED</code> environment variable.</p>
</dd><dt><code>--native-tls</code></dt><dd><p>Whether to load TLS certificates from the platform&#8217;s native certificate store.</p>

<p>By default, uv loads certificates from the bundled <code>webpki-roots</code> crate. The <code>webpki-roots</code> are a reliable set of trust roots from Mozilla, and including them in uv improves portability and performance (especially on macOS).</p>
Expand Down Expand Up @@ -1081,6 +1085,7 @@ uv remove [OPTIONS] <PACKAGES>...

<p>The project environment will not be synced.</p>

<p>May also be set with the <code>UV_FROZEN</code> environment variable.</p>
</dd><dt><code>--help</code>, <code>-h</code></dt><dd><p>Display the concise help for this command</p>

</dd><dt><code>--index</code> <i>index</i></dt><dd><p>The URLs to use when resolving dependencies, in addition to the default index.</p>
Expand Down Expand Up @@ -1145,6 +1150,7 @@ uv remove [OPTIONS] <PACKAGES>...

<p>Requires that the lockfile is up-to-date. If the lockfile is missing or needs to be updated, uv will exit with an error.</p>

<p>May also be set with the <code>UV_LOCKED</code> environment variable.</p>
</dd><dt><code>--native-tls</code></dt><dd><p>Whether to load TLS certificates from the platform&#8217;s native certificate store.</p>

<p>By default, uv loads certificates from the bundled <code>webpki-roots</code> crate. The <code>webpki-roots</code> are a reliable set of trust roots from Mozilla, and including them in uv improves portability and performance (especially on macOS).</p>
Expand Down Expand Up @@ -1401,6 +1407,7 @@ uv sync [OPTIONS]

<p>Instead of checking if the lockfile is up-to-date, uses the versions in the lockfile as the source of truth. If the lockfile is missing, uv will exit with an error. If the <code>pyproject.toml</code> includes changes to dependencies that have not been included in the lockfile yet, they will not be present in the environment.</p>

<p>May also be set with the <code>UV_FROZEN</code> environment variable.</p>
</dd><dt><code>--help</code>, <code>-h</code></dt><dd><p>Display the concise help for this command</p>

</dd><dt><code>--index</code> <i>index</i></dt><dd><p>The URLs to use when resolving dependencies, in addition to the default index.</p>
Expand Down Expand Up @@ -1469,6 +1476,7 @@ uv sync [OPTIONS]

<p>Requires that the lockfile is up-to-date. If the lockfile is missing or needs to be updated, uv will exit with an error.</p>

<p>May also be set with the <code>UV_LOCKED</code> environment variable.</p>
</dd><dt><code>--native-tls</code></dt><dd><p>Whether to load TLS certificates from the platform&#8217;s native certificate store.</p>

<p>By default, uv loads certificates from the bundled <code>webpki-roots</code> crate. The <code>webpki-roots</code> are a reliable set of trust roots from Mozilla, and including them in uv improves portability and performance (especially on macOS).</p>
Expand Down Expand Up @@ -1717,6 +1725,7 @@ uv lock [OPTIONS]
<p>May also be set with the <code>UV_FIND_LINKS</code> environment variable.</p>
</dd><dt><code>--frozen</code></dt><dd><p>Assert that a <code>uv.lock</code> exists, without updating it</p>

<p>May also be set with the <code>UV_FROZEN</code> environment variable.</p>
</dd><dt><code>--help</code>, <code>-h</code></dt><dd><p>Display the concise help for this command</p>

</dd><dt><code>--index</code> <i>index</i></dt><dd><p>The URLs to use when resolving dependencies, in addition to the default index.</p>
Expand Down Expand Up @@ -1783,6 +1792,7 @@ uv lock [OPTIONS]

<p>Requires that the lockfile is up-to-date. If the lockfile is missing or needs to be updated, uv will exit with an error.</p>

<p>May also be set with the <code>UV_LOCKED</code> environment variable.</p>
</dd><dt><code>--native-tls</code></dt><dd><p>Whether to load TLS certificates from the platform&#8217;s native certificate store.</p>

<p>By default, uv loads certificates from the bundled <code>webpki-roots</code> crate. The <code>webpki-roots</code> are a reliable set of trust roots from Mozilla, and including them in uv improves portability and performance (especially on macOS).</p>
Expand Down Expand Up @@ -2023,6 +2033,7 @@ uv export [OPTIONS]

<p>If a <code>uv.lock</code> does not exist, uv will exit with an error.</p>

<p>May also be set with the <code>UV_FROZEN</code> environment variable.</p>
</dd><dt><code>--help</code>, <code>-h</code></dt><dd><p>Display the concise help for this command</p>

</dd><dt><code>--index</code> <i>index</i></dt><dd><p>The URLs to use when resolving dependencies, in addition to the default index.</p>
Expand Down Expand Up @@ -2089,6 +2100,7 @@ uv export [OPTIONS]

<p>Requires that the lockfile is up-to-date. If the lockfile is missing or needs to be updated, uv will exit with an error.</p>

<p>May also be set with the <code>UV_LOCKED</code> environment variable.</p>
</dd><dt><code>--native-tls</code></dt><dd><p>Whether to load TLS certificates from the platform&#8217;s native certificate store.</p>

<p>By default, uv loads certificates from the bundled <code>webpki-roots</code> crate. The <code>webpki-roots</code> are a reliable set of trust roots from Mozilla, and including them in uv improves portability and performance (especially on macOS).</p>
Expand Down Expand Up @@ -2338,6 +2350,7 @@ uv tree [OPTIONS]

<p>If the lockfile is missing, uv will exit with an error.</p>

<p>May also be set with the <code>UV_FROZEN</code> environment variable.</p>
</dd><dt><code>--help</code>, <code>-h</code></dt><dd><p>Display the concise help for this command</p>

</dd><dt><code>--index</code> <i>index</i></dt><dd><p>The URLs to use when resolving dependencies, in addition to the default index.</p>
Expand Down Expand Up @@ -2406,6 +2419,7 @@ uv tree [OPTIONS]

<p>Requires that the lockfile is up-to-date. If the lockfile is missing or needs to be updated, uv will exit with an error.</p>

<p>May also be set with the <code>UV_LOCKED</code> environment variable.</p>
</dd><dt><code>--native-tls</code></dt><dd><p>Whether to load TLS certificates from the platform&#8217;s native certificate store.</p>

<p>By default, uv loads certificates from the bundled <code>webpki-roots</code> crate. The <code>webpki-roots</code> are a reliable set of trust roots from Mozilla, and including them in uv improves portability and performance (especially on macOS).</p>
Expand Down
Loading