From f876616b81aa555abbbb540046872639381674ff Mon Sep 17 00:00:00 2001 From: konstin Date: Mon, 4 Nov 2024 10:35:01 +0100 Subject: [PATCH 1/3] Publish: Hint at `--skip-existing` -> `--check-url` transition --- crates/uv-cli/src/lib.rs | 5 ++++- crates/uv/src/lib.rs | 9 ++++++++- crates/uv/tests/it/publish.rs | 20 ++++++++++++++++++++ 3 files changed, 32 insertions(+), 2 deletions(-) diff --git a/crates/uv-cli/src/lib.rs b/crates/uv-cli/src/lib.rs index 714a36a91e90..01a6381bde71 100644 --- a/crates/uv-cli/src/lib.rs +++ b/crates/uv-cli/src/lib.rs @@ -4863,8 +4863,11 @@ pub struct PublishArgs { /// file succeeds even without `--check-url`, while most other indexes error. /// /// The index must provide one of the supported hashes (SHA-256, SHA-384, or SHA-512). - #[arg(long,env = EnvVars::UV_PUBLISH_CHECK_URL)] + #[arg(long, env = EnvVars::UV_PUBLISH_CHECK_URL)] pub check_url: Option, + + #[arg(long, hide = true)] + pub skip_existing: bool, } /// See [PEP 517](https://peps.python.org/pep-0517/) and diff --git a/crates/uv/src/lib.rs b/crates/uv/src/lib.rs index b171de7b1f26..aee1ce2d2940 100644 --- a/crates/uv/src/lib.rs +++ b/crates/uv/src/lib.rs @@ -6,7 +6,7 @@ use std::path::Path; use std::process::ExitCode; use anstream::eprintln; -use anyhow::Result; +use anyhow::{bail, Result}; use clap::error::{ContextKind, ContextValue}; use clap::{CommandFactory, Parser}; use owo_colors::OwoColorize; @@ -1128,6 +1128,13 @@ async fn run(mut cli: Cli) -> Result { warn_user_once!("`uv publish` is experimental and may change without warning"); } + if args.skip_existing { + bail!( + "`uv publish` does not support `--skip-existing`, \ + use `--check-url` with the simple index URL instead." + ); + } + // Resolve the settings from the command-line arguments and workspace configuration. let PublishSettings { files, diff --git a/crates/uv/tests/it/publish.rs b/crates/uv/tests/it/publish.rs index 752d7c427a84..74a1316b6bf5 100644 --- a/crates/uv/tests/it/publish.rs +++ b/crates/uv/tests/it/publish.rs @@ -142,3 +142,23 @@ fn no_credentials() { "### ); } + +/// Hint people that it's not `--skip-existing` but `--check-url`. +#[test] +fn skip_existing_redirect() { + let context = TestContext::new("3.12"); + + uv_snapshot!(context.filters(), context.publish() + .arg("--skip-existing") + .arg("--publish-url") + .arg("https://test.pypi.org/legacy/"), @r###" + success: false + exit_code: 2 + ----- stdout ----- + + ----- stderr ----- + warning: `uv publish` is experimental and may change without warning + error: `uv publish` does not support `--skip-existing`, use `--check-url` with the simple index URL instead. + "### + ); +} From 0f356e1c075c2e14d2a21d43e20b8b1c6b17a159 Mon Sep 17 00:00:00 2001 From: konstin Date: Mon, 4 Nov 2024 13:56:40 +0100 Subject: [PATCH 2/3] More context --- crates/uv/src/lib.rs | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/crates/uv/src/lib.rs b/crates/uv/src/lib.rs index aee1ce2d2940..bcd507a8d26e 100644 --- a/crates/uv/src/lib.rs +++ b/crates/uv/src/lib.rs @@ -1130,8 +1130,11 @@ async fn run(mut cli: Cli) -> Result { if args.skip_existing { bail!( - "`uv publish` does not support `--skip-existing`, \ - use `--check-url` with the simple index URL instead." + "`uv publish` does not support `--skip-existing` because there is not a \ + reliable way to identify when an upload fails due to an existing \ + distribution. Instead, use `--check-url` to provide the URL to the simple \ + API for your index. uv will check the index for existing distributions before \ + attempting uploads." ); } From 690e6b143d357ebdbd0f7ed6bf9e9061a87edbef Mon Sep 17 00:00:00 2001 From: Zanie Blue Date: Mon, 4 Nov 2024 17:11:26 -0600 Subject: [PATCH 3/3] Update snapshot --- crates/uv/tests/it/publish.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/crates/uv/tests/it/publish.rs b/crates/uv/tests/it/publish.rs index 74a1316b6bf5..e270498e8375 100644 --- a/crates/uv/tests/it/publish.rs +++ b/crates/uv/tests/it/publish.rs @@ -158,7 +158,7 @@ fn skip_existing_redirect() { ----- stderr ----- warning: `uv publish` is experimental and may change without warning - error: `uv publish` does not support `--skip-existing`, use `--check-url` with the simple index URL instead. + error: `uv publish` does not support `--skip-existing` because there is not a reliable way to identify when an upload fails due to an existing distribution. Instead, use `--check-url` to provide the URL to the simple API for your index. uv will check the index for existing distributions before attempting uploads. "### ); }