diff --git a/crates/uv-cli/src/lib.rs b/crates/uv-cli/src/lib.rs index 3e45ed876d2f..7ca64ca27313 100644 --- a/crates/uv-cli/src/lib.rs +++ b/crates/uv-cli/src/lib.rs @@ -319,7 +319,7 @@ pub struct GlobalArgs { /// See `--directory` to change the working directory entirely. /// /// This setting has no effect when used in the `uv pip` interface. - #[arg(global = true, long)] + #[arg(global = true, long, env = EnvVars::UV_PROJECT)] pub project: Option, } diff --git a/crates/uv-static/src/env_vars.rs b/crates/uv-static/src/env_vars.rs index d22f59dc1141..3e5781ea9c7e 100644 --- a/crates/uv-static/src/env_vars.rs +++ b/crates/uv-static/src/env_vars.rs @@ -685,4 +685,7 @@ impl EnvVars { /// Equivalent to the `--torch-backend` command-line argument (e.g., `cpu`, `cu126`, or `auto`). pub const UV_TORCH_BACKEND: &'static str = "UV_TORCH_BACKEND"; + + /// Equivalent to the `--project` command-line argument. + pub const UV_PROJECT: &'static str = "UV_PROJECT"; } diff --git a/crates/uv/tests/it/help.rs b/crates/uv/tests/it/help.rs index a7f9f428cd68..f8a6bc539230 100644 --- a/crates/uv/tests/it/help.rs +++ b/crates/uv/tests/it/help.rs @@ -66,7 +66,7 @@ fn help() { --directory Change to the given directory prior to running the command --project - Run the command within the given project directory + Run the command within the given project directory [env: UV_PROJECT=] --config-file The path to a `uv.toml` file to use for configuration [env: UV_CONFIG_FILE=] --no-config @@ -145,7 +145,7 @@ fn help_flag() { --directory Change to the given directory prior to running the command --project - Run the command within the given project directory + Run the command within the given project directory [env: UV_PROJECT=] --config-file The path to a `uv.toml` file to use for configuration [env: UV_CONFIG_FILE=] --no-config @@ -223,7 +223,7 @@ fn help_short_flag() { --directory Change to the given directory prior to running the command --project - Run the command within the given project directory + Run the command within the given project directory [env: UV_PROJECT=] --config-file The path to a `uv.toml` file to use for configuration [env: UV_CONFIG_FILE=] --no-config @@ -419,6 +419,8 @@ fn help_subcommand() { See `--directory` to change the working directory entirely. This setting has no effect when used in the `uv pip` interface. + + [env: UV_PROJECT=] --config-file The path to a `uv.toml` file to use for configuration. @@ -670,6 +672,8 @@ fn help_subsubcommand() { See `--directory` to change the working directory entirely. This setting has no effect when used in the `uv pip` interface. + + [env: UV_PROJECT=] --config-file The path to a `uv.toml` file to use for configuration. @@ -748,7 +752,7 @@ fn help_flag_subcommand() { --directory Change to the given directory prior to running the command --project - Run the command within the given project directory + Run the command within the given project directory [env: UV_PROJECT=] --config-file The path to a `uv.toml` file to use for configuration [env: UV_CONFIG_FILE=] --no-config @@ -820,7 +824,7 @@ fn help_flag_subsubcommand() { --directory Change to the given directory prior to running the command --project - Run the command within the given project directory + Run the command within the given project directory [env: UV_PROJECT=] --config-file The path to a `uv.toml` file to use for configuration [env: UV_CONFIG_FILE=] --no-config @@ -976,7 +980,7 @@ fn help_with_global_option() { --directory Change to the given directory prior to running the command --project - Run the command within the given project directory + Run the command within the given project directory [env: UV_PROJECT=] --config-file The path to a `uv.toml` file to use for configuration [env: UV_CONFIG_FILE=] --no-config @@ -1091,7 +1095,7 @@ fn help_with_no_pager() { --directory Change to the given directory prior to running the command --project - Run the command within the given project directory + Run the command within the given project directory [env: UV_PROJECT=] --config-file The path to a `uv.toml` file to use for configuration [env: UV_CONFIG_FILE=] --no-config diff --git a/docs/configuration/environment.md b/docs/configuration/environment.md index 36afd8fc90aa..397b99d00e9d 100644 --- a/docs/configuration/environment.md +++ b/docs/configuration/environment.md @@ -274,6 +274,10 @@ Equivalent to the `--prerelease` command-line argument. For example, if set to Equivalent to the `--preview` argument. Enables preview mode. +### `UV_PROJECT` + +Equivalent to the `--project` command-line argument. + ### `UV_PROJECT_ENVIRONMENT` Specifies the path to the directory to use for a project virtual environment. diff --git a/docs/reference/cli.md b/docs/reference/cli.md index ffa9f213f7f6..497b432bad12 100644 --- a/docs/reference/cli.md +++ b/docs/reference/cli.md @@ -434,6 +434,7 @@ uv run [OPTIONS] [COMMAND]

This setting has no effect when used in the uv pip interface.

+

May also be set with the UV_PROJECT environment variable.

--python, -p python

The Python interpreter to use for the run environment.

If the interpreter request is satisfied by a discovered environment, the environment will be used.

@@ -696,6 +697,7 @@ uv init [OPTIONS] [PATH]

This setting has no effect when used in the uv pip interface.

+

May also be set with the UV_PROJECT environment variable.

--python, -p python

The Python interpreter to use to determine the minimum supported Python version.

See uv python to view supported request formats.

@@ -1057,6 +1059,7 @@ uv add [OPTIONS] >

This setting has no effect when used in the uv pip interface.

+

May also be set with the UV_PROJECT environment variable.

--python, -p python

The Python interpreter to use for resolving and syncing.

See uv python for details on Python discovery and supported request formats.

@@ -1414,6 +1417,7 @@ uv remove [OPTIONS] ...

This setting has no effect when used in the uv pip interface.

+

May also be set with the UV_PROJECT environment variable.

--python, -p python

The Python interpreter to use for resolving and syncing.

See uv python for details on Python discovery and supported request formats.

@@ -1834,6 +1838,7 @@ uv sync [OPTIONS]

This setting has no effect when used in the uv pip interface.

+

May also be set with the UV_PROJECT environment variable.

--python, -p python

The Python interpreter to use for the project environment.

By default, the first interpreter that meets the project’s requires-python constraint is used.

@@ -2155,6 +2160,7 @@ uv lock [OPTIONS]

This setting has no effect when used in the uv pip interface.

+

May also be set with the UV_PROJECT environment variable.

--python, -p python

The Python interpreter to use during resolution.

A Python interpreter is required for building source distributions to determine package metadata when there are not wheels.

@@ -2556,6 +2562,7 @@ uv export [OPTIONS]

This setting has no effect when used in the uv pip interface.

+

May also be set with the UV_PROJECT environment variable.

--prune package

Prune the given package from the dependency tree.

Pruned packages will be excluded from the exported requirements file, as will any dependencies that are no longer required after the pruned package is removed.

@@ -2912,6 +2919,7 @@ uv tree [OPTIONS]

This setting has no effect when used in the uv pip interface.

+

May also be set with the UV_PROJECT environment variable.

--prune prune

Prune the given package from the display of the dependency tree

--python, -p python

The Python interpreter to use for locking and filtering.

@@ -3375,6 +3383,7 @@ uv tool run [OPTIONS] [COMMAND]

This setting has no effect when used in the uv pip interface.

+

May also be set with the UV_PROJECT environment variable.

--python, -p python

The Python interpreter to use to build the run environment.

See uv python for details on Python discovery and supported request formats.

@@ -3711,6 +3720,7 @@ uv tool install [OPTIONS]

This setting has no effect when used in the uv pip interface.

+

May also be set with the UV_PROJECT environment variable.

--python, -p python

The Python interpreter to use to build the tool environment.

See uv python for details on Python discovery and supported request formats.

@@ -4027,6 +4037,7 @@ uv tool upgrade [OPTIONS] ...

This setting has no effect when used in the uv pip interface.

+

May also be set with the UV_PROJECT environment variable.

--python, -p python

Upgrade a tool, and specify it to use the given Python interpreter to build its environment. Use with --all to apply to all tools.

See uv python for details on Python discovery and supported request formats.

@@ -4161,6 +4172,7 @@ uv tool list [OPTIONS]

This setting has no effect when used in the uv pip interface.

+

May also be set with the UV_PROJECT environment variable.

--quiet, -q

Use quiet output.

Repeating this option, e.g., -qq, will enable a silent mode in which uv will write no output to stdout.

@@ -4286,6 +4298,7 @@ uv tool uninstall [OPTIONS] ...

This setting has no effect when used in the uv pip interface.

+

May also be set with the UV_PROJECT environment variable.

--quiet, -q

Use quiet output.

Repeating this option, e.g., -qq, will enable a silent mode in which uv will write no output to stdout.

@@ -4405,6 +4418,7 @@ uv tool update-shell [OPTIONS]

This setting has no effect when used in the uv pip interface.

+

May also be set with the UV_PROJECT environment variable.

--quiet, -q

Use quiet output.

Repeating this option, e.g., -qq, will enable a silent mode in which uv will write no output to stdout.

@@ -4542,6 +4556,7 @@ uv tool dir [OPTIONS]

This setting has no effect when used in the uv pip interface.

+

May also be set with the UV_PROJECT environment variable.

--quiet, -q

Use quiet output.

Repeating this option, e.g., -qq, will enable a silent mode in which uv will write no output to stdout.

@@ -4767,6 +4782,7 @@ uv python list [OPTIONS] [REQUEST]

This setting has no effect when used in the uv pip interface.

+

May also be set with the UV_PROJECT environment variable.

--quiet, -q

Use quiet output.

Repeating this option, e.g., -qq, will enable a silent mode in which uv will write no output to stdout.

@@ -4932,6 +4948,7 @@ uv python install [OPTIONS] [TARGETS]...

This setting has no effect when used in the uv pip interface.

+

May also be set with the UV_PROJECT environment variable.

--pypy-mirror pypy-mirror

Set the URL to use as the source for downloading PyPy installations.

The provided URL will replace https://downloads.python.org/pypy in, e.g., https://downloads.python.org/pypy/pypy3.8-v7.3.7-osx64.tar.bz2.

@@ -5072,6 +5089,7 @@ uv python find [OPTIONS] [REQUEST]

This setting has no effect when used in the uv pip interface.

+

May also be set with the UV_PROJECT environment variable.

--quiet, -q

Use quiet output.

Repeating this option, e.g., -qq, will enable a silent mode in which uv will write no output to stdout.

@@ -5224,6 +5242,7 @@ uv python pin [OPTIONS] [REQUEST]

This setting has no effect when used in the uv pip interface.

+

May also be set with the UV_PROJECT environment variable.

--quiet, -q

Use quiet output.

Repeating this option, e.g., -qq, will enable a silent mode in which uv will write no output to stdout.

@@ -5365,6 +5384,7 @@ uv python dir [OPTIONS]

This setting has no effect when used in the uv pip interface.

+

May also be set with the UV_PROJECT environment variable.

--quiet, -q

Use quiet output.

Repeating this option, e.g., -qq, will enable a silent mode in which uv will write no output to stdout.

@@ -5491,6 +5511,7 @@ uv python uninstall [OPTIONS] ...

This setting has no effect when used in the uv pip interface.

+

May also be set with the UV_PROJECT environment variable.

--quiet, -q

Use quiet output.

Repeating this option, e.g., -qq, will enable a silent mode in which uv will write no output to stdout.

@@ -5873,6 +5894,7 @@ uv pip compile [OPTIONS] >

This setting has no effect when used in the uv pip interface.

+

May also be set with the UV_PROJECT environment variable.

--python, -p python

The Python interpreter to use during resolution.

A Python interpreter is required for building source distributions to determine package metadata when there are not wheels.

@@ -6341,6 +6363,7 @@ uv pip sync [OPTIONS] ...

This setting has no effect when used in the uv pip interface.

+

May also be set with the UV_PROJECT environment variable.

--python, -p python

The Python interpreter into which packages should be installed.

By default, syncing requires a virtual environment. A path to an alternative Python can be provided, but it is only recommended in continuous integration (CI) environments and should be used with caution, as it can modify the system Python installation.

@@ -6867,6 +6890,7 @@ uv pip install [OPTIONS] |--editable This setting has no effect when used in the uv pip interface.

+

May also be set with the UV_PROJECT environment variable.

--python, -p python

The Python interpreter into which packages should be installed.

By default, installation requires a virtual environment. A path to an alternative Python can be provided, but it is only recommended in continuous integration (CI) environments and should be used with caution, as it can modify the system Python installation.

@@ -7225,6 +7249,7 @@ uv pip uninstall [OPTIONS] >

This setting has no effect when used in the uv pip interface.

+

May also be set with the UV_PROJECT environment variable.

--python, -p python

The Python interpreter from which packages should be uninstalled.

By default, uninstallation requires a virtual environment. A path to an alternative Python can be provided, but it is only recommended in continuous integration (CI) environments and should be used with caution, as it can modify the system Python installation.

@@ -7360,6 +7385,7 @@ uv pip freeze [OPTIONS]

This setting has no effect when used in the uv pip interface.

+

May also be set with the UV_PROJECT environment variable.

--python, -p python

The Python interpreter for which packages should be listed.

By default, uv lists packages in a virtual environment but will show packages in a system Python environment if no virtual environment is found.

@@ -7581,6 +7607,7 @@ uv pip list [OPTIONS]

This setting has no effect when used in the uv pip interface.

+

May also be set with the UV_PROJECT environment variable.

--python, -p python

The Python interpreter for which packages should be listed.

By default, uv lists packages in a virtual environment but will show packages in a system Python environment if no virtual environment is found.

@@ -7718,6 +7745,7 @@ uv pip show [OPTIONS] [PACKAGE]...

This setting has no effect when used in the uv pip interface.

+

May also be set with the UV_PROJECT environment variable.

--python, -p python

The Python interpreter to find the package in.

By default, uv looks for packages in a virtual environment but will look for packages in a system Python environment if no virtual environment is found.

@@ -7928,6 +7956,7 @@ uv pip tree [OPTIONS]

This setting has no effect when used in the uv pip interface.

+

May also be set with the UV_PROJECT environment variable.

--prune prune

Prune the given package from the display of the dependency tree

--python, -p python

The Python interpreter for which packages should be listed.

@@ -8061,6 +8090,7 @@ uv pip check [OPTIONS]

This setting has no effect when used in the uv pip interface.

+

May also be set with the UV_PROJECT environment variable.

--python, -p python

The Python interpreter for which packages should be checked.

By default, uv checks packages in a virtual environment but will check packages in a system Python environment if no virtual environment is found.

@@ -8304,6 +8334,7 @@ uv venv [OPTIONS] [PATH]

This setting has no effect when used in the uv pip interface.

+

May also be set with the UV_PROJECT environment variable.

--prompt prompt

Provide an alternative prompt prefix for the virtual environment.

By default, the prompt is dependent on whether a path was provided to uv venv. If provided (e.g, uv venv project), the prompt is set to the directory name. If not provided (uv venv), the prompt is set to the current directory’s name.

@@ -8648,6 +8679,7 @@ uv build [OPTIONS] [SRC]

This setting has no effect when used in the uv pip interface.

+

May also be set with the UV_PROJECT environment variable.

--python, -p python

The Python interpreter to use for the build environment.

By default, builds are executed in isolated virtual environments. The discovered interpreter will be used to create those environments, and will be symlinked or copied in depending on the platform.

@@ -8852,6 +8884,7 @@ With these settings, the following two calls are equivalent:

This setting has no effect when used in the uv pip interface.

+

May also be set with the UV_PROJECT environment variable.

--publish-url publish-url

The URL of the upload endpoint (not the index URL).

Note that there are typically different URLs for index access (e.g., https:://.../simple) and index upload.

@@ -9019,6 +9052,7 @@ uv cache clean [OPTIONS] [PACKAGE]...

This setting has no effect when used in the uv pip interface.

+

May also be set with the UV_PROJECT environment variable.

--quiet, -q

Use quiet output.

Repeating this option, e.g., -qq, will enable a silent mode in which uv will write no output to stdout.

@@ -9138,6 +9172,7 @@ uv cache prune [OPTIONS]

This setting has no effect when used in the uv pip interface.

+

May also be set with the UV_PROJECT environment variable.

--quiet, -q

Use quiet output.

Repeating this option, e.g., -qq, will enable a silent mode in which uv will write no output to stdout.

@@ -9259,6 +9294,7 @@ uv cache dir [OPTIONS]

This setting has no effect when used in the uv pip interface.

+

May also be set with the UV_PROJECT environment variable.

--quiet, -q

Use quiet output.

Repeating this option, e.g., -qq, will enable a silent mode in which uv will write no output to stdout.

@@ -9394,6 +9430,7 @@ uv self update [OPTIONS] [TARGET_VERSION]

This setting has no effect when used in the uv pip interface.

+

May also be set with the UV_PROJECT environment variable.

--quiet, -q

Use quiet output.

Repeating this option, e.g., -qq, will enable a silent mode in which uv will write no output to stdout.

@@ -9510,6 +9547,7 @@ uv version [OPTIONS]

This setting has no effect when used in the uv pip interface.

+

May also be set with the UV_PROJECT environment variable.

--quiet, -q

Use quiet output.

Repeating this option, e.g., -qq, will enable a silent mode in which uv will write no output to stdout.

@@ -9575,6 +9613,7 @@ uv generate-shell-completion [OPTIONS]

This setting has no effect when used in the uv pip interface.

+

May also be set with the UV_PROJECT environment variable.

## uv help @@ -9684,6 +9723,7 @@ uv help [OPTIONS] [COMMAND]...

This setting has no effect when used in the uv pip interface.

+

May also be set with the UV_PROJECT environment variable.

--quiet, -q

Use quiet output.

Repeating this option, e.g., -qq, will enable a silent mode in which uv will write no output to stdout.