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

Support UV_PROJECT environment to set project directory. #12327

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
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
2 changes: 1 addition & 1 deletion crates/uv-cli/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -314,7 +314,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<PathBuf>,
}

Expand Down
3 changes: 3 additions & 0 deletions crates/uv-static/src/env_vars.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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";
}
18 changes: 11 additions & 7 deletions crates/uv/tests/it/help.rs
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ fn help() {
--directory <DIRECTORY>
Change to the given directory prior to running the command
--project <PROJECT>
Run the command within the given project directory
Run the command within the given project directory [env: UV_PROJECT=]
--config-file <CONFIG_FILE>
The path to a `uv.toml` file to use for configuration [env: UV_CONFIG_FILE=]
--no-config
Expand Down Expand Up @@ -145,7 +145,7 @@ fn help_flag() {
--directory <DIRECTORY>
Change to the given directory prior to running the command
--project <PROJECT>
Run the command within the given project directory
Run the command within the given project directory [env: UV_PROJECT=]
--config-file <CONFIG_FILE>
The path to a `uv.toml` file to use for configuration [env: UV_CONFIG_FILE=]
--no-config
Expand Down Expand Up @@ -223,7 +223,7 @@ fn help_short_flag() {
--directory <DIRECTORY>
Change to the given directory prior to running the command
--project <PROJECT>
Run the command within the given project directory
Run the command within the given project directory [env: UV_PROJECT=]
--config-file <CONFIG_FILE>
The path to a `uv.toml` file to use for configuration [env: UV_CONFIG_FILE=]
--no-config
Expand Down Expand Up @@ -416,6 +416,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 <CONFIG_FILE>
The path to a `uv.toml` file to use for configuration.
Expand Down Expand Up @@ -664,6 +666,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 <CONFIG_FILE>
The path to a `uv.toml` file to use for configuration.
Expand Down Expand Up @@ -742,7 +746,7 @@ fn help_flag_subcommand() {
--directory <DIRECTORY>
Change to the given directory prior to running the command
--project <PROJECT>
Run the command within the given project directory
Run the command within the given project directory [env: UV_PROJECT=]
--config-file <CONFIG_FILE>
The path to a `uv.toml` file to use for configuration [env: UV_CONFIG_FILE=]
--no-config
Expand Down Expand Up @@ -814,7 +818,7 @@ fn help_flag_subsubcommand() {
--directory <DIRECTORY>
Change to the given directory prior to running the command
--project <PROJECT>
Run the command within the given project directory
Run the command within the given project directory [env: UV_PROJECT=]
--config-file <CONFIG_FILE>
The path to a `uv.toml` file to use for configuration [env: UV_CONFIG_FILE=]
--no-config
Expand Down Expand Up @@ -970,7 +974,7 @@ fn help_with_global_option() {
--directory <DIRECTORY>
Change to the given directory prior to running the command
--project <PROJECT>
Run the command within the given project directory
Run the command within the given project directory [env: UV_PROJECT=]
--config-file <CONFIG_FILE>
The path to a `uv.toml` file to use for configuration [env: UV_CONFIG_FILE=]
--no-config
Expand Down Expand Up @@ -1085,7 +1089,7 @@ fn help_with_no_pager() {
--directory <DIRECTORY>
Change to the given directory prior to running the command
--project <PROJECT>
Run the command within the given project directory
Run the command within the given project directory [env: UV_PROJECT=]
--config-file <CONFIG_FILE>
The path to a `uv.toml` file to use for configuration [env: UV_CONFIG_FILE=]
--no-config
Expand Down
4 changes: 4 additions & 0 deletions docs/configuration/environment.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
Loading
Loading