mirror of https://github.com/astral-sh/uv
Rename `--raw-sources` to `--raw` (#13348)
This also omits bounds on constraints, and is useful for that. This retains `--raw-sources` as an alias. I've had this on my mind for a while, but https://github.com/astral-sh/uv/pull/12946 reminded me of it again.
This commit is contained in:
parent
9a15240147
commit
26e37f3a1e
|
|
@ -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)]
|
||||
|
|
|
|||
|
|
@ -72,7 +72,7 @@ pub(crate) async fn add(
|
|||
marker: Option<MarkerTree>,
|
||||
editable: Option<bool>,
|
||||
dependency_type: DependencyType,
|
||||
raw_sources: bool,
|
||||
raw: bool,
|
||||
indexes: Vec<Index>,
|
||||
rev: Option<String>,
|
||||
tag: Option<String>,
|
||||
|
|
@ -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<bool>,
|
||||
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<NameRequirementSpecification>,
|
||||
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);
|
||||
|
|
|
|||
|
|
@ -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,
|
||||
|
|
|
|||
|
|
@ -1252,7 +1252,7 @@ pub(crate) struct AddSettings {
|
|||
pub(crate) dependency_type: DependencyType,
|
||||
pub(crate) editable: Option<bool>,
|
||||
pub(crate) extras: Vec<ExtraName>,
|
||||
pub(crate) raw_sources: bool,
|
||||
pub(crate) raw: bool,
|
||||
pub(crate) rev: Option<String>,
|
||||
pub(crate) tag: Option<String>,
|
||||
pub(crate) branch: Option<String>,
|
||||
|
|
@ -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,
|
||||
|
|
|
|||
|
|
@ -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 <TAG>' cannot be used with '--raw-sources'
|
||||
error: the argument '--tag <TAG>' cannot be used with '--raw'
|
||||
|
||||
Usage: uv add --cache-dir [CACHE_DIR] --tag <TAG> --exclude-newer <EXCLUDE_NEWER> <PACKAGES|--requirements <REQUIREMENTS>>
|
||||
|
||||
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 -----
|
||||
|
|
|
|||
|
|
@ -1068,9 +1068,11 @@ uv add [OPTIONS] <PACKAGES|--requirements <REQUIREMENTS>>
|
|||
|
||||
<p>Repeating this option, e.g., <code>-qq</code>, will enable a silent mode in which uv will write no output to stdout.</p>
|
||||
|
||||
</dd><dt id="uv-add--raw-sources"><a href="#uv-add--raw-sources"><code>--raw-sources</code></a></dt><dd><p>Add source requirements to <code>project.dependencies</code>, rather than <code>tool.uv.sources</code>.</p>
|
||||
</dd><dt id="uv-add--raw"><a href="#uv-add--raw"><code>--raw</code></a>, <code>--raw-sources</code></dt><dd><p>Add a dependency as provided.</p>
|
||||
|
||||
<p>By default, uv will use the <code>tool.uv.sources</code> section to record source information for Git, local, editable, and direct URL requirements.</p>
|
||||
<p>By default, uv will use the <code>tool.uv.sources</code> section to record source information for Git, local, editable, and direct URL requirements. When <code>--raw</code> is provided, uv will add source requirements to <code>project.dependencies</code>, rather than <code>tool.uv.sources</code>.</p>
|
||||
|
||||
<p>Additionally, by default, uv will add bounds to your dependency, e.g., <code>foo>=1.0.0</code>. When <code>--raw</code> is provided, uv will add the dependency without bounds.</p>
|
||||
|
||||
</dd><dt id="uv-add--refresh"><a href="#uv-add--refresh"><code>--refresh</code></a></dt><dd><p>Refresh all cached data</p>
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue