Build VTK from source #34
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Build VTK from source | |
on: | |
workflow_dispatch | |
env: | |
PYTHONUTF8: 1 | |
jobs: | |
build: | |
name: Build with wrapper for Python ${{ matrix.python-version }} on ${{ matrix.os }} | |
runs-on: ${{ matrix.os }} | |
strategy: | |
matrix: | |
os: [ 'ubuntu-20.04', 'macos-13', 'macos-14', 'windows-2019' ] | |
python-version: [ '3.9', '3.10', '3.11', '3.12' ] | |
steps: | |
- name: Checkout project | |
uses: actions/checkout@v4 | |
- uses: actions/setup-python@v5 | |
if: ${{ runner.os != 'macOS' }} # setup-python is currently very broken for macos-14 and possibly 13 too | |
with: | |
python-version: ${{ matrix.python-version }} | |
- name: Setup Micromamba on MacOS | |
if: ${{ runner.os == 'macOS' }} # setup-python is currently very broken for macos-14 and possibly 13 too | |
uses: mamba-org/setup-micromamba@v1 | |
with: | |
environment-name: build-vtk # required by micromamba | |
create-args: >- | |
python=${{ matrix.python-version }} | |
- name: Setup Python Env | |
# shell: bash -l {0} | |
# The `bdist_wheel` command requires the `wheel` package | |
run: | | |
python -V | |
python -m pip install --upgrade pip | |
python -m pip install --upgrade wheel | |
python -m pip freeze | |
- name: Setup Windows build environment (MSVC) | |
if: ${{ runner.os == 'Windows' }} | |
uses: ilammy/msvc-dev-cmd@v1 | |
- name: Ubuntu Deps | |
shell: bash -l {0} | |
if: ${{ runner.os == 'Linux' }} | |
run: | | |
sudo apt install -y build-essential cmake mesa-common-dev mesa-utils freeglut3-dev python3-dev python3-venv git-core ninja-build cmake wget libglvnd0 libglvnd-dev | |
# - name: MacOS-13 Deps | |
# shell: bash -l {0} | |
# if: ${{ matrix.os != 'macos-11' }} | |
# run: | | |
- name: MacOS Deps # 13 and 14 | |
shell: bash -l {0} | |
if: ${{ runner.os == 'macOS' }} | |
run: | | |
brew install ninja | |
micromamba info | |
# - name: Windows Deps | |
# shell: bash -l {0} #cmd? | |
# if: ${{ matrix.os != 'windows-2019' }} | |
# run: | | |
- name: Build Linux Wheel from Scratch | |
shell: bash -l {0} | |
if: ${{ runner.os == 'Linux' }} | |
run: | | |
python -V | |
pip install --upgrade setuptools | |
mkdir -p ./vtk/build | |
curl -L -O https://www.vtk.org/files/release/9.2/VTK-9.2.6.tar.gz # Update this for newer releases of VTK | |
tar -zxf VTK-9.2.6.tar.gz --directory ./vtk/ | |
cd ./vtk/build | |
cmake -GNinja -DVTK_WHEEL_BUILD=ON -DVTK_WRAP_PYTHON=ON -DCMAKE_BUILD_TYPE=Release ../VTK-9.2.6 | |
ninja | |
python setup.py bdist_wheel | |
cd ../../ | |
find ./ -iname *.whl | |
- name: Build macOS Wheel from Scratch | |
shell: bash -l {0} | |
if: ${{ runner.os == 'macOS' }} | |
run: | | |
micromamba info | |
python -V | |
pip install --upgrade setuptools | |
mkdir -p ./vtk/build | |
curl -L -O https://www.vtk.org/files/release/9.2/VTK-9.2.6.tar.gz # Update this for newer releases of VTK | |
tar -zxf VTK-9.2.6.tar.gz --directory ./vtk/ | |
cd ./vtk/build | |
cmake -GNinja -DVTK_WHEEL_BUILD=ON -DVTK_WRAP_PYTHON=ON -DCMAKE_BUILD_TYPE=Release ../VTK-9.2.6 | |
ninja | |
python setup.py bdist_wheel | |
cd ../../ | |
find ./ -iname *.whl | |
- name: Build Windows Wheel from Scratch | |
shell: cmd | |
if: ${{ runner.os == 'Windows' }} | |
run: | | |
python -V | |
cl | |
pip install --upgrade setuptools | |
mkdir vtk\build | |
curl -L -O https://www.vtk.org/files/release/9.2/VTK-9.2.6.tar.gz | |
tar -zxf VTK-9.2.6.tar.gz --directory vtk\ | |
cd vtk\build | |
cmake -GNinja -DVTK_WHEEL_BUILD=ON -DVTK_WRAP_PYTHON=ON -DCMAKE_BUILD_TYPE=Release ..\VTK-9.2.6 | |
ninja | |
python setup.py bdist_wheel | |
cd ..\..\ | |
dir /s | |
- name: Prepare Python version string | |
shell: bash -l {0} | |
run: echo "PYTHON_VERSION_NO_DOTS=$(echo ${{ matrix.python-version }} | tr -d '.')" >> $GITHUB_ENV | |
- name: Rename MacOS ARM64 wheel | |
shell: bash -l {0} | |
if: ${{ matrix.os == 'macos-14' }} | |
run: | | |
mv vtk/build/dist/vtk-9.2.6.dev0-cp${{ env.PYTHON_VERSION_NO_DOTS }}-cp${{ env.PYTHON_VERSION_NO_DOTS }}-macosx_14_0_arm64.whl vtk/build/dist/cadquery-vtk-9.2.6-cp${{ env.PYTHON_VERSION_NO_DOTS }}-cp${{ env.PYTHON_VERSION_NO_DOTS }}-macosx_14_0_arm64.whl | |
- name: Rename MacOS AMD64 wheel | |
shell: bash -l {0} | |
if: ${{ matrix.os == 'macos-13' }} | |
run: | | |
mv vtk/build/dist/vtk-9.2.6.dev0-cp${{ env.PYTHON_VERSION_NO_DOTS }}-cp${{ env.PYTHON_VERSION_NO_DOTS }}-macosx_13_0_x86_64.whl vtk/build/dist/cadquery-vtk-9.2.6-cp${{ env.PYTHON_VERSION_NO_DOTS }}-cp${{ env.PYTHON_VERSION_NO_DOTS }}-macosx_13_0_x86_64.whl | |
- name: Rename Linux AMD64 wheel | |
shell: bash -l {0} | |
if: ${{ matrix.os == 'ubuntu-20.04' }} | |
run: | | |
mv vtk/build/dist/vtk-9.2.6.dev0-cp${{ env.PYTHON_VERSION_NO_DOTS }}-cp${{ env.PYTHON_VERSION_NO_DOTS }}-linux_x86_64.whl vtk/build/dist/cadquery-vtk-9.2.6-cp${{ env.PYTHON_VERSION_NO_DOTS }}-cp${{ env.PYTHON_VERSION_NO_DOTS }}-linux_x86_64.whl | |
- name: Rename Windows AMD64 wheel | |
shell: bash -l {0} | |
if: ${{ matrix.os == 'windows-2019' }} | |
run: | | |
mv vtk/build/dist/vtk-9.2.6.dev0-cp${{ env.PYTHON_VERSION_NO_DOTS }}-cp${{ env.PYTHON_VERSION_NO_DOTS }}-win_amd64.whl vtk/build/dist/cadquery-vtk-9.2.6-cp${{ env.PYTHON_VERSION_NO_DOTS }}-cp${{ env.PYTHON_VERSION_NO_DOTS }}-win_amd64.whl | |
- name: Test wheel | |
shell: bash -l {0} | |
run: | | |
python -V | |
pip install vtk/build/dist/*.whl | |
python -c "import vtk;print('vtk imported successfully')" | |
- name: Upload Artifact | |
uses: actions/upload-artifact@v4 | |
with: | |
name: cadquery-vtk-${{ matrix.os }}-cp${{ matrix.python-version }} | |
path: vtk/build/dist/*.whl |