Skip to content
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
42 changes: 20 additions & 22 deletions crates/uv-cli/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3565,13 +3565,13 @@ pub struct RunArgs {
#[arg(long, conflicts_with_all = ["only_group", "only_dev"], value_hint = ValueHint::Other)]
pub group: Vec<GroupName>,

/// Disable the specified dependency group.
/// Disable the specified dependency group [env: `UV_NO_GROUP`=]
///
/// This option always takes precedence over default groups,
/// `--all-groups`, and `--group`.
///
/// May be provided multiple times.
#[arg(long, env = EnvVars::UV_NO_GROUP, value_delimiter = ' ', value_hint = ValueHint::Other)]
#[arg(long, value_delimiter = ' ', value_hint = ValueHint::Other)]
pub no_group: Vec<GroupName>,

/// Ignore the default dependency groups.
Expand Down Expand Up @@ -3909,13 +3909,13 @@ pub struct SyncArgs {
#[arg(long, conflicts_with_all = ["only_group", "only_dev"], value_hint = ValueHint::Other)]
pub group: Vec<GroupName>,

/// Disable the specified dependency group.
/// Disable the specified dependency group [env: `UV_NO_GROUP`=]
///
/// This option always takes precedence over default groups,
/// `--all-groups`, and `--group`.
///
/// May be provided multiple times.
#[arg(long, env = EnvVars::UV_NO_GROUP, value_delimiter = ' ', value_hint = ValueHint::Other)]
#[arg(long, value_delimiter = ' ', value_hint = ValueHint::Other)]
pub no_group: Vec<GroupName>,

/// Ignore the default dependency groups.
Expand Down Expand Up @@ -4724,13 +4724,13 @@ pub struct TreeArgs {
#[arg(long, conflicts_with_all = ["only_group", "only_dev"])]
pub group: Vec<GroupName>,

/// Disable the specified dependency group.
/// Disable the specified dependency group [env: `UV_NO_GROUP`=]
///
/// This option always takes precedence over default groups,
/// `--all-groups`, and `--group`.
///
/// May be provided multiple times.
#[arg(long, env = EnvVars::UV_NO_GROUP, value_delimiter = ' ')]
#[arg(long, value_delimiter = ' ')]
pub no_group: Vec<GroupName>,

/// Ignore the default dependency groups.
Expand Down Expand Up @@ -4900,13 +4900,13 @@ pub struct ExportArgs {
#[arg(long, conflicts_with_all = ["only_group", "only_dev"])]
pub group: Vec<GroupName>,

/// Disable the specified dependency group.
/// Disable the specified dependency group [env: `UV_NO_GROUP`=]
///
/// This option always takes precedence over default groups,
/// `--all-groups`, and `--group`.
///
/// May be provided multiple times.
#[arg(long, env = EnvVars::UV_NO_GROUP, value_delimiter = ' ')]
#[arg(long, value_delimiter = ' ')]
pub no_group: Vec<GroupName>,

/// Ignore the default dependency groups.
Expand Down Expand Up @@ -5189,10 +5189,10 @@ pub struct AuditArgs {
#[arg(long, value_parser = clap::builder::BoolishValueParser::new())]
pub no_dev: bool,

/// Don't audit the specified dependency group.
/// Don't audit the specified dependency group [env: `UV_NO_GROUP`=]
///
/// May be provided multiple times.
#[arg(long, env = EnvVars::UV_NO_GROUP, value_delimiter = ' ', value_hint = ValueHint::Other)]
#[arg(long, value_delimiter = ' ', value_hint = ValueHint::Other)]
pub no_group: Vec<GroupName>,

/// Don't audit the default dependency groups.
Expand Down Expand Up @@ -6187,8 +6187,8 @@ pub struct ToolUpgradeArgs {
)]
pub no_sources: bool,

/// Don't use sources from the `tool.uv.sources` table for the specified packages.
#[arg(long, help_heading = "Resolver options", env = EnvVars::UV_NO_SOURCES_PACKAGE, value_delimiter = ' ')]
/// Don't use sources from the `tool.uv.sources` table for the specified packages [env: `UV_NO_SOURCES_PACKAGE`=]
#[arg(long, help_heading = "Resolver options", value_delimiter = ' ')]
pub no_sources_package: Vec<PackageName>,

#[command(flatten)]
Expand Down Expand Up @@ -7033,11 +7033,10 @@ pub struct BuildOptionsArgs {
)]
pub build: bool,

/// Don't build source distributions for a specific package.
/// Don't build source distributions for a specific package [env: `UV_NO_BUILD_PACKAGE`=]
#[arg(
long,
help_heading = "Build options",
env = EnvVars::UV_NO_BUILD_PACKAGE,
value_delimiter = ' ',
value_hint = ValueHint::Other,
)]
Expand All @@ -7064,11 +7063,10 @@ pub struct BuildOptionsArgs {
)]
pub binary: bool,

/// Don't install pre-built wheels for a specific package.
/// Don't install pre-built wheels for a specific package [env: `UV_NO_BINARY_PACKAGE`=]
#[arg(
long,
help_heading = "Build options",
env = EnvVars::UV_NO_BINARY_PACKAGE,
value_delimiter = ' ',
value_hint = ValueHint::Other,
)]
Expand Down Expand Up @@ -7260,8 +7258,8 @@ pub struct InstallerArgs {
)]
pub no_sources: bool,

/// Don't use sources from the `tool.uv.sources` table for the specified packages.
#[arg(long, help_heading = "Resolver options", env = EnvVars::UV_NO_SOURCES_PACKAGE, value_delimiter = ' ')]
/// Don't use sources from the `tool.uv.sources` table for the specified packages [env: `UV_NO_SOURCES_PACKAGE`=]
#[arg(long, help_heading = "Resolver options", value_delimiter = ' ')]
pub no_sources_package: Vec<PackageName>,
}

Expand Down Expand Up @@ -7480,8 +7478,8 @@ pub struct ResolverArgs {
)]
pub no_sources: bool,

/// Don't use sources from the `tool.uv.sources` table for the specified packages.
#[arg(long, help_heading = "Resolver options", env = EnvVars::UV_NO_SOURCES_PACKAGE, value_delimiter = ' ')]
/// Don't use sources from the `tool.uv.sources` table for the specified packages [env: `UV_NO_SOURCES_PACKAGE`=]
#[arg(long, help_heading = "Resolver options", value_delimiter = ' ')]
pub no_sources_package: Vec<PackageName>,
}

Expand Down Expand Up @@ -7757,8 +7755,8 @@ pub struct ResolverInstallerArgs {
)]
pub no_sources: bool,

/// Don't use sources from the `tool.uv.sources` table for the specified packages.
#[arg(long, help_heading = "Resolver options", env = EnvVars::UV_NO_SOURCES_PACKAGE, value_delimiter = ' ')]
/// Don't use sources from the `tool.uv.sources` table for the specified packages [env: `UV_NO_SOURCES_PACKAGE`=]
#[arg(long, help_heading = "Resolver options", value_delimiter = ' ')]
pub no_sources_package: Vec<PackageName>,
}

Expand Down
36 changes: 30 additions & 6 deletions crates/uv-cli/src/options.rs
Original file line number Diff line number Diff line change
Expand Up @@ -293,7 +293,11 @@ impl From<ResolverArgs> for PipOptions {
exclude_newer_package: exclude_newer_package.map(ExcludeNewerPackage::from_iter),
link_mode,
no_sources: if no_sources { Some(true) } else { None },
no_sources_package: Some(no_sources_package),
no_sources_package: if no_sources_package.is_empty() {
None
} else {
Some(no_sources_package)
},
..Self::from(index_args)
}
}
Expand Down Expand Up @@ -339,7 +343,11 @@ impl From<InstallerArgs> for PipOptions {
link_mode,
compile_bytecode: flag(compile_bytecode, no_compile_bytecode, "compile-bytecode"),
no_sources: if no_sources { Some(true) } else { None },
no_sources_package: Some(no_sources_package),
no_sources_package: if no_sources_package.is_empty() {
None
} else {
Some(no_sources_package)
},
..Self::from(index_args)
}
}
Expand Down Expand Up @@ -414,7 +422,11 @@ impl From<ResolverInstallerArgs> for PipOptions {
link_mode,
compile_bytecode: flag(compile_bytecode, no_compile_bytecode, "compile-bytecode"),
no_sources: if no_sources { Some(true) } else { None },
no_sources_package: Some(no_sources_package),
no_sources_package: if no_sources_package.is_empty() {
None
} else {
Some(no_sources_package)
},
..Self::from(index_args)
}
}
Expand Down Expand Up @@ -582,11 +594,23 @@ pub fn resolver_options(
link_mode,
torch_backend: None,
no_build: flag(no_build, build, "build"),
no_build_package: Some(no_build_package),
no_build_package: if no_build_package.is_empty() {
None
} else {
Some(no_build_package)
},
no_binary: flag(no_binary, binary, "binary"),
no_binary_package: Some(no_binary_package),
no_binary_package: if no_binary_package.is_empty() {
None
} else {
Some(no_binary_package)
},
no_sources: if no_sources { Some(true) } else { None },
no_sources_package: Some(no_sources_package),
no_sources_package: if no_sources_package.is_empty() {
None
} else {
Some(no_sources_package)
},
}
}

Expand Down
41 changes: 41 additions & 0 deletions crates/uv-settings/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ use uv_dirs::{system_config_file, user_config_dir};
use uv_distribution_types::Origin;
use uv_flags::EnvironmentFlags;
use uv_fs::Simplified;
use uv_normalize::{GroupName, PackageName};
use uv_pep440::Version;
use uv_static::{EnvVars, InvalidEnvironmentVariable, parse_boolish_environment_variable};
use uv_warnings::warn_user;
Expand Down Expand Up @@ -751,6 +752,10 @@ pub struct EnvironmentOptions {
pub show_resolution: EnvFlag,
pub no_editable: EnvFlag,
pub no_env_file: EnvFlag,
pub no_group: Option<Vec<GroupName>>,
pub no_binary_package: Option<Vec<PackageName>>,
pub no_build_package: Option<Vec<PackageName>>,
pub no_sources_package: Option<Vec<PackageName>>,
pub venv_seed: EnvFlag,
pub venv_clear: EnvFlag,
pub venv_relocatable: EnvFlag,
Expand Down Expand Up @@ -847,6 +852,12 @@ impl EnvironmentOptions {
show_resolution: EnvFlag::new(EnvVars::UV_SHOW_RESOLUTION)?,
no_editable: EnvFlag::new(EnvVars::UV_NO_EDITABLE)?,
no_env_file: EnvFlag::new(EnvVars::UV_NO_ENV_FILE)?,
no_group: parse_name_list_environment_variable(EnvVars::UV_NO_GROUP)?,
no_binary_package: parse_name_list_environment_variable(EnvVars::UV_NO_BINARY_PACKAGE)?,
no_build_package: parse_name_list_environment_variable(EnvVars::UV_NO_BUILD_PACKAGE)?,
no_sources_package: parse_name_list_environment_variable(
EnvVars::UV_NO_SOURCES_PACKAGE,
)?,
venv_seed: EnvFlag::new(EnvVars::UV_VENV_SEED)?,
venv_clear: EnvFlag::new(EnvVars::UV_VENV_CLEAR)?,
venv_relocatable: EnvFlag::new(EnvVars::UV_VENV_RELOCATABLE)?,
Expand Down Expand Up @@ -878,6 +889,36 @@ fn parse_string_environment_variable(name: &'static str) -> Result<Option<String
}
}

/// Parse an environment variable containing a whitespace-delimited list of names.
fn parse_name_list_environment_variable<T>(name: &'static str) -> Result<Option<Vec<T>>, Error>
where
T: FromStr,
<T as FromStr>::Err: std::fmt::Display,
{
let Some(value) = parse_string_environment_variable(name)? else {
return Ok(None);
};

let names = value
.split_whitespace()
.map(|entry| {
entry.parse::<T>().map_err(|err| {
Error::InvalidEnvironmentVariable(InvalidEnvironmentVariable {
name: name.to_string(),
value: value.clone(),
err: err.to_string(),
})
})
})
.collect::<Result<Vec<_>, _>>()?;

if names.is_empty() {
Ok(None)
} else {
Ok(Some(names))
}
}

fn parse_integer_environment_variable<T>(
name: &'static str,
help: Option<&str>,
Expand Down
Loading
Loading