gemini-code-assist[bot] commented on code in PR #19664:
URL: https://github.com/apache/tvm/pull/19664#discussion_r3350926995


##########
pyproject.toml:
##########
@@ -219,7 +219,20 @@ test-command = "pytest -vvs 
{project}/tests/python/all-platform-minimal-test"
 repair-wheel-command = "auditwheel repair --exclude libtvm_ffi.so --exclude 
libtvm_runtime_cuda.so --exclude 'libcuda.so.*' --exclude 'libcudart.so.*' 
--exclude 'libnvrtc.so.*' --exclude 'libnvrtc-builtins.so.*' -w {dest_dir} 
{wheel}"
 
 [tool.cibuildwheel.macos]
-repair-wheel-command = '''bash -c 'set -euo pipefail; r="$(mktemp -d)"; 
delocate-wheel --ignore-missing-dependencies --exclude libtvm_ffi.dylib 
--require-archs {delocate_archs} -w "$r" -v "{wheel}"; python -m pip install -q 
wheel; u="$(mktemp -d)"; python -m wheel unpack "$r"/*.whl -d "$u"; find "$u" 
-type f \( -name "*.dylib" -o -name "*.so" \) -print0 | xargs -0 -n1 codesign 
--force --sign -; python -m wheel pack "$u"/*/ -d "{dest_dir}"' '''
+# Re-sign after delocate: its edits invalidate the ad-hoc signature of
+# libtvm_runtime.dylib (it links the --excluded @rpath/libtvm_ffi.dylib), and 
arm64
+# dyld SIGKILLs an invalidly-signed Mach-O. wheel is absent from the repair 
venv.
+repair-wheel-command = '''
+set -euo pipefail
+delocate-wheel --ignore-missing-dependencies --exclude libtvm_ffi.dylib 
--require-archs {delocate_archs} -w {dest_dir} -v {wheel}
+python -m pip install -q wheel
+TMP_DIR="$(mktemp -d)"
+python -m wheel unpack "{dest_dir}"/*.whl -d "$TMP_DIR"
+find "$TMP_DIR" -type f \( -name "*.dylib" -o -name "*.so" \) -exec codesign 
--force --sign - {} +
+rm -f "{dest_dir}"/*.whl
+python -m wheel pack "$TMP_DIR"/*/ -d {dest_dir}
+rm -rf "$TMP_DIR"
+'''

Review Comment:
   ![high](https://www.gstatic.com/codereviewagent/high-priority.svg)
   
   Using `{dest_dir}` as the output directory for `delocate-wheel` and then 
globbing/deleting files with `"{dest_dir}"/*.whl` is highly risky. In 
`cibuildwheel`, `{dest_dir}` is a shared directory where all repaired wheels 
are stored. If multiple wheels are built (e.g., for different Python versions 
or architectures), or if previous builds left wheels in `{dest_dir}`:
   1. `python -m wheel unpack "{dest_dir}"/*.whl` will fail because `wheel 
unpack` only accepts a single wheel file argument.
   2. `rm -f "{dest_dir}"/*.whl` will delete all previously built and repaired 
wheels in `{dest_dir}`.
   
   To fix this, use a separate temporary directory for the intermediate 
delocated wheel, similar to how the original implementation used `$r`.
   
   ```suggestion
   repair-wheel-command = '''
   set -euo pipefail
   DELOCATE_TMP_DIR="$(mktemp -d)"
   delocate-wheel --ignore-missing-dependencies --exclude libtvm_ffi.dylib 
--require-archs {delocate_archs} -w "$DELOCATE_TMP_DIR" -v {wheel}
   python -m pip install -q wheel
   TMP_DIR="$(mktemp -d)"
   python -m wheel unpack "$DELOCATE_TMP_DIR"/*.whl -d "$TMP_DIR"
   find "$TMP_DIR" -type f \( -name "*.dylib" -o -name "*.so" \) -exec codesign 
--force --sign - {} +
   python -m wheel pack "$TMP_DIR"/*/ -d {dest_dir}
   rm -rf "$DELOCATE_TMP_DIR" "$TMP_DIR"
   '''
   ```



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to