Skip to content

[CI] Add cibw-based wheel publishing to PyPI#19656

Open
tlopex wants to merge 1 commit into
apache:mainfrom
tlopex:pypi_official
Open

[CI] Add cibw-based wheel publishing to PyPI#19656
tlopex wants to merge 1 commit into
apache:mainfrom
tlopex:pypi_official

Conversation

@tlopex
Copy link
Copy Markdown
Member

@tlopex tlopex commented Jun 2, 2026

Add a workflow_dispatch pipeline that builds, tests, and publishes manylinux/ macOS/Windows wheels via cibuildwheel with OIDC trusted publishing.

Add a workflow_dispatch pipeline that builds, tests, and publishes manylinux/
macOS/Windows wheels via cibuildwheel with OIDC trusted publishing.
- publish_wheel.yml + build-wheel-for-publish action: per-OS/arch matrix,
  static-LLVM host builds, a separate build_cuda_runtime stage that compiles
  the libtvm_runtime_cuda sidecar and injects it via -DTVM_PACKAGE_EXTRA_LIBS,
  auditwheel/delocate/delvewheel repair, and post-upload install+import verify.
- pyproject.toml [tool.cibuildwheel]: manylinux_2_28 image pins, skips,
  test-command, per-platform repair commands.
- cmake: FindLLVM prefers static zstd; tvm_compiler links --no-relax +
  --as-needed on Linux; Library.cmake rpath/install helper reused by backends.
- tests/python/wheel: assert LLVM enabled and CUDA runtime bundled.
Copy link
Copy Markdown
Contributor

@gemini-code-assist gemini-code-assist Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request refactors the TVM wheel packaging and build process by introducing a standard cibuildwheel flow, adding helper scripts to build CUDA runtime sidecar libraries on Linux and Windows, and consolidating target library configurations with a new CMake helper. Key feedback includes moving pytest from core runtime dependencies to test dependencies in pyproject.toml, ensuring the fallback conda create command in the Windows build script cleans up partially populated directories, avoiding fragile ^ line continuations in the generated Windows batch file, and quoting ${USE_LLVM} in CMakeLists.txt to prevent syntax errors.

Important

The consumer version of Gemini Code Assist on GitHub is being sunset. Starting June 18, 2026, new organization installations will be blocked, and all code review activity will officially cease on July 17, 2026.
For more details on the timeline and next steps, please review the Help Documentation.

Comment thread pyproject.toml
Comment on lines 50 to 52
"psutil",
"scipy",
"tornado",
"pytest",
"typing_extensions",
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

high

The testing framework pytest is listed as a core runtime dependency in dependencies. Production users installing TVM do not need pytest to run inference or compile models. It should be moved to [dependency-groups] or [project.optional-dependencies] (e.g., under test or dev) to keep the production dependency graph minimal.

Suggested change
"psutil",
"scipy",
"tornado",
"pytest",
"typing_extensions",
"psutil",
"typing_extensions",

Comment on lines +47 to +48
"${conda_exe}" create -q -p "${cuda_prefix}" -c nvidia/label/cuda-13.0.2 cuda-toolkit -y \
|| "${conda_exe}" create -q -p "${cuda_prefix}" -c nvidia/label/cuda-13.0.2 cuda-toolkit --use-only-tar-bz2 -y
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

If the first conda create command fails halfway, the target directory ${cuda_prefix} may be left partially populated. The fallback command will then fail because the directory is not empty. Cleaning up the directory before retrying ensures the fallback command can run successfully.

Suggested change
"${conda_exe}" create -q -p "${cuda_prefix}" -c nvidia/label/cuda-13.0.2 cuda-toolkit -y \
|| "${conda_exe}" create -q -p "${cuda_prefix}" -c nvidia/label/cuda-13.0.2 cuda-toolkit --use-only-tar-bz2 -y
"${conda_exe}" create -q -p "${cuda_prefix}" -c nvidia/label/cuda-13.0.2 cuda-toolkit -y \
|| { rm -rf "${cuda_prefix_unix}" && "${conda_exe}" create -q -p "${cuda_prefix}" -c nvidia/label/cuda-13.0.2 cuda-toolkit --use-only-tar-bz2 -y; }

Comment on lines +84 to +92
cmake -S "${repo_root}" -B "${build_dir}" -G Ninja ^
-DCMAKE_BUILD_TYPE=Release ^
-DBUILD_TESTING=OFF ^
-DTVM_BUILD_PYTHON_MODULE=ON ^
-DUSE_CUDA="${cuda_root}" ^
-DUSE_LLVM=OFF ^
-DUSE_CUBLAS=OFF -DUSE_CUDNN=OFF -DUSE_CUTLASS=OFF -DUSE_NCCL=OFF -DUSE_NVTX=OFF ^
-DCMAKE_CUDA_COMPILER="${nvcc_exe}" ^
-DCMAKE_CUDA_FLAGS="-allow-unsupported-compiler" || exit /b 1
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

Using line continuations with ^ in a generated Windows batch file is fragile because any trailing whitespace after the ^ character will break the command. It is safer to write the entire cmake command on a single line to prevent accidental syntax errors during execution.

Suggested change
cmake -S "${repo_root}" -B "${build_dir}" -G Ninja ^
-DCMAKE_BUILD_TYPE=Release ^
-DBUILD_TESTING=OFF ^
-DTVM_BUILD_PYTHON_MODULE=ON ^
-DUSE_CUDA="${cuda_root}" ^
-DUSE_LLVM=OFF ^
-DUSE_CUBLAS=OFF -DUSE_CUDNN=OFF -DUSE_CUTLASS=OFF -DUSE_NCCL=OFF -DUSE_NVTX=OFF ^
-DCMAKE_CUDA_COMPILER="${nvcc_exe}" ^
-DCMAKE_CUDA_FLAGS="-allow-unsupported-compiler" || exit /b 1
cmake -S "${repo_root}" -B "${build_dir}" -G Ninja -DCMAKE_BUILD_TYPE=Release -DBUILD_TESTING=OFF -DTVM_BUILD_PYTHON_MODULE=ON -DUSE_CUDA="${cuda_root}" -DUSE_LLVM=OFF -DUSE_CUBLAS=OFF -DUSE_CUDNN=OFF -DUSE_CUTLASS=OFF -DUSE_NCCL=OFF -DUSE_NVTX=OFF -DCMAKE_CUDA_COMPILER="${nvcc_exe}" -DCMAKE_CUDA_FLAGS="-allow-unsupported-compiler" || exit /b 1

Comment thread CMakeLists.txt
# generation. Disabling linker relaxation keeps the GOT-indirect sequences and
# avoids the miscompilation; it is harmless when LLVM is linked dynamically.
# See binutils bug ld/25754.
if(CMAKE_SYSTEM_NAME STREQUAL "Linux" AND NOT ${USE_LLVM} MATCHES ${IS_FALSE_PATTERN})
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

In CMake, if ${USE_LLVM} is set to a path (e.g., to a specific llvm-config), expanding it unquoted in the if condition can cause syntax errors if the path contains spaces or special characters. Quoting the variable as "${USE_LLVM}" is safer and prevents potential configuration failures.

if(CMAKE_SYSTEM_NAME STREQUAL "Linux" AND NOT "${USE_LLVM}" MATCHES ${IS_FALSE_PATTERN})

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant