-
Notifications
You must be signed in to change notification settings - Fork 552
271 lines (237 loc) · 10.4 KB
/
build-python.yaml
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
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
name: Compile python package
on:
push:
branches: [master, feature/github-release]
tags:
- '[0-9]+.[0-9]+.[0-9]+'
pull_request:
branches: [master, develop]
workflow_dispatch:
env:
BOOST_MAJOR_VERSION: '1'
BOOST_MINOR_VERSION: '80'
BOOST_PATCH_VERSION: '0'
LIBNABO_VERSION: '1.1.2'
BOOST_INSTALL_PATH: ${{ github.workspace }}/.tmp/boost/install
BOOST_SRC_DIR: ${{ github.workspace }}/.tmp/boost
LIBNABO_INSTALL_PATH: ${{ github.workspace }}/.tmp/libnabo-build/install
LIBNABO_SRC_DIR: ${{ github.workspace }}/.tmp/libnabo
PYTHON_WHEEL_DIR: ${{ github.workspace }}/.tmp/python-wheel
VCPKG_DEFAULT_BINARY_CACHE: '${{ github.workspace }}/.tmp/bin-cache'
BUILD_DIR: ${{ github.workspace }}/build
jobs:
compile-python-package:
strategy:
fail-fast: false
matrix:
python_version: ['3.8', '3.9', '3.10', '3.11', '3.12']
os:
# - windows-2019 cannot compile on Windows
# (!) TODO: The workflow contains code for Windows building, but we cannot compile it with MS MPI. Changes in the source code are needed.
- ubuntu-22.04
- ubuntu-20.04
- ubuntu-24.04
permissions:
contents: write
runs-on: ${{ matrix.os }}
steps:
- uses: actions/checkout@v3
- name: Make temp dir
run: mkdir ${{ github.workspace }}/.tmp
- name: Init base env variable on Linux
if: ${{ runner.os == 'Linux' }}
run: |
echo "BOOST_DIR=boost_${{ env.BOOST_MAJOR_VERSION }}_${{ env.BOOST_MINOR_VERSION }}_${{ env.BOOST_PATCH_VERSION }}" >> $GITHUB_ENV
echo "BOOST_VERSION=${{ env.BOOST_MAJOR_VERSION }}.${{ env.BOOST_MINOR_VERSION }}.${{ env.BOOST_PATCH_VERSION }}" >> $GITHUB_ENV
- name: Init env variable on Linux
if: ${{ runner.os == 'Linux' }}
run: |
echo "BOOST_ARCHIVE_NAME=${{ env.BOOST_DIR }}.7z" >> $GITHUB_ENV
- name: Init base env variable on Windows
if: ${{ runner.os == 'Windows' }}
run: |
echo "BOOST_DIR=boost_${{ env.BOOST_MAJOR_VERSION }}_${{ env.BOOST_MINOR_VERSION }}_${{ env.BOOST_PATCH_VERSION }}" | Out-File -FilePath $env:GITHUB_ENV -Append
echo "BOOST_VERSION=${{ env.BOOST_MAJOR_VERSION }}.${{ env.BOOST_MINOR_VERSION }}.${{ env.BOOST_PATCH_VERSION }}" | Out-File -FilePath $env:GITHUB_ENV -Append
- name: Init env variable on Windows
if: ${{ runner.os == 'Windows' }}
run: |
echo "BOOST_ARCHIVE_NAME=${{ env.BOOST_DIR }}.zip" | Out-File -FilePath $env:GITHUB_ENV -Append
- name: Cache boost
id: cache-boost
if: ${{ runner.os == 'Linux' }}
uses: actions/cache@v3
with:
path: ${{ env.BOOST_INSTALL_PATH }}
key: ${{ runner.os }}-boost-cache-${{ env.BOOST_VERSION }}-python-${{ matrix.python_version }}
- name: Cache libnabo
id: cache-libnabo
uses: actions/cache@v3
with:
path: ${{ env.LIBNABO_INSTALL_PATH }}
key: ${{ runner.os }}-libnabo-cache-${{ env.LIBNABO_VERSION }}
- name: Cache binary vcpkg
if: ${{ runner.os == 'Windows' }}
id: cache-vcpkg
uses: actions/cache@v3
with:
path: ${{ env.VCPKG_DEFAULT_BINARY_CACHE }}
key: ${{ runner.os }}-vcpkg-cache-${{ matrix.python_version }}
- name: Make dirs on Linux
if: ${{ runner.os == 'Linux' }}
run: |
mkdir -p ${{ env.BOOST_SRC_DIR }}
mkdir -p ${{ env.LIBNABO_SRC_DIR }}
mkdir -p ${{ env.BOOST_INSTALL_PATH }}
mkdir -p ${{ env.LIBNABO_INSTALL_PATH }}
mkdir -p ${{ env.VCPKG_DEFAULT_BINARY_CACHE }}
- name: Make dirs on Windows
if: ${{ runner.os == 'Windows' }}
run: |
mkdir -Force ${{ env.BOOST_SRC_DIR }}
mkdir -Force ${{ env.LIBNABO_SRC_DIR }}
mkdir -Force ${{ env.BOOST_INSTALL_PATH }}
mkdir -Force ${{ env.LIBNABO_INSTALL_PATH }}
mkdir -Force ${{ env.VCPKG_DEFAULT_BINARY_CACHE }}
- name: Install dependencies on Linux
if: ${{ runner.os == 'Linux' }}
run: |
sudo apt update
sudo apt install -y --no-install-recommends g++ \
gcc \
make \
libeigen3-dev \
libyaml-cpp-dev \
ninja-build \
catch \
libomp-dev \
wget
- name: Install MS MPI
if: ${{ runner.os == 'Windows' }}
working-directory: ${{ runner.temp }}
run: |
Invoke-WebRequest https://download.microsoft.com/download/a/5/2/a5207ca5-1203-491a-8fb8-906fd68ae623/msmpisetup.exe -OutFile ./msmpisetup.exe
Start-Process -Wait -FilePath ./msmpisetup.exe -ArgumentList "-unattend","-log","./log.txt" -NoNewWindow
cat ./log.txt
- name: Set up Python ${{ matrix.python_version }}
uses: actions/setup-python@v4
with:
python-version: ${{ matrix.python_version }}
cache: 'pip'
- name: Install required dependencies for Python
run: |
python -m pip install -U 'pip>=23.0'
pip install 'numpy>=1.20' wheel 'setuptools>=61.0' 'build~=0.10' `cmake` `pybind11`
- name: Install dependencies on Windows
if: ${{ runner.os == 'Windows' }}
run: |
vcpkg install eigen3:x64-windows-static `
libopenmpt:x64-windows `
boost-mpi:x64-windows-static `
boost-thread:x64-windows-static `
boost-system:x64-windows-static `
boost-program-options:x64-windows-static `
boost-date-time:x64-windows-static `
boost-chrono:x64-windows-static `
boost-regex[icu]:x64-windows-static `
boost-assign:x64-windows-static `
boost-timer:x64-windows-static `
--clean-after-build
- name: Download boost ${{ env.BOOST_VERSION }} on Linux
if: ${{ steps.cache-boost.outputs.cache-hit != 'true' && runner.os == 'Linux' }}
working-directory: ${{ env.BOOST_SRC_DIR }}
run: |
wget --no-verbose https://archives.boost.io/release/${{ env.BOOST_VERSION }}/source/${{ env.BOOST_ARCHIVE_NAME }}
7z -y x ${{ env.BOOST_ARCHIVE_NAME }}
rm ${{ env.BOOST_ARCHIVE_NAME }}
- name: Configure static boost on Linux
if: ${{ steps.cache-boost.outputs.cache-hit != 'true' && runner.os == 'Linux' }}
working-directory: ${{ env.BOOST_SRC_DIR }}/${{ env.BOOST_DIR }}
run: |
./bootstrap.sh --with-libraries=thread,system,program_options,date_time,chrono --with-icu --prefix=${{ env.BOOST_INSTALL_PATH }}
./b2 cxxflags=-fPIC cflags=-fPIC link=static install
- name: Download source code libnabo ${{ env.LIBNABO_VERSION }}
if: steps.cache-libnabo.outputs.cache-hit != 'true'
working-directory: ${{ env.LIBNABO_SRC_DIR }}
run: |
git clone -b ${{ env.LIBNABO_VERSION }} --single-branch https://github.com/norlab-ulaval/libnabo.git
- name: Install libnabo ${{ env.LIBNABO_VERSION }} on Windows
if: ${{ steps.cache-libnabo.outputs.cache-hit != 'true' && runner.os == 'Windows' }}
working-directory: ${{ env.LIBNABO_SRC_DIR }}
run: |
cd libnabo
cmake -A x64 `
-DCMAKE_TOOLCHAIN_FILE="$env:VCPKG_INSTALLATION_ROOT/scripts/buildsystems/vcpkg.cmake" `
-DCMAKE_INSTALL_PREFIX=${{ env.LIBNABO_INSTALL_PATH }} `
-DCMAKE_BUILD_TYPE=RelWithDebInfo `
-DUSE_OPEN_MP:BOOL=ON `
-S . -B ./build
cmake --build ./build --target install
cd -
rm -r ./libnabo/build
- name: Install libnabo ${{ env.LIBNABO_VERSION }} on Linux
if: ${{ steps.cache-libnabo.outputs.cache-hit != 'true' && runner.os == 'Linux' }}
working-directory: ${{ env.LIBNABO_SRC_DIR }}
run: |
cd libnabo
cmake -GNinja \
-DBOOST_ROOT=${{ env.BOOST_INSTALL_PATH }} \
-DCMAKE_INSTALL_PREFIX=${{ env.LIBNABO_INSTALL_PATH }} \
-DCMAKE_BUILD_TYPE=RelWithDebInfo \
-DUSE_OPEN_MP:BOOL=ON \
-S . -B ./build
cmake --build ./build --target install
cd -
rm -r ./libnabo/build
- name: Compile libpointmatcher on Linux
if: runner.os == 'Linux'
run: |
cmake \
-DBOOST_ROOT:PATH=${{ env.BOOST_INSTALL_PATH }} \
-DLIBNABO_INSTALL_DIR=${{ env.LIBNABO_INSTALL_PATH }} \
-DBUILD_PYTHON_MODULE:BOOL=ON \
-DUSE_OPEN_MP:BOOL=ON \
-DBoost_USE_STATIC_LIBS:BOOL=ON \
-DCMAKE_BUILD_TYPE=RelWithDebInfo \
-S . -B ${{ env.BUILD_DIR }}
sudo cmake --build ${{ env.BUILD_DIR }} --target install
- name: Compile libpointmatcher on Windows
if: runner.os == 'Windows'
env:
PYTHON_PACKAGE_NAME: pypointmatcher
run: |
cmake -A x64 `
-DCMAKE_TOOLCHAIN_FILE:FILEPATH="$env:VCPKG_INSTALLATION_ROOT/scripts/buildsystems/vcpkg.cmake" `
-DLIBNABO_INSTALL_DIR:PATH="${{ env.LIBNABO_INSTALL_PATH }}" ``
-DBUILD_PYTHON_MODULE:BOOL=ON `
-DBoost_USE_STATIC_LIBS:BOOL=ON `
-DPYTHON_INSTALL_TARGET:PATH="./python/${{ env.PYTHON_PACKAGE_NAME }}" `
-DVCPKG_TARGET_TRIPLET="x64-windows-static" `
-DUSE_OPEN_MP:BOOL=ON `
-DCMAKE_BUILD_TYPE="RelWithDebInfo" `
-S . -B ${{ env.BUILD_DIR }}
cmake --build ${{ env.BUILD_DIR }} --target install
- name: Build python wheel
working-directory: ./python
run: |
python -m build --wheel --no-isolation --outdir ${{ env.PYTHON_WHEEL_DIR }}
- name: Install package
working-directory: ./python
run: |
pip install ${{ env.PYTHON_WHEEL_DIR }}/*.whl
- name: Test import
working-directory: ${{ runner.temp }}
run: python -c "from pypointmatcher import *"
- name: Upload python wheel
uses: actions/upload-artifact@v3
with:
name: libpointmatcher python ${{ matrix.python_version }} wheel
path: ${{ env.PYTHON_WHEEL_DIR }}/*.whl
if-no-files-found: error
retention-days: 10
- uses: ncipollo/release-action@v1
if: github.ref_type == 'tag'
with:
artifacts: "${{ env.PYTHON_WHEEL_DIR }}/*.whl"
prerelease: true
allowUpdates: true
generateReleaseNotes: true