Skip to content

Commit e50c021

Browse files
authored
Only copy external-link index.html for PACKAGE_LINKS_ALLOW_LIST packages (#8115) (#8134)
## Summary Fixes #8115 — XPU nightly wheels fail to install because runtime deps such as `tcmlib==1.5.0` disappear from `https://download.pytorch.org/whl/nightly/xpu/`. ## Root cause `PACKAGE_LINKS_ALLOW_LIST` packages (the `torch_xpu` deps like `tcmlib`, plus `numpy`, `nvidia-*`, ...) are link packages whose `index.html` points at external sources (PyPI CDN / `pypi.nvidia.com`). The copy-from-parent step copied the parent index into each subdir **unconditionally**. When the parent index was a relative-path, S3-wheel index (generated from the wheels that physically live under the subdir), it overwrote the real links index and dropped externally-hosted versions such as `tcmlib==1.5.0`. ## Fix Guard the copy: only copy a links package's `index.html` when it actually contains external links (`files.pythonhosted.org` or `pypi.nvidia.com`), and skip it when it only has relative paths. Everything else is unchanged. ## Test plan - `python s3_management/manage_v2.py whl/nightly --do-not-upload` and confirm `whl/nightly/xpu/tcmlib/index.html` retains its external (PyPI) links incl. `1.5.0`, while `numpy`/`nvidia-*` still propagate into each `cu*`/`xpu` subdir.
1 parent 2f4c5ad commit e50c021

1 file changed

Lines changed: 33 additions & 0 deletions

File tree

s3_management/manage_v2.py

100755100644
Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -583,6 +583,13 @@ def safe_parse_version(ver_str: str) -> Version:
583583
return Version("0.0.0")
584584

585585

586+
def index_has_external_links(html: str) -> bool:
587+
# A links package index must point at external sources (PyPI CDN /
588+
# pypi.nvidia.com). A relative-path index is S3-wheel-based and must not
589+
# overwrite the real links index. See pytorch/test-infra#8115
590+
return "files.pythonhosted.org" in html or "pypi.nvidia.com" in html
591+
592+
586593
class S3Index:
587594
def __init__(self, objects: List[S3Object], prefix: str) -> None:
588595
self.objects = objects
@@ -1067,6 +1074,19 @@ def upload_package_index(pkg_name: str) -> None:
10671074
root_obj = BUCKET.Object(key=root_index_key)
10681075
root_index_html = root_obj.get()["Body"].read().decode("utf-8")
10691076

1077+
# For links packages, only copy an index that points at
1078+
# external sources; skip a relative-path (S3 wheel) index
1079+
# so it cannot overwrite the real links index. Non-links
1080+
# packages are unaffected (they never reach this branch).
1081+
if (
1082+
pkg_name.lower() in PACKAGE_LINKS_ALLOW_LIST
1083+
and not index_has_external_links(root_index_html)
1084+
):
1085+
print(
1086+
f"INFO: Skipping copy of {root_index_key}: no external links"
1087+
)
1088+
return
1089+
10701090
# Upload to subdirectory in S3
10711091
BUCKET.Object(key=f"{subdir}/{compat_pkg_name}/index.html").put(
10721092
ACL="public-read",
@@ -1228,6 +1248,19 @@ def save_pep503_htmls(self) -> None:
12281248
with open(root_index_path, mode="r", encoding="utf-8") as src:
12291249
root_index_html = src.read()
12301250

1251+
# For links packages, only copy an index that points at
1252+
# external sources; skip a relative-path (S3 wheel) index
1253+
# so it cannot overwrite the real links index. Non-links
1254+
# packages are unaffected (they never reach this branch).
1255+
if (
1256+
pkg_name.lower() in PACKAGE_LINKS_ALLOW_LIST
1257+
and not index_has_external_links(root_index_html)
1258+
):
1259+
print(
1260+
f"INFO: Skipping copy of {root_index_path}: no external links"
1261+
)
1262+
continue
1263+
12311264
# Save to subdirectory
12321265
with open(
12331266
path.join(pkg_dir, "index.html"),

0 commit comments

Comments
 (0)