Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Publish: Hint at --skip-existing -> --check-url transition #8803

Merged
merged 4 commits into from
Nov 4, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
5 changes: 4 additions & 1 deletion crates/uv-cli/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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<IndexUrl>,

#[arg(long, hide = true)]
pub skip_existing: bool,
}

/// See [PEP 517](https://peps.python.org/pep-0517/) and
Expand Down
9 changes: 8 additions & 1 deletion crates/uv/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -1128,6 +1128,13 @@ async fn run(mut cli: Cli) -> Result<ExitStatus> {
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."
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you give users a little more context here?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

(I think this will be fairly common to encounter and it seems worth explaining why the API is different)

Copy link
Member Author

@konstin konstin Nov 4, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Like what sort of context? Explaining why --skip-existing is broken?

Copy link
Member

@zanieb zanieb Nov 4, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah like

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.

);
}

// Resolve the settings from the command-line arguments and workspace configuration.
let PublishSettings {
files,
Expand Down
20 changes: 20 additions & 0 deletions crates/uv/tests/it/publish.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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.
"###
);
}
Loading