diff --git a/crates/uv-cli/src/lib.rs b/crates/uv-cli/src/lib.rs index bf605198f..56a281a5c 100644 --- a/crates/uv-cli/src/lib.rs +++ b/crates/uv-cli/src/lib.rs @@ -591,7 +591,7 @@ pub struct VersionArgs { pub refresh: RefreshArgs, /// Update the version of a specific package in the workspace. - #[arg(long, conflicts_with = "isolated")] + #[arg(long, env = EnvVars::UV_PACKAGE, conflicts_with = "isolated")] pub package: Option, /// The Python interpreter to use for resolving and syncing. @@ -2380,7 +2380,7 @@ pub struct BuildArgs { /// directory if no source directory is provided. /// /// If the workspace member does not exist, uv will exit with an error. - #[arg(long, conflicts_with("all_packages"))] + #[arg(long, env = EnvVars::UV_PACKAGE, conflicts_with("all_packages"))] pub package: Option, /// Builds all packages in the workspace. @@ -3104,7 +3104,7 @@ pub struct RunArgs { /// Run the command in a specific package in the workspace. /// /// If the workspace member does not exist, uv will exit with an error. - #[arg(long, conflicts_with = "all_packages")] + #[arg(long, env = EnvVars::UV_PACKAGE, conflicts_with = "all_packages")] pub package: Option, /// Avoid discovering the project or workspace. @@ -3347,7 +3347,7 @@ pub struct SyncArgs { /// declared by the specified workspace member package. /// /// If the workspace member does not exist, uv will exit with an error. - #[arg(long, conflicts_with = "all_packages")] + #[arg(long, env = EnvVars::UV_PACKAGE, conflicts_with = "all_packages")] pub package: Option, /// Sync the environment for a Python script, rather than the current project. @@ -3619,7 +3619,7 @@ pub struct AddArgs { pub refresh: RefreshArgs, /// Add the dependency to a specific package in the workspace. - #[arg(long, conflicts_with = "isolated")] + #[arg(long, env = EnvVars::UV_PACKAGE, conflicts_with = "isolated")] pub package: Option, /// Add the dependency to the specified Python script, rather than to a project. @@ -3720,7 +3720,7 @@ pub struct RemoveArgs { pub refresh: RefreshArgs, /// Remove the dependencies from a specific package in the workspace. - #[arg(long, conflicts_with = "isolated")] + #[arg(long, env = EnvVars::UV_PACKAGE, conflicts_with = "isolated")] pub package: Option, /// Remove the dependency from the specified Python script, rather than from a project. @@ -3907,7 +3907,7 @@ pub struct ExportArgs { /// Export the dependencies for a specific package in the workspace. /// /// If the workspace member does not exist, uv will exit with an error. - #[arg(long, conflicts_with = "all_packages")] + #[arg(long, env = EnvVars::UV_PACKAGE, conflicts_with = "all_packages")] pub package: Option, /// Prune the given package from the dependency tree. diff --git a/crates/uv-static/src/env_vars.rs b/crates/uv-static/src/env_vars.rs index 4ac2976d9..27e0ab171 100644 --- a/crates/uv-static/src/env_vars.rs +++ b/crates/uv-static/src/env_vars.rs @@ -100,6 +100,10 @@ impl EnvVars { /// file as the constraints file. Uses space-separated list of files. pub const UV_CONSTRAINT: &'static str = "UV_CONSTRAINT"; + /// Equivalent to the `--package` command-line argument. If set, uv + /// will run the command in this workspace member. + pub const UV_PACKAGE: &'static str = "UV_PACKAGE"; + /// Equivalent to the `--build-constraint` command-line argument. If set, uv will use this file /// as constraints for any source distribution builds. Uses space-separated list of files. pub const UV_BUILD_CONSTRAINT: &'static str = "UV_BUILD_CONSTRAINT"; diff --git a/docs/reference/cli.md b/docs/reference/cli.md index 82fe0fa3d..3e86e97b8 100644 --- a/docs/reference/cli.md +++ b/docs/reference/cli.md @@ -209,7 +209,7 @@ uv run [OPTIONS] [COMMAND]

May be provided multiple times. Implies --no-default-groups.

--package package

Run the command in a specific package in the workspace.

If the workspace member does not exist, uv will exit with an error.

-
--prerelease prerelease

The strategy to use when considering pre-release versions.

+

May also be set with the UV_PACKAGE environment variable.

--prerelease prerelease

The strategy to use when considering pre-release versions.

By default, uv will accept pre-releases for packages that only publish pre-releases, along with first-party requirements that contain an explicit pre-release marker in the declared specifiers (if-necessary-or-explicit).

May also be set with the UV_PRERELEASE environment variable.

Possible values:

    @@ -541,7 +541,7 @@ uv add [OPTIONS] >

    The group may then be activated when installing the project with the --extra flag.

    To enable an optional extra for this requirement instead, see --extra.

--package package

Add the dependency to a specific package in the workspace

-
--prerelease prerelease

The strategy to use when considering pre-release versions.

+

May also be set with the UV_PACKAGE environment variable.

--prerelease prerelease

The strategy to use when considering pre-release versions.

By default, uv will accept pre-releases for packages that only publish pre-releases, along with first-party requirements that contain an explicit pre-release marker in the declared specifiers (if-necessary-or-explicit).

May also be set with the UV_PRERELEASE environment variable.

Possible values:

    @@ -723,7 +723,7 @@ uv remove [OPTIONS] ...

    When disabled, uv will only use locally cached data and locally available files.

    May also be set with the UV_OFFLINE environment variable.

--optional optional

Remove the packages from the project's optional dependencies for the specified extra

--package package

Remove the dependencies from a specific package in the workspace

-
--prerelease prerelease

The strategy to use when considering pre-release versions.

+

May also be set with the UV_PACKAGE environment variable.

--prerelease prerelease

The strategy to use when considering pre-release versions.

By default, uv will accept pre-releases for packages that only publish pre-releases, along with first-party requirements that contain an explicit pre-release marker in the declared specifiers (if-necessary-or-explicit).

May also be set with the UV_PRERELEASE environment variable.

Possible values:

    @@ -897,7 +897,7 @@ uv version [OPTIONS] [VALUE]
  • text: Display the version as plain text
  • json: Display the version as JSON
--package package

Update the version of a specific package in the workspace

-
--prerelease prerelease

The strategy to use when considering pre-release versions.

+

May also be set with the UV_PACKAGE environment variable.

--prerelease prerelease

The strategy to use when considering pre-release versions.

By default, uv will accept pre-releases for packages that only publish pre-releases, along with first-party requirements that contain an explicit pre-release marker in the declared specifiers (if-necessary-or-explicit).

May also be set with the UV_PRERELEASE environment variable.

Possible values:

    @@ -1108,7 +1108,7 @@ uv sync [OPTIONS]
--package package

Sync for a specific package in the workspace.

The workspace's environment (.venv) is updated to reflect the subset of dependencies declared by the specified workspace member package.

If the workspace member does not exist, uv will exit with an error.

-
--prerelease prerelease

The strategy to use when considering pre-release versions.

+

May also be set with the UV_PACKAGE environment variable.

--prerelease prerelease

The strategy to use when considering pre-release versions.

By default, uv will accept pre-releases for packages that only publish pre-releases, along with first-party requirements that contain an explicit pre-release marker in the declared specifiers (if-necessary-or-explicit).

May also be set with the UV_PRERELEASE environment variable.

Possible values:

    @@ -1473,7 +1473,7 @@ uv export [OPTIONS]
--output-file, -o output-file

Write the exported requirements to the given file

--package package

Export the dependencies for a specific package in the workspace.

If the workspace member does not exist, uv will exit with an error.

-
--prerelease prerelease

The strategy to use when considering pre-release versions.

+

May also be set with the UV_PACKAGE environment variable.

--prerelease prerelease

The strategy to use when considering pre-release versions.

By default, uv will accept pre-releases for packages that only publish pre-releases, along with first-party requirements that contain an explicit pre-release marker in the declared specifiers (if-necessary-or-explicit).

May also be set with the UV_PRERELEASE environment variable.

Possible values:

    @@ -4803,7 +4803,7 @@ uv build [OPTIONS] [SRC]
--package package

Build a specific package in the workspace.

The workspace will be discovered from the provided source directory, or the current directory if no source directory is provided.

If the workspace member does not exist, uv will exit with an error.

-
--prerelease prerelease

The strategy to use when considering pre-release versions.

+

May also be set with the UV_PACKAGE environment variable.

--prerelease prerelease

The strategy to use when considering pre-release versions.

By default, uv will accept pre-releases for packages that only publish pre-releases, along with first-party requirements that contain an explicit pre-release marker in the declared specifiers (if-necessary-or-explicit).

May also be set with the UV_PRERELEASE environment variable.

Possible values:

    diff --git a/docs/reference/environment.md b/docs/reference/environment.md index 61889ddb3..6e10d54d9 100644 --- a/docs/reference/environment.md +++ b/docs/reference/environment.md @@ -275,6 +275,11 @@ Equivalent to the `--offline` command-line argument. If set, uv will disable net Equivalent to the `--override` command-line argument. If set, uv will use this file as the overrides file. Uses space-separated list of files. +### `UV_PACKAGE` + +Equivalent to the `--package` command-line argument. If set, uv +will run the command in this workspace member. + ### `UV_PRERELEASE` Equivalent to the `--prerelease` command-line argument. For example, if set to