From 25045cb3e839bc4b661034065134190b57786239 Mon Sep 17 00:00:00 2001 From: Charlie Marsh Date: Mon, 9 Dec 2024 17:30:24 -0500 Subject: [PATCH] Avoid 403 error hint for PyTorch URLs (#9750) ## Summary Closes https://github.com/astral-sh/uv/issues/9746. --- crates/uv-resolver/src/pubgrub/report.rs | 6 ++++++ crates/uv/tests/it/lock.rs | 2 -- crates/uv/tests/it/pip_compile.rs | 2 -- 3 files changed, 6 insertions(+), 4 deletions(-) diff --git a/crates/uv-resolver/src/pubgrub/report.rs b/crates/uv-resolver/src/pubgrub/report.rs index 3d5d5e2f5664..3b86ccfcbe94 100644 --- a/crates/uv-resolver/src/pubgrub/report.rs +++ b/crates/uv-resolver/src/pubgrub/report.rs @@ -793,6 +793,12 @@ impl PubGrubReportFormatter<'_> { }); } if index_capabilities.forbidden(&index.url) { + // If the index is a PyTorch index (e.g., `https://download.pytorch.org/whl/cu118`), + // avoid noting the lack of credentials. PyTorch returns a 403 (Forbidden) status + // code for any package that does not exist. + if index.url.url().host_str() == Some("download.pytorch.org") { + continue; + } hints.insert(PubGrubHint::ForbiddenIndex { index: index.url.clone(), }); diff --git a/crates/uv/tests/it/lock.rs b/crates/uv/tests/it/lock.rs index f0956f851ed4..5629ef9ca5ed 100644 --- a/crates/uv/tests/it/lock.rs +++ b/crates/uv/tests/it/lock.rs @@ -14017,8 +14017,6 @@ fn lock_default_index() -> Result<()> { ----- stderr ----- × No solution found when resolving dependencies: ╰─▶ Because iniconfig was not found in the package registry and your project depends on iniconfig, we can conclude that your project's requirements are unsatisfiable. - - hint: An index URL (https://download.pytorch.org/whl/cu121) could not be queried due to a lack of valid authentication credentials (403 Forbidden). "###); let lock = fs_err::read_to_string(context.temp_dir.join("uv.lock")).unwrap(); diff --git a/crates/uv/tests/it/pip_compile.rs b/crates/uv/tests/it/pip_compile.rs index a132e7a48768..7cefebdc76d9 100644 --- a/crates/uv/tests/it/pip_compile.rs +++ b/crates/uv/tests/it/pip_compile.rs @@ -6703,8 +6703,6 @@ fn index_url_in_requirements() -> Result<()> { ----- stderr ----- × No solution found when resolving dependencies: ╰─▶ Because anyio was not found in the package registry and you require anyio<4, we can conclude that your requirements are unsatisfiable. - - hint: An index URL (https://download.pytorch.org/whl) could not be queried due to a lack of valid authentication credentials (403 Forbidden). "### );