diff --git a/crates/uv-cli/src/lib.rs b/crates/uv-cli/src/lib.rs index 0b96875e5..3c7f5bdab 100644 --- a/crates/uv-cli/src/lib.rs +++ b/crates/uv-cli/src/lib.rs @@ -594,7 +594,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. @@ -2397,7 +2397,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. @@ -3124,7 +3124,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. @@ -3368,7 +3368,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. @@ -3642,7 +3642,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. @@ -3744,7 +3744,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. @@ -3933,7 +3933,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 aff56df45..838f3111f 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";