From d65f6a7194b9589101b4c8d1bcb0cf0136ff63d3 Mon Sep 17 00:00:00 2001 From: Jaswant Panchumarti Date: Fri, 12 Jun 2026 10:29:11 -0400 Subject: [PATCH 1/3] Move static cibuildwheel config into pyproject.toml Relocate the CIBW environment variables (SDK index, GL build deps, retag-only repair command, test command) from build-wheels.yml into [tool.cibuildwheel] so local builds and CI share the same settings; CI now only selects the build target. Document local wheel builds in the README. --- .github/workflows/build-wheels.yml | 25 ++--------------- .github/workflows/ci.yml | 4 --- .github/workflows/release.yml | 4 --- README.md | 45 ++++++++++++++++++++++++++++++ pyproject.toml | 33 +++++++++++++++++++++- 5 files changed, 80 insertions(+), 31 deletions(-) diff --git a/.github/workflows/build-wheels.yml b/.github/workflows/build-wheels.yml index b31312e..34610b3 100644 --- a/.github/workflows/build-wheels.yml +++ b/.github/workflows/build-wheels.yml @@ -12,11 +12,7 @@ on: required: true type: string python-version: - description: "CIBW build target (e.g., 3.10)" - required: true - type: string - platform-tag: - description: "Wheel platform tag to apply after building." + description: "Python version to install on host (e.g., 3.10)" required: true type: string @@ -24,25 +20,10 @@ jobs: build-test: runs-on: ${{ inputs.os }} + # Static cibuildwheel config lives in [tool.cibuildwheel] in pyproject.toml; + # CI only selects the build target. env: - PIP_EXTRA_INDEX_URL: "https://vtk.org/files/wheel-sdks" - CIBW_ENVIRONMENT_PASS_LINUX: "PIP_EXTRA_INDEX_URL" CIBW_BUILD: ${{ inputs.build-target }} - CIBW_TEST_COMMAND: "python -m pytest {project} --verbose" - # Required to make tests pass (VTK needs them) - CIBW_BEFORE_ALL_LINUX: "yum install -y mesa-libGL-devel glx-utils freeglut-devel" - # Global test setup - CIBW_TEST_REQUIRES: "pytest virtualenv" - # Do not repair, everything is already put just as needed to make it work - CIBW_REPAIR_WHEEL_COMMAND_LINUX: " - python -m pip install wheel && - python -m wheel tags --platform-tag ${{ inputs.platform-tag }} --remove {wheel} && - cp $(dirname {wheel})/vtk_streaming*.whl {dest_dir}" - # same as above, we don't patch the wheel on Mac too. - CIBW_REPAIR_WHEEL_COMMAND_MACOS: " - python -m pip install wheel && - python -m wheel tags --platform-tag ${{ inputs.platform-tag }} --remove {wheel} && - cp $(dirname {wheel})/vtk_streaming*.whl {dest_dir}" steps: - uses: actions/checkout@v4 diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index c249c5c..a5aba51 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -17,17 +17,13 @@ jobs: python-version: "3.10" # OS name to ciwheelbuild platform name - os: ubuntu-latest - platform-tag: manylinux_2_28_x86_64 build-target: "manylinux_x86_64" - os: windows-latest - platform-tag: win_amd64 build-target: "win_amd64" - os: macos-latest - platform-tag: macosx_11_0_arm64 build-target: "macosx_arm64" uses: ./.github/workflows/build-wheels.yml with: os: ${{ matrix.os }} build-target: ${{ matrix.py-abi }}-${{ matrix.build-target }} python-version: ${{ matrix.python-version }} - platform-tag: ${{ matrix.platform-tag }} diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 45accfe..b5ccb10 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -21,20 +21,16 @@ jobs: python-version: "3.13" # OS name to ciwheelbuild platform name - os: ubuntu-latest - platform-tag: manylinux_2_28_x86_64 build-target: "manylinux_x86_64" - os: windows-latest - platform-tag: win_amd64 build-target: "win_amd64" - os: macos-latest - platform-tag: macosx_11_0_arm64 build-target: "macosx_arm64" uses: ./.github/workflows/build-wheels.yml with: os: ${{ matrix.os }} build-target: ${{ matrix.py-abi }}-${{ matrix.build-target }} python-version: ${{ matrix.python-version }} - platform-tag: ${{ matrix.platform-tag }} upload-pypi: name: Push runtime wheel on PyPi diff --git a/README.md b/README.md index bab6337..80bf730 100644 --- a/README.md +++ b/README.md @@ -18,6 +18,51 @@ It is currently based on VTK 9.6.0. pip install vtk-streaming ``` +## Building from source + +Wheels are built with [cibuildwheel](https://cibuildwheel.pypa.io/). + +Requirements: +- Linux: [Docker](https://www.docker.com/) (the build runs in a manylinux container). +- Windows: MSVC (Visual Studio Build Tools). (ensure visual studio environment is initialized) +- macOS: Xcode command line tools. (`xcode-select --install` should have completed successfully) + +Build a wheel for one Python/platform target: + +```sh +# Linux +uvx cibuildwheel --only cp310-manylinux_x86_64 + +# Windows +uvx cibuildwheel --only cp310-win_amd64 + +# macOS +uvx cibuildwheel --only cp310-macosx_arm64 +``` + +`uvx` comes with [uv](https://docs.astral.sh/uv/); alternatively +`pipx run cibuildwheel` or if you use `pip`: + +```sh +pip install cibuildwheel + +# Linux +cibuildwheel --only cp310-manylinux_x86_64 + +# Windows +cibuildwheel --only cp310-win_amd64 + +# macOS +cibuildwheel --only cp310-macosx_arm64 +``` + +Substitute `cp310`/`cp311`/`cp312`/`cp313` to target other Python versions. The wheel is +written to `wheelhouse/` and can be installed directly: + +```sh +pip install wheelhouse/vtk_streaming-*.whl +``` + ## Example ```py diff --git a/pyproject.toml b/pyproject.toml index 4b242b9..c07a0ac 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -47,4 +47,35 @@ download = "https://pypi.org/project/slicer-layer-dm/#files" tracker = "https://github.com/Kitware/VTKStreaming/issues" [project.optional-dependencies] -test = ["pytest", "virtualenv"] \ No newline at end of file +test = ["pytest", "virtualenv"] + +# Shared cibuildwheel config; CI (build-wheels.yml) only adds the +# per-matrix CIBW_BUILD selection. Locally, build the same wheel with e.g. +# `uvx cibuildwheel --only cp310-manylinux_x86_64`. +[tool.cibuildwheel] +# pip installs build requirements inside the build environment, so it needs +# the VTK wheel-SDK index to resolve vtk-sdk. +environment = { PIP_EXTRA_INDEX_URL = "https://vtk.org/files/wheel-sdks" } +# No vtk-sdk wheels exist for musllinux. +skip = "*-musllinux_*" +test-requires = ["pytest", "virtualenv"] +test-command = "python -m pytest {project} --verbose" + +[tool.cibuildwheel.linux] +# Required to make tests pass (VTK needs them) +before-all = "yum install -y mesa-libGL-devel glx-utils freeglut-devel" +# Do not repair (no auditwheel), everything is already put just as needed to +# make it work; only retag the platform tag. +repair-wheel-command = [ + "python -m pip install wheel", + "python -m wheel tags --platform-tag manylinux_2_28_x86_64 --remove {wheel}", + "cp $(dirname {wheel})/vtk_streaming*.whl {dest_dir}", +] + +[tool.cibuildwheel.macos] +# Same as Linux: no delocate, only retag the platform tag. +repair-wheel-command = [ + "python -m pip install wheel", + "python -m wheel tags --platform-tag macosx_11_0_arm64 --remove {wheel}", + "cp $(dirname {wheel})/vtk_streaming*.whl {dest_dir}", +] From 85a0ccf94041426acbbcb6ad67efe05d27b026ce Mon Sep 17 00:00:00 2001 From: Jaswant Panchumarti Date: Fri, 12 Jun 2026 11:08:34 -0400 Subject: [PATCH 2/3] fix CI workflow to run on pull requests and pushes to wheel branch --- .github/workflows/ci.yml | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index a5aba51..743cba5 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -1,8 +1,10 @@ -name: CI Slicer Core +name: CI VTK Streaming on: pull_request: - branches: [master] + branches: [wheel] + push: + branches: [wheel] jobs: build-test: From c8b9f5f5481e676cf975226b89019dd1b6704b63 Mon Sep 17 00:00:00 2001 From: Jaswant Panchumarti Date: Fri, 12 Jun 2026 15:38:57 -0400 Subject: [PATCH 3/3] Add build instructions without cibw --- README.md | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) diff --git a/README.md b/README.md index 80bf730..7b17959 100644 --- a/README.md +++ b/README.md @@ -20,6 +20,32 @@ pip install vtk-streaming ## Building from source +# Build for quick development + +Requirements: +- Linux: A C++ compiler (GCC 11.4+ or any other compiler supported by VTK.) +- Windows: MSVC (Visual Studio Build Tools). (ensure visual studio environment is initialized) +- macOS: Xcode command line tools. (`xcode-select --install` should have completed successfully) + +## Linux/macOS + +```sh +python3 -m venv .venv +. .venv/bin/activate +pip install -e . --extra-index-url https://vtk.org/files/wheel-sdks +``` + +# Windows + +Open a powershell with MSVC initialized (ex: Visual Studio Developer Powershell) + +```sh +python3 -m venv .venv +.venv/bin/activate.ps1 +pip install -e . --extra-index-url https://vtk.org/files/wheel-sdks +``` + +# Reproduce CI artifacts Wheels are built with [cibuildwheel](https://cibuildwheel.pypa.io/). Requirements: