Skip to content

Commit a6bcfcb

Browse files
authored
Fix rendering of injected retained-wheel links (#8533)
Follow-up to #8532, which is live on the nightly index: https://download.pytorch.org/whl/nightly/nvidia-cudnn-cu12/ Two rendering defects in the injected link: 1. **Missing separator.** `pypi.nvidia.com` does not terminate its final anchor with a `<br>`, so the injected link rendered on the same line as the last upstream wheel: ``` nvidia_cudnn_cu12-9.9.0.52-py3-none-win_amd64.whl nvidia_cudnn_cu12-9.1.0.70-py3-none-manylinux2014_x86_64.whl ``` Fixed by appending the missing `<br/>` after the final upstream `</a>` before injecting, only when one is not already there. 2. **Wrong indentation.** The block was spliced in with `html.replace("</body>", ...)`, which left the closing tag's two leading spaces in front of the block, so the injected anchor came out at six spaces instead of four. Now matched against the indented tag. Both are specific to the NVIDIA index. `append_preview_numpy_wheels()` is unaffected and untouched: the PyPI simple index puts its anchors at indent 0, has `</body>` at column 0, and does terminate its last anchor with a `<br/>` -- confirmed against the live https://download.pytorch.org/whl/nightly/numpy/ index, whose injected links are correctly indented and separated. ## Verification Ran the full `upload_package_using_simple_index` path against the live upstream index with a stubbed S3: - injected anchor indent is 4 (was 6), and the preceding upstream anchor now ends with `<br/>` - exactly one `<br/>` added, no `<br/><br/>`, and re-running on already-patched HTML is a no-op - pip's `parse_links` still returns 151 links, with the root-relative href resolving against the serving host and the sha256 recognised - stripping tags and expanding `<br>` puts the last two wheels on separate rendered lines
1 parent 90a18ed commit a6bcfcb

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
@@ -1202,8 +1202,18 @@ def append_retained_wheels(html: str, pkg_name: str, prefix: str) -> str:
12021202
f"for {pkg_name} under {prefix}"
12031203
)
12041204
block = "\n".join(additions)
1205-
if "</body>" in html:
1206-
return html.replace("</body>", f"{block}\n </body>", 1)
1205+
1206+
# pypi.nvidia.com does not terminate its final anchor with a <br>, which
1207+
# would leave the first injected link on the same rendered line.
1208+
head, anchor_end, tail = html.rpartition("</a>")
1209+
if anchor_end and "<br" not in tail:
1210+
html = f"{head}{anchor_end}<br/>{tail}"
1211+
1212+
# Match on the indented closing tag: replacing the bare tag would leave its
1213+
# leading whitespace in front of the injected block.
1214+
for marker in (" </body>", "</body>"):
1215+
if marker in html:
1216+
return html.replace(marker, f"{block}\n{marker}", 1)
12071217
return f"{html}\n{block}\n"
12081218

12091219

0 commit comments

Comments
 (0)