Skip to content

Commit c39936e

Browse files
konstinzanieb
andauthored
Publish: Hint at --skip-existing -> --check-url transition (#8803)
See #8531 (comment), we hint users coming from twine to use `--check-url` instead. > `uv publish` does not support `--skip-existing`, use `--check-url` with the simple index URL instead. --------- Co-authored-by: Zanie Blue <[email protected]>
1 parent f8ec797 commit c39936e

File tree

3 files changed

+35
-2
lines changed

3 files changed

+35
-2
lines changed

crates/uv-cli/src/lib.rs

+4-1
Original file line numberDiff line numberDiff line change
@@ -4882,8 +4882,11 @@ pub struct PublishArgs {
48824882
/// file succeeds even without `--check-url`, while most other indexes error.
48834883
///
48844884
/// The index must provide one of the supported hashes (SHA-256, SHA-384, or SHA-512).
4885-
#[arg(long,env = EnvVars::UV_PUBLISH_CHECK_URL)]
4885+
#[arg(long, env = EnvVars::UV_PUBLISH_CHECK_URL)]
48864886
pub check_url: Option<IndexUrl>,
4887+
4888+
#[arg(long, hide = true)]
4889+
pub skip_existing: bool,
48874890
}
48884891

48894892
/// See [PEP 517](https://peps.python.org/pep-0517/) and

crates/uv/src/lib.rs

+11-1
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ use std::path::Path;
77
use std::process::ExitCode;
88

99
use anstream::eprintln;
10-
use anyhow::Result;
10+
use anyhow::{bail, Result};
1111
use clap::error::{ContextKind, ContextValue};
1212
use clap::{CommandFactory, Parser};
1313
use owo_colors::OwoColorize;
@@ -1130,6 +1130,16 @@ async fn run(mut cli: Cli) -> Result<ExitStatus> {
11301130
warn_user_once!("`uv publish` is experimental and may change without warning");
11311131
}
11321132

1133+
if args.skip_existing {
1134+
bail!(
1135+
"`uv publish` does not support `--skip-existing` because there is not a \
1136+
reliable way to identify when an upload fails due to an existing \
1137+
distribution. Instead, use `--check-url` to provide the URL to the simple \
1138+
API for your index. uv will check the index for existing distributions before \
1139+
attempting uploads."
1140+
);
1141+
}
1142+
11331143
// Resolve the settings from the command-line arguments and workspace configuration.
11341144
let PublishSettings {
11351145
files,

crates/uv/tests/it/publish.rs

+20
Original file line numberDiff line numberDiff line change
@@ -142,3 +142,23 @@ fn no_credentials() {
142142
"###
143143
);
144144
}
145+
146+
/// Hint people that it's not `--skip-existing` but `--check-url`.
147+
#[test]
148+
fn skip_existing_redirect() {
149+
let context = TestContext::new("3.12");
150+
151+
uv_snapshot!(context.filters(), context.publish()
152+
.arg("--skip-existing")
153+
.arg("--publish-url")
154+
.arg("https://test.pypi.org/legacy/"), @r###"
155+
success: false
156+
exit_code: 2
157+
----- stdout -----
158+
159+
----- stderr -----
160+
warning: `uv publish` is experimental and may change without warning
161+
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.
162+
"###
163+
);
164+
}

0 commit comments

Comments
 (0)