Skip to content

Commit ceb1c81

Browse files
committed
Fix ROCm index URLs dropping the parent-directory hop
Follow-up to #8436. AMD serves a per-package index at whl-multi-arch/<package>/ but stores the wheels flat in whl-multi-arch/, so every href is "../<wheel>.whl". replace_relative_links_with_absolute() normalised those with str.lstrip("./"), which strips leading "." and "/" *characters* rather than a prefix, so "../x.whl" collapsed to "x.whl" and was joined onto the package URL. The published indices therefore point at whl-multi-arch/<package>/<wheel>.whl, which returns HTTP 403: https://download.pytorch.org/whl/nightly/rocm7.14/rocm-sdk-device-gfx1010/ Resolve the href with urllib.parse.urljoin instead, which honours the parent hop. Scoped to ROCm via is_amd_package(): NVIDIA and PyPI indices do not use "../" hrefs and keep the existing code path.
1 parent 0be39b5 commit ceb1c81

1 file changed

Lines changed: 12 additions & 2 deletions

File tree

s3_management/update_dependencies.py

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
import re
33
import time
44
from typing import Dict, List
5+
from urllib.parse import urljoin
56

67
import boto3 # type: ignore[import-untyped]
78

@@ -836,13 +837,16 @@ def download(url: str) -> bytes:
836837
return conn.read()
837838

838839

839-
def replace_relative_links_with_absolute(html: str, base_url: str) -> str:
840+
def replace_relative_links_with_absolute(
841+
html: str, base_url: str, resolve_relative_paths: bool = False
842+
) -> str:
840843
"""
841844
Replace all relative links in HTML with absolute links.
842845
843846
Args:
844847
html: HTML content as string
845848
base_url: Base URL to prepend to relative links
849+
resolve_relative_paths: Resolve "../" segments against base_url (ROCm only)
846850
847851
Returns:
848852
Modified HTML with absolute links
@@ -864,6 +868,10 @@ def replace_href(match):
864868
):
865869
return full_match
866870

871+
# ROCm wheels sit flat in whl-multi-arch/, so AMD hrefs are "../<wheel>.whl"
872+
if resolve_relative_paths:
873+
return f'href="{urljoin(base_url, url)}"'
874+
867875
# Remove leading ./ or /
868876
url = url.lstrip("./")
869877
url = url.lstrip("/")
@@ -902,7 +910,9 @@ def upload_index_html(
902910
) -> None:
903911
"""Upload modified index.html to S3 and R2 with absolute links"""
904912
# Replace relative links with absolute links
905-
modified_html = replace_relative_links_with_absolute(html, base_url)
913+
modified_html = replace_relative_links_with_absolute(
914+
html, base_url, resolve_relative_paths=is_amd_package(pkg_name)
915+
)
906916

907917
index_key = f"{prefix}/{pkg_name}/index.html"
908918

0 commit comments

Comments
 (0)