-
Notifications
You must be signed in to change notification settings - Fork 14
175 lines (151 loc) · 6.29 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
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://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://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://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: |
echo "WHEEL_OS_VERSION=macosx_11_0_arm64" >> $GITHUB_ENV
- name: Rename MacOS AMD64 wheel
shell: bash -l {0}
if: ${{ matrix.os == 'macos-13' }}
run: |
echo "WHEEL_OS_VERSION=macosx_10_13_x86_64" >> $GITHUB_ENV
- name: Rename Linux AMD64 wheel
shell: bash -l {0}
if: ${{ matrix.os == 'ubuntu-20.04' }}
run: |
echo "WHEEL_OS_VERSION=linux_x86_64" >> $GITHUB_ENV
- name: Rename Windows AMD64 wheel
shell: bash -l {0}
if: ${{ matrix.os == 'windows-2019' }}
run: |
echo "WHEEL_OS_VERSION=win_amd64" >> $GITHUB_ENV
- name: Edit wheel
shell: bash -l {0}
run: |
wheel_file=$(ls vtk/build/dist/*.whl | xargs -n 1 basename) # Get the wheel file name from an ls of the dist directory
echo $wheel_file
mkdir ./wheel_build/ # Make a separate build directory
unzip vtk/build/dist/${wheel_file} -d ./wheel_build/ # Extract the wheel file
sed -i'' -e 's/Name:.*$/Name: cadquery_vtk/' ./wheel_build/*.dist-info/METADATA # Change the name in the METADATA file
sed -i'' -e 's/Version:.9.2.6.dev0$/Version: 9.2.6/' ./wheel_build/*.dist-info/METADATA # Remove the .dev0 from the version in the METADATA file
mv ./wheel_build/*.dist-info ./wheel_build/cadquery_vtk-9.2.6.dist-info # Rename the dist-info file to the new name
wheel pack ./wheel_build/; # Create a new wheel file with the new name by prepending "cadquery_" to the name
rm ./vtk/build/dist/*.whl # Remove the old wheel file
mv *.whl ./vtk/build/dist/ # Move the new wheel file to the dist directory
- 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