From 8926c8d4b3136822f220c23d84b2cf1bb6f1c151 Mon Sep 17 00:00:00 2001 From: konstin Date: Wed, 2 Oct 2024 18:00:33 +0200 Subject: [PATCH 1/5] Hint at wrong endpoint in publish Improve hints when using the simple index URL instead of the upload URL in `uv publish`. This is the most common confusion when publishing, so we give it some extra care and put it more centrally in the CLI help. Fixes #7860 --- crates/uv-cli/src/lib.rs | 7 ++++--- crates/uv-publish/src/lib.rs | 36 +++++++++++++++++++++++++++--------- docs/reference/cli.md | 4 ++-- 3 files changed, 33 insertions(+), 14 deletions(-) diff --git a/crates/uv-cli/src/lib.rs b/crates/uv-cli/src/lib.rs index b4b0a176a47b9..4b73949be7ada 100644 --- a/crates/uv-cli/src/lib.rs +++ b/crates/uv-cli/src/lib.rs @@ -4380,7 +4380,8 @@ pub struct DisplayTreeArgs { #[arg(long)] pub no_dedupe: bool, - /// Show the reverse dependencies for the given package. This flag will invert the tree and display the packages that depend on the given package. + /// Show the reverse dependencies for the given package. This flag will invert the tree and + /// display the packages that depend on the given package. #[arg(long, alias = "reverse")] pub invert: bool, } @@ -4394,9 +4395,9 @@ pub struct PublishArgs { #[arg(default_value = "dist/*")] pub files: Vec, - /// The URL of the upload endpoint. + /// The URL of the upload endpoint (not the simple index URL!). /// - /// Note that this typically differs from the index URL. + /// Note that there are typically different URLs for index access ("simple") and index upload. /// /// Defaults to PyPI's publish URL (). /// diff --git a/crates/uv-publish/src/lib.rs b/crates/uv-publish/src/lib.rs index 4276d5b7ed25c..6704e79930fba 100644 --- a/crates/uv-publish/src/lib.rs +++ b/crates/uv-publish/src/lib.rs @@ -81,8 +81,12 @@ pub enum PublishSendError { ReqwestMiddleware(#[from] reqwest_middleware::Error), #[error("Upload failed with status {0}")] StatusNoBody(StatusCode, #[source] reqwest::Error), - #[error("Upload failed with status code {0}: {1}")] + #[error("Upload failed with status code {0}. Server says: {1}")] Status(StatusCode, String), + #[error("POST requests are not supported by the endpoint, are you using the simple index URL instead of the upload URL?")] + MethodNotAllowedNoBody, + #[error("POST requests are not supported by the endpoint, are you using the simple index URL instead of the upload URL? Server says: {0}")] + MethodNotAllowed(String), /// The registry returned a "403 Forbidden". #[error("Permission denied (status code {0}): {1}")] PermissionDenied(StatusCode, String), @@ -573,18 +577,32 @@ async fn handle_response(registry: &Url, response: Response) -> Result ResultThis setting has no effect when used in the uv pip interface.

-
--publish-url publish-url

The URL of the upload endpoint.

+
--publish-url publish-url

The URL of the upload endpoint (not the simple index URL!).

-

Note that this typically differs from the index URL.

+

Note that there are typically different URLs for index access ("simple") and index upload.

Defaults to PyPI’s publish URL (<https://upload.pypi.org/legacy/>).

From 6647915bf3609a7c39072a9d87d05289e4dba7d5 Mon Sep 17 00:00:00 2001 From: konstin Date: Fri, 4 Oct 2024 11:09:08 +0200 Subject: [PATCH 2/5] Review --- crates/uv-cli/src/lib.rs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/crates/uv-cli/src/lib.rs b/crates/uv-cli/src/lib.rs index 4b73949be7ada..e207fc7d0e7ea 100644 --- a/crates/uv-cli/src/lib.rs +++ b/crates/uv-cli/src/lib.rs @@ -4397,7 +4397,8 @@ pub struct PublishArgs { /// The URL of the upload endpoint (not the simple index URL!). /// - /// Note that there are typically different URLs for index access ("simple") and index upload. + /// Note that there are typically different URLs for index access (e.g., `https:://.../simple`) + /// and index upload. /// /// Defaults to PyPI's publish URL (). /// From 67c0d408bb5260486c542c2761d102e0c9cbf190 Mon Sep 17 00:00:00 2001 From: konstin Date: Fri, 4 Oct 2024 11:12:57 +0200 Subject: [PATCH 3/5] generate-all --- docs/reference/cli.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/reference/cli.md b/docs/reference/cli.md index 7ffc4100533e0..2052fc68a09a2 100644 --- a/docs/reference/cli.md +++ b/docs/reference/cli.md @@ -7188,7 +7188,7 @@ uv publish [OPTIONS] [FILES]...
--publish-url publish-url

The URL of the upload endpoint (not the simple index URL!).

-

Note that there are typically different URLs for index access ("simple") and index upload.

+

Note that there are typically different URLs for index access (e.g., https:://.../simple) and index upload.

Defaults to PyPI’s publish URL (<https://upload.pypi.org/legacy/>).

From 86f948952bdf81e8dd3b5ba5cfc0671d6ab0fdd6 Mon Sep 17 00:00:00 2001 From: konsti Date: Mon, 7 Oct 2024 19:12:04 +0200 Subject: [PATCH 4/5] Update crates/uv-cli/src/lib.rs Co-authored-by: Zanie Blue --- crates/uv-cli/src/lib.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/crates/uv-cli/src/lib.rs b/crates/uv-cli/src/lib.rs index e207fc7d0e7ea..5e4a108363649 100644 --- a/crates/uv-cli/src/lib.rs +++ b/crates/uv-cli/src/lib.rs @@ -4395,7 +4395,7 @@ pub struct PublishArgs { #[arg(default_value = "dist/*")] pub files: Vec, - /// The URL of the upload endpoint (not the simple index URL!). + /// The URL of the upload endpoint (not the index URL). /// /// Note that there are typically different URLs for index access (e.g., `https:://.../simple`) /// and index upload. From 397c46c0f5f86cff4668399abdf53755c65d931d Mon Sep 17 00:00:00 2001 From: Zanie Blue Date: Tue, 8 Oct 2024 14:08:46 -0500 Subject: [PATCH 5/5] Update docs --- docs/reference/cli.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/reference/cli.md b/docs/reference/cli.md index 2052fc68a09a2..6df0823f67991 100644 --- a/docs/reference/cli.md +++ b/docs/reference/cli.md @@ -7186,7 +7186,7 @@ uv publish [OPTIONS] [FILES]...

This setting has no effect when used in the uv pip interface.

-
--publish-url publish-url

The URL of the upload endpoint (not the simple index URL!).

+
--publish-url publish-url

The URL of the upload endpoint (not the index URL).

Note that there are typically different URLs for index access (e.g., https:://.../simple) and index upload.