@@ -11,7 +11,6 @@ use uv_cache::Cache;
1111use uv_client:: { AuthIntegration , BaseClient , BaseClientBuilder , RegistryClientBuilder } ;
1212use uv_configuration:: { KeyringProviderType , TrustedPublishing } ;
1313use uv_distribution_types:: { IndexCapabilities , IndexLocations , IndexUrl } ;
14- use uv_pep508:: VerbatimUrl ;
1514use uv_publish:: {
1615 CheckUrlClient , FormMetadata , PublishError , TrustedPublishResult , check_trusted_publishing,
1716 files_for_publishing, upload,
@@ -75,16 +74,15 @@ pub(crate) async fn publish(
7574 . publish_url
7675 . clone ( )
7776 . with_context ( || format ! ( "Index is missing a publish URL: `{index_name}`" ) ) ?;
78- let check_url = index. url . clone ( ) ;
79- ( publish_url, Some ( check_url) )
80- } else if token_store. is_known_url ( & publish_url) {
81- // If the user is publishing to a known index, construct the check URL from the publish
82- // URL.
83- let check_url = check_url. or_else ( || {
84- infer_check_url ( & publish_url)
85- . inspect ( |check_url| debug ! ( "Inferred check URL: {check_url}" ) )
86- } ) ;
87- ( publish_url, check_url)
77+
78+ // pyx has the same behavior as PyPI where uploads of identical
79+ // files + contents are idempotent, so we don't need to pre-check.
80+ if token_store. is_known_url ( & publish_url) {
81+ ( publish_url, None )
82+ } else {
83+ let check_url = index. url . clone ( ) ;
84+ ( publish_url, Some ( check_url) )
85+ }
8886 } else {
8987 ( publish_url, check_url)
9088 } ;
@@ -439,50 +437,6 @@ fn prompt_username_and_password() -> Result<(Option<String>, Option<String>)> {
439437 Ok ( ( Some ( username) , Some ( password) ) )
440438}
441439
442- /// Construct a Simple Index URL from a publish URL, if possible.
443- ///
444- /// Matches against a publish URL of the form `/v1/upload/{workspace}/{registry}` and returns
445- /// `/simple/{workspace}/{registry}`.
446- fn infer_check_url ( publish_url : & DisplaySafeUrl ) -> Option < IndexUrl > {
447- let mut segments = publish_url. path_segments ( ) ?;
448-
449- let v1 = segments. next ( ) ?;
450- if v1 != "v1" {
451- return None ;
452- }
453-
454- let upload = segments. next ( ) ?;
455- if upload != "upload" {
456- return None ;
457- }
458-
459- let workspace = segments. next ( ) ?;
460- if workspace. is_empty ( ) {
461- return None ;
462- }
463-
464- let registry = segments. next ( ) ?;
465- if registry. is_empty ( ) {
466- return None ;
467- }
468-
469- // Skip any empty segments (trailing slash handling)
470- for remaining in segments {
471- if !remaining. is_empty ( ) {
472- return None ;
473- }
474- }
475-
476- // Reconstruct the URL with `/simple/{workspace}/{registry}`.
477- let mut check_url = publish_url. clone ( ) ;
478- {
479- let mut segments = check_url. path_segments_mut ( ) . ok ( ) ?;
480- segments. clear ( ) ;
481- segments. push ( "simple" ) . push ( workspace) . push ( registry) ;
482- }
483- Some ( IndexUrl :: from ( VerbatimUrl :: from ( check_url) ) )
484- }
485-
486440#[ cfg( test) ]
487441mod tests {
488442 use super :: * ;
@@ -595,33 +549,4 @@ mod tests {
595549 @"The password can't be set both in the publish URL and in the CLI"
596550 ) ;
597551 }
598-
599- #[ test]
600- fn test_infer_check_url ( ) {
601- let url =
602- DisplaySafeUrl :: from_str ( "https://example.com/v1/upload/workspace/registry" ) . unwrap ( ) ;
603- let check_url = infer_check_url ( & url) ;
604- assert_eq ! (
605- check_url,
606- Some ( IndexUrl :: from_str( "https://example.com/simple/workspace/registry" ) . unwrap( ) )
607- ) ;
608-
609- let url =
610- DisplaySafeUrl :: from_str ( "https://example.com/v1/upload/workspace/registry/" ) . unwrap ( ) ;
611- let check_url = infer_check_url ( & url) ;
612- assert_eq ! (
613- check_url,
614- Some ( IndexUrl :: from_str( "https://example.com/simple/workspace/registry" ) . unwrap( ) )
615- ) ;
616-
617- let url =
618- DisplaySafeUrl :: from_str ( "https://example.com/upload/workspace/registry" ) . unwrap ( ) ;
619- let check_url = infer_check_url ( & url) ;
620- assert_eq ! ( check_url, None ) ;
621-
622- let url = DisplaySafeUrl :: from_str ( "https://example.com/upload/workspace/registry/package" )
623- . unwrap ( ) ;
624- let check_url = infer_check_url ( & url) ;
625- assert_eq ! ( check_url, None ) ;
626- }
627552}
0 commit comments