Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 3 additions & 22 deletions .github/workflows/build-wheels.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,37 +12,18 @@ 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

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
Expand Down
10 changes: 4 additions & 6 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -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:
Expand All @@ -17,17 +19,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 }}
4 changes: 0 additions & 4 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
71 changes: 71 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,77 @@ It is currently based on VTK 9.6.0.
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:
- 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
Expand Down
33 changes: 32 additions & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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"]
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}",
]
Loading