mirror of
https://github.com/astral-sh/uv.git
synced 2025-08-04 19:08:04 +00:00
Avoid enforcing URL check on initial publish (#10182)
## Summary Closes https://github.com/astral-sh/uv/issues/10174.
This commit is contained in:
parent
b52d48973f
commit
2f5badddbb
3 changed files with 27 additions and 9 deletions
|
@ -21,7 +21,7 @@ use std::{env, fmt, io};
|
|||
use thiserror::Error;
|
||||
use tokio::io::{AsyncReadExt, BufReader};
|
||||
use tokio_util::io::ReaderStream;
|
||||
use tracing::{debug, enabled, trace, Level};
|
||||
use tracing::{debug, enabled, trace, warn, Level};
|
||||
use url::Url;
|
||||
use uv_client::{BaseClient, OwnedArchive, RegistryClientBuilder, UvRetryableStrategy};
|
||||
use uv_configuration::{KeyringProviderType, TrustedPublishing};
|
||||
|
@ -469,10 +469,24 @@ pub async fn check_url(
|
|||
.wrap_existing(client);
|
||||
|
||||
debug!("Checking for {filename} in the registry");
|
||||
let response = registry_client
|
||||
let response = match registry_client
|
||||
.simple(filename.name(), Some(index_url), index_capabilities)
|
||||
.await
|
||||
.map_err(PublishError::CheckUrlIndex)?;
|
||||
{
|
||||
Ok(response) => response,
|
||||
Err(err) => {
|
||||
return match err.into_kind() {
|
||||
uv_client::ErrorKind::PackageNotFound(_) => {
|
||||
// The package doesn't exist, so we can't have uploaded it.
|
||||
warn!(
|
||||
"Package not found in the registry; skipping upload check for {filename}"
|
||||
);
|
||||
Ok(false)
|
||||
}
|
||||
kind => Err(PublishError::CheckUrlIndex(kind.into())),
|
||||
};
|
||||
}
|
||||
};
|
||||
let [(_, simple_metadata)] = response.as_slice() else {
|
||||
unreachable!("We queried a single index, we must get a single response");
|
||||
};
|
||||
|
|
|
@ -173,7 +173,7 @@ pub(crate) async fn publish(
|
|||
}
|
||||
} else if check_url.is_none() {
|
||||
warn_user_once!(
|
||||
"Using `--keyring-provider` with a password or token and no check url has no effect"
|
||||
"Using `--keyring-provider` with a password or token and no check URL has no effect"
|
||||
);
|
||||
} else {
|
||||
// We may be using the keyring for the simple index.
|
||||
|
|
|
@ -241,8 +241,9 @@ fn check_keyring_behaviours() {
|
|||
----- stderr -----
|
||||
warning: `uv publish` is experimental and may change without warning
|
||||
Publishing 1 file to https://test.pypi.org/legacy/?ok
|
||||
error: Failed to query check URL
|
||||
Caused by: Package `ok` was not found in the registry
|
||||
Uploading ok-1.0.0-py3-none-any.whl ([SIZE])
|
||||
error: Failed to publish `../../scripts/links/ok-1.0.0-py3-none-any.whl` to https://test.pypi.org/legacy/?ok
|
||||
Caused by: Upload failed with status code 403 Forbidden. Server says: 403 Username/Password authentication is no longer supported. Migrate to API Tokens or Trusted Publishers instead. See https://test.pypi.org/help/#apitoken and https://test.pypi.org/help/#trusted-publishers
|
||||
"###
|
||||
);
|
||||
|
||||
|
@ -265,7 +266,7 @@ fn check_keyring_behaviours() {
|
|||
----- stderr -----
|
||||
warning: `uv publish` is experimental and may change without warning
|
||||
Publishing 1 file to https://test.pypi.org/legacy/?ok
|
||||
warning: Using `--keyring-provider` with a password or token and no check url has no effect
|
||||
warning: Using `--keyring-provider` with a password or token and no check URL has no effect
|
||||
Uploading ok-1.0.0-py3-none-any.whl ([SIZE])
|
||||
error: Failed to publish `../../scripts/links/ok-1.0.0-py3-none-any.whl` to https://test.pypi.org/legacy/?ok
|
||||
Caused by: Upload failed with status code 403 Forbidden. Server says: 403 Username/Password authentication is no longer supported. Migrate to API Tokens or Trusted Publishers instead. See https://test.pypi.org/help/#apitoken and https://test.pypi.org/help/#trusted-publishers
|
||||
|
@ -295,8 +296,11 @@ fn check_keyring_behaviours() {
|
|||
Request for dummy@https://test.pypi.org/legacy/?ok
|
||||
Request for dummy@test.pypi.org
|
||||
warning: Keyring has no password for URL `https://test.pypi.org/legacy/?ok` and username `dummy`
|
||||
error: Failed to query check URL
|
||||
Caused by: Package `ok` was not found in the registry
|
||||
Uploading ok-1.0.0-py3-none-any.whl ([SIZE])
|
||||
Request for dummy@https://test.pypi.org/legacy/?ok
|
||||
Request for dummy@test.pypi.org
|
||||
error: Failed to publish `../../scripts/links/ok-1.0.0-py3-none-any.whl` to https://test.pypi.org/legacy/?ok
|
||||
Caused by: Upload failed with status code 403 Forbidden. Server says: 403 Username/Password authentication is no longer supported. Migrate to API Tokens or Trusted Publishers instead. See https://test.pypi.org/help/#apitoken and https://test.pypi.org/help/#trusted-publishers
|
||||
"###
|
||||
);
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue