Skip to content

Commit 5bd86d3

Browse files
fix: remove nested zipfile open that shadowed outer zf in check_bundling
Co-authored-by: Cursor <cursoragent@cursor.com>
1 parent f69c6a1 commit 5bd86d3

1 file changed

Lines changed: 18 additions & 19 deletions

File tree

packaging/repair_wheel.py

Lines changed: 18 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -958,26 +958,25 @@ def _assert_third_party_licenses(zf, is_cuda, is_rocm):
958958
# RPATH so the dynamic linker finds AMD's own librocjpeg at
959959
# runtime (AMD's RPATH inside it then handles its transitive
960960
# deps). Verify the RPATH was patched by _patch_image_so_rpath_in_wheel.
961-
with zipfile.ZipFile(wheel) as zf:
962-
image_names = [n for n in zf.namelist() if "libtorchcodec_image" in n and n.endswith(".so")]
963-
if not image_names:
964-
raise RuntimeError(f"{wheel.name} does not contain libtorchcodec_image.so")
965-
with tempfile.TemporaryDirectory() as tmp:
966-
zf.extract(image_names[0], tmp)
967-
image_so = Path(tmp) / image_names[0]
968-
result = subprocess.run(
969-
["patchelf", "--print-rpath", str(image_so)],
970-
capture_output=True, text=True, check=True,
961+
image_names = [n for n in zf.namelist() if "libtorchcodec_image" in n and n.endswith(".so")]
962+
if not image_names:
963+
raise RuntimeError(f"{wheel.name} does not contain libtorchcodec_image.so")
964+
with tempfile.TemporaryDirectory() as tmp:
965+
zf.extract(image_names[0], tmp)
966+
image_so = Path(tmp) / image_names[0]
967+
result = subprocess.run(
968+
["patchelf", "--print-rpath", str(image_so)],
969+
capture_output=True, text=True, check=True,
970+
)
971+
rpath = result.stdout.strip()
972+
if "_rocm_sdk_core/lib" not in rpath and "/opt/rocm/lib" not in rpath:
973+
raise RuntimeError(
974+
f"{wheel.name}: libtorchcodec_image.so RPATH ({rpath!r}) "
975+
"does not contain _rocm_sdk_core/lib or /opt/rocm/lib. "
976+
"librocjpeg will not be found at runtime. "
977+
"Check that _patch_image_so_rpath_in_wheel ran correctly."
971978
)
972-
rpath = result.stdout.strip()
973-
if "_rocm_sdk_core/lib" not in rpath and "/opt/rocm/lib" not in rpath:
974-
raise RuntimeError(
975-
f"{wheel.name}: libtorchcodec_image.so RPATH ({rpath!r}) "
976-
"does not contain _rocm_sdk_core/lib or /opt/rocm/lib. "
977-
"librocjpeg will not be found at runtime. "
978-
"Check that _patch_image_so_rpath_in_wheel ran correctly."
979-
)
980-
print(f" libtorchcodec_image.so RPATH: {rpath}")
979+
print(f" libtorchcodec_image.so RPATH: {rpath}")
981980
if bundles_rocjpeg:
982981
raise RuntimeError(
983982
f"{wheel.name} bundles librocjpeg — this is intentionally "

0 commit comments

Comments
 (0)