diff --git a/crates/uv-cli/src/lib.rs b/crates/uv-cli/src/lib.rs index 71bb1eb49..2163fc190 100644 --- a/crates/uv-cli/src/lib.rs +++ b/crates/uv-cli/src/lib.rs @@ -3481,19 +3481,24 @@ pub struct AddArgs { #[arg(long, overrides_with = "editable", hide = true)] pub no_editable: bool, - /// Add source requirements to `project.dependencies`, rather than `tool.uv.sources`. + /// Add a dependency as provided. /// /// By default, uv will use the `tool.uv.sources` section to record source information for Git, - /// local, editable, and direct URL requirements. + /// local, editable, and direct URL requirements. When `--raw` is provided, uv will add source + /// requirements to `project.dependencies`, rather than `tool.uv.sources`. + /// + /// Additionally, by default, uv will add bounds to your dependency, e.g., `foo>=1.0.0`. When + /// `--raw` is provided, uv will add the dependency without bounds. #[arg( long, conflicts_with = "editable", conflicts_with = "no_editable", conflicts_with = "rev", conflicts_with = "tag", - conflicts_with = "branch" + conflicts_with = "branch", + alias = "raw-sources" )] - pub raw_sources: bool, + pub raw: bool, /// Commit to use when adding a dependency from Git. #[arg(long, group = "git-ref", action = clap::ArgAction::Set)] diff --git a/crates/uv/src/commands/project/add.rs b/crates/uv/src/commands/project/add.rs index 8ed8cbcd4..0c1cf8d01 100644 --- a/crates/uv/src/commands/project/add.rs +++ b/crates/uv/src/commands/project/add.rs @@ -72,7 +72,7 @@ pub(crate) async fn add( marker: Option, editable: Option, dependency_type: DependencyType, - raw_sources: bool, + raw: bool, indexes: Vec, rev: Option, tag: Option, @@ -444,7 +444,7 @@ pub(crate) async fn add( &target, editable, &dependency_type, - raw_sources, + raw, rev.as_deref(), tag.as_deref(), branch.as_deref(), @@ -454,7 +454,7 @@ pub(crate) async fn add( )?; // Add any indexes that were provided on the command-line, in priority order. - if !raw_sources { + if !raw { let urls = IndexUrls::from_indexes(indexes); for index in urls.defined_indexes() { toml.add_index(index)?; @@ -519,7 +519,7 @@ pub(crate) async fn add( sync_state, locked, &dependency_type, - raw_sources, + raw, constraints, &settings, &network_settings, @@ -551,7 +551,7 @@ fn edits( target: &AddTarget, editable: Option, dependency_type: &DependencyType, - raw_sources: bool, + raw: bool, rev: Option<&str>, tag: Option<&str>, branch: Option<&str>, @@ -569,7 +569,7 @@ fn edits( requirement.extras = ex.into_boxed_slice(); let (requirement, source) = match target { - AddTarget::Script(_, _) | AddTarget::Project(_, _) if raw_sources => { + AddTarget::Script(_, _) | AddTarget::Project(_, _) if raw => { (uv_pep508::Requirement::from(requirement), None) } AddTarget::Script(ref script, _) => { @@ -743,7 +743,7 @@ async fn lock_and_sync( sync_state: PlatformState, locked: bool, dependency_type: &DependencyType, - raw_sources: bool, + raw: bool, constraints: Vec, settings: &ResolverInstallerSettings, network_settings: &NetworkSettings, @@ -774,7 +774,7 @@ async fn lock_and_sync( .into_lock(); // Avoid modifying the user request further if `--raw-sources` is set. - if !raw_sources { + if !raw { // Extract the minimum-supported version for each dependency. let mut minimum_version = FxHashMap::with_capacity_and_hasher(lock.packages().len(), FxBuildHasher); diff --git a/crates/uv/src/lib.rs b/crates/uv/src/lib.rs index 6e0897086..da46a71e9 100644 --- a/crates/uv/src/lib.rs +++ b/crates/uv/src/lib.rs @@ -1869,7 +1869,7 @@ async fn run_project( args.marker, args.editable, args.dependency_type, - args.raw_sources, + args.raw, args.indexes, args.rev, args.tag, diff --git a/crates/uv/src/settings.rs b/crates/uv/src/settings.rs index 245129034..85dcfd5b0 100644 --- a/crates/uv/src/settings.rs +++ b/crates/uv/src/settings.rs @@ -1252,7 +1252,7 @@ pub(crate) struct AddSettings { pub(crate) dependency_type: DependencyType, pub(crate) editable: Option, pub(crate) extras: Vec, - pub(crate) raw_sources: bool, + pub(crate) raw: bool, pub(crate) rev: Option, pub(crate) tag: Option, pub(crate) branch: Option, @@ -1280,7 +1280,7 @@ impl AddSettings { editable, no_editable, extra, - raw_sources, + raw, rev, tag, branch, @@ -1371,7 +1371,7 @@ impl AddSettings { .collect(), marker, dependency_type, - raw_sources, + raw, rev, tag, branch, diff --git a/crates/uv/tests/it/edit.rs b/crates/uv/tests/it/edit.rs index 160bbf4b7..a2dc91df4 100644 --- a/crates/uv/tests/it/edit.rs +++ b/crates/uv/tests/it/edit.rs @@ -799,18 +799,18 @@ fn add_raw_error() -> Result<()> { "#})?; // Provide a tag without a Git source. - uv_snapshot!(context.filters(), context.add().arg("uv-public-pypackage @ git+https://github.com/astral-test/uv-public-pypackage").arg("--tag").arg("0.0.1").arg("--raw-sources"), @r###" + uv_snapshot!(context.filters(), context.add().arg("uv-public-pypackage @ git+https://github.com/astral-test/uv-public-pypackage").arg("--tag").arg("0.0.1").arg("--raw-sources"), @r" success: false exit_code: 2 ----- stdout ----- ----- stderr ----- - error: the argument '--tag ' cannot be used with '--raw-sources' + error: the argument '--tag ' cannot be used with '--raw' Usage: uv add --cache-dir [CACHE_DIR] --tag --exclude-newer > For more information, try '--help'. - "###); + "); Ok(()) } @@ -3959,7 +3959,7 @@ fn add_lower_bound_existing() -> Result<()> { Ok(()) } -/// Avoid setting a lower bound with `--raw-sources`. +/// Avoid setting a lower bound with `--raw`. #[test] fn add_lower_bound_raw() -> Result<()> { let context = TestContext::new("3.12"); @@ -3973,8 +3973,8 @@ fn add_lower_bound_raw() -> Result<()> { dependencies = ["anyio"] "#})?; - // Adding `anyio` should _not_ set a lower-bound when using `--raw-sources`. - uv_snapshot!(context.filters(), context.add().arg("anyio").arg("--raw-sources"), @r" + // Adding `anyio` should _not_ set a lower-bound when using `--raw`. + uv_snapshot!(context.filters(), context.add().arg("anyio").arg("--raw"), @r" success: true exit_code: 0 ----- stdout ----- diff --git a/docs/reference/cli.md b/docs/reference/cli.md index 1bdad2717..a9ddc1002 100644 --- a/docs/reference/cli.md +++ b/docs/reference/cli.md @@ -1068,9 +1068,11 @@ uv add [OPTIONS] >

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

-
--raw-sources

Add source requirements to project.dependencies, rather than tool.uv.sources.

+
--raw, --raw-sources

Add a dependency as provided.

-

By default, uv will use the tool.uv.sources section to record source information for Git, local, editable, and direct URL requirements.

+

By default, uv will use the tool.uv.sources section to record source information for Git, local, editable, and direct URL requirements. When --raw is provided, uv will add source requirements to project.dependencies, rather than tool.uv.sources.

+ +

Additionally, by default, uv will add bounds to your dependency, e.g., foo>=1.0.0. When --raw is provided, uv will add the dependency without bounds.

--refresh

Refresh all cached data