-
Notifications
You must be signed in to change notification settings - Fork 14
220 lines (181 loc) · 7.3 KB
/
build-vtk.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
name: Build VTK from source
on: workflow_dispatch
env:
PYTHONUTF8: 1
VTK: 9.3.1
VTK_MAJOR: 9.3
jobs:
build:
name: Build with wrapper for Python ${{ matrix.python-version }} on ${{ matrix.os }}
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
os: ["ubuntu-20.04", "macos-13", "macos-14", "windows-2019"]
python-version: ["3.13"]
include:
- os: "macos-13"
sed_i: "sed -i '.bak'"
shells: "bash"
- os: "macos-14"
sed_i: "sed -i '.bak'"
shells: "bash"
- os: "ubuntu-20.04"
sed_i: "sed -i"
shells: "bash"
- os: "windows-2019"
sed_i: "sed -i"
shells: "bash cmd.exe"
steps:
- name: (All) Checkout project
uses: actions/checkout@v4
- name: (All) Get number of CPUs
shell: bash -l {0}
id: cpu-count
run: |
if [[ "$RUNNER_OS" == "macOS" ]]; then
cpu_count=$(sysctl -n hw.logicalcpu)
elif [[ "$RUNNER_OS" == "Linux" ]]; then
cpu_count=$(nproc)
elif [[ "$RUNNER_OS" == "Windows" ]]; then
cpu_count=$NUMBER_OF_PROCESSORS
else
cpu_count=1
fi
echo "cpu_count=$cpu_count" >> $GITHUB_OUTPUT
echo "=> Using $cpu_count CPUs"
- name: (All) Setup Micromamba
uses: mamba-org/setup-micromamba@v1
with:
environment-name: build-vtk
init-shell: ${{ matrix.shells }}
cache-downloads: true
create-args: >-
python=${{ matrix.python-version }}
- name: (All) Setup Python Env
shell: bash -l {0}
run: |
micromamba activate build-vtk
python -m pip install --upgrade pip
python -m pip install --upgrade wheel build setuptools
python -m pip freeze
- name: (Linux) 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: (Mac) MacOS Deps # 13 and 14
shell: bash -l {0}
if: ${{ runner.os == 'macOS' }}
run: |
brew install ninja
- name: (All) Restore VTK build cache
id: cache-vtk-restore
uses: actions/cache/restore@v4
with:
path: |
VTK-${{ env.VTK }}
key: VTK-${{ env.VTK }}-wheel-py${{ matrix.python-version }}-${{ matrix.os }}-
- name: (All) Load VTK sources
if: steps.cache-vtk-restore.outputs.cache-hit != 'true'
shell: bash -l {0}
run: |
set -euo pipefail
curl -L -O https://vtk.org/files/release/${{ env.VTK_MAJOR }}/VTK-${{ env.VTK }}.tar.gz
tar -zxf VTK-${{ env.VTK }}.tar.gz
cd VTK-${{ env.VTK }}
mkdir build
patch -p1 < ../patches/vtk-${{ env.VTK }}/9987_try_except_python_import.patch
patch -p1 < ../patches/vtk-${{ env.VTK }}/11486.patch
if [[ $RUNNER_OS == "Windows" ]]; then
patch -p1 < ../patches/vtk-${{ env.VTK }}/fix-threads-windows.patch
fi
- name: (Linux) Build Linux python libraries from Scratch
shell: bash -l {0}
if: runner.os == 'Linux' && steps.cache-vtk-restore.outputs.cache-hit != 'true'
run: |
set -euo pipefail
micromamba activate build-vtk
if [[ "$RUNNER_OS" == "Linux" ]]; then
export CXXFLAGS="-D_GLIBCXX_USE_CXX11_ABI=0" # Disables the C++11 ABI features for VTK compatibility
fi
cd VTK-${{ env.VTK }}/build
cmake -G Ninja \
-D VTK_VERSIONED_INSTALL=ON \
-D VTK_CUSTOM_LIBRARY_SUFFIX="9.3" -DVTK_VERSION_SUFFIX="" \
-D VTK_WHEEL_BUILD=ON -DVTK_WRAP_PYTHON=ON \
-D CMAKE_BUILD_TYPE=Release \
-D CMAKE_POLICY_DEFAULT_CMP0174=NEW -DCMAKE_POLICY_DEFAULT_CMP0177=NEW \
..
ninja -j ${{ steps.cpu-count.outputs.cpu_count }}
- name: (Mac) Build macOS python libraries from Scratch
shell: bash -l {0}
if: runner.os == 'macOS' && steps.cache-vtk-restore.outputs.cache-hit != 'true'
run: |
set -euo pipefail
micromamba activate build-vtk
cd VTK-${{ env.VTK }}/build
env "MACOSX_DEPLOYMENT_TARGET=11.1" cmake -G Ninja \
-D VTK_VERSIONED_INSTALL=ON \
-D VTK_CUSTOM_LIBRARY_SUFFIX="9.3" -DVTK_VERSION_SUFFIX="" \
-D VTK_WHEEL_BUILD=ON -DVTK_WRAP_PYTHON=ON \
-D CMAKE_BUILD_TYPE=Release \
-D CMAKE_POLICY_DEFAULT_CMP0174=NEW -DCMAKE_POLICY_DEFAULT_CMP0177=NEW \
..
ninja -j ${{ steps.cpu-count.outputs.cpu_count }}
- name: (Windows) Build Windows python libraries from Scratch
shell: cmd
if: runner.os == 'Windows' && steps.cache-vtk-restore.outputs.cache-hit != 'true'
run: |
call C:\Users\runneradmin\micromamba\condabin\micromamba.bat activate build-vtk
call "C:\Program Files (x86)\Microsoft Visual Studio\2019\Enterprise\VC\Auxiliary\Build\vcvars64.bat"
cd VTK-${{ env.VTK }}\build
cmake -G Ninja ^
-D VTK_VERSIONED_INSTALL=ON ^
-D VTK_CUSTOM_LIBRARY_SUFFIX="9.3" -DVTK_VERSION_SUFFIX="" ^
-D VTK_WHEEL_BUILD=ON -DVTK_WRAP_PYTHON=ON ^
-D CMAKE_BUILD_TYPE=Release ^
-D CMAKE_POLICY_DEFAULT_CMP0174=NEW -DCMAKE_POLICY_DEFAULT_CMP0177=NEW ^
..
ninja -j ${{ steps.cpu-count.outputs.cpu_count }}
- name: (All) Cache VTK build folder
id: cache-vtk-save
uses: actions/cache/save@v4
with:
path: |
VTK-${{ env.VTK }}
key: ${{ steps.cache-vtk-restore.outputs.cache-primary-key }}
- name: (All) Build wheel
shell: bash -l {0}
run: |
set -euo pipefail
micromamba activate build-vtk
cd VTK-${{ env.VTK }}/build
${{ matrix.sed_i }} "s/dist_name = 'vtk'/dist_name = 'cadquery_vtk'/" setup.py
${{ matrix.sed_i }} "s/version_suffix = '9.3'/version_suffix = ''/" setup.py
cat setup.py
python -m build -n -w
- name: (Windows) Deloacte wheel
if: runner.os == 'Windows'
shell: bash -l {0}
run: |
set -euo pipefail
micromamba activate build-vtk
pip install delvewheel
cd VTK-${{ env.VTK }}/build
PATH=$(pwd)/bin/:$PATH delvewheel repair --wheel-dir wheel dist/*.whl
rm dist/*.whl
mv wheel/*.whl dist/
- name: (All) Upload Artifact
uses: actions/upload-artifact@v4
with:
name: cadquery-vtk-${{ matrix.os }}-cp${{ matrix.python-version }}
path: VTK-${{ env.VTK }}/build/dist/*.whl
- name: (All) Test wheel
shell: bash -l {0}
run: |
set -euo pipefail
micromamba create -n test python=${{ matrix.python-version }} -y
micromamba activate build-vtk
pip install VTK-${{ env.VTK }}/build/dist/*.whl
python -c "import vtk;print('vtk imported successfully', vtk.__version__)"