-
Notifications
You must be signed in to change notification settings - Fork 1
308 lines (271 loc) · 10.8 KB
/
wheels.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
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
name: Wheels
on:
workflow_dispatch:
schedule:
- cron: "0 4 * * *" # every day at 4am UTC
release:
types:
- published
env:
GEANT4_VERSION: 11.2.2
XERCES_VERSION: 3.2.5
CPP_STANDARD: 17
Geant4_DIR: ${{ github.workspace }}/geant4
concurrency:
group: ${{ github.workflow }}-${{ github.head_ref || github.run_id }}
cancel-in-progress: true
jobs:
sdist:
name: Source distribution
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Setup Python
uses: actions/setup-python@v5
with:
python-version: 3.12
- name: Build sdist
run: |
python -m pip install build
python -m build --sdist .
- name: Upload sdist
uses: actions/upload-artifact@v4
with:
name: dist
path: dist/*.tar.gz
wheels:
name:
Build wheel for cp${{ matrix.python }} ${{ matrix.platform_id }} ${{
matrix.manylinux_image }}
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
include:
- os: ubuntu-latest
python: 38
platform_id: manylinux_x86_64
manylinux_image: manylinux2014
- os: ubuntu-latest
python: 39
platform_id: manylinux_x86_64
manylinux_image: manylinux2014
- os: ubuntu-latest
python: 310
platform_id: manylinux_x86_64
manylinux_image: manylinux2014
- os: ubuntu-latest
python: 311
platform_id: manylinux_x86_64
manylinux_image: manylinux2014
- os: ubuntu-latest
python: 312
platform_id: manylinux_x86_64
manylinux_image: manylinux2014
- os: macos-latest
python: 38
platform_id: macosx_x86_64
- os: macos-latest
python: 39
platform_id: macosx_x86_64
- os: macos-latest
python: 310
platform_id: macosx_x86_64
- os: macos-latest
python: 311
platform_id: macosx_x86_64
- os: macos-latest
python: 312
platform_id: macosx_x86_64
- os: macos-latest
python: 38
platform_id: macosx_arm64
- os: macos-latest
python: 39
platform_id: macosx_arm64
- os: macos-latest
python: 310
platform_id: macosx_arm64
- os: macos-latest
python: 311
platform_id: macosx_arm64
- os: macos-latest
python: 312
platform_id: macosx_arm64
- os: windows-latest
python: 38
platform_id: win_amd64
- os: windows-latest
python: 39
platform_id: win_amd64
- os: windows-latest
python: 310
platform_id: win_amd64
- os: windows-latest
python: 311
platform_id: win_amd64
- os: windows-latest
python: 312
platform_id: win_amd64
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Setup CMake
uses: lukka/get-cmake@v3.30.3
- name: Setup Windows environment variables
if: matrix.os == 'windows-latest'
shell: bash
run: |
echo "CMAKE_ARGS=-DCMAKE_MSVC_RUNTIME_LIBRARY=MultiThreaded" >> $GITHUB_ENV
- name: Setup MacOS environment variables
if: matrix.os == 'macos-latest'
run: |
echo "CMAKE_ARGS=-DCMAKE_OSX_ARCHITECTURES=${{ matrix.platform_id == 'macosx_x86_64' && 'x86_64' || 'arm64' }}" >> $GITHUB_ENV
- name: Cache Xerces-C Installation
if: matrix.os != 'ubuntu-latest'
id: cache-xerces
uses: actions/cache@v4
with:
path: ${{ github.workspace }}/xerces
key:
xerces-v${{ env.XERCES_VERSION }}-cpp${{ env.CPP_STANDARD }}-${{
matrix.platform_id }}
- name: Build and Install Xerces-C
if:
steps.cache-xerces.outputs.cache-hit != 'true' && matrix.os !=
'ubuntu-latest'
run: |
git clone https://github.com/apache/xerces-c.git xerces-source
git -C xerces-source checkout tags/v${{ env.XERCES_VERSION }}
cmake -B xerces-build -S xerces-source ${{ env.CMAKE_ARGS }} -DCMAKE_BUILD_TYPE=Release -DCMAKE_INSTALL_PREFIX=${{ github.workspace }}/xerces -DCMAKE_CXX_STANDARD=${{ env.CPP_STANDARD }} -DBUILD_SHARED_LIBS=OFF ${{ matrix.os == 'windows-latest' && '-DCMAKE_CXX_FLAGS_RELEASE="/MT"' || '-G Ninja -DCMAKE_CXX_FLAGS=-fPIC -DCMAKE_C_FLAGS=-fPIC -Dnetwork-accessor=socket -Dtranscoder=iconv' }}
cmake --build xerces-build --parallel $(nproc) --config Release --target install
- name: Cache Geant4 Installation
if: matrix.os != 'ubuntu-latest'
id: cache-geant4
uses: actions/cache@v4
with:
path: ${{ env.Geant4_DIR }}
key:
geant4-v${{ env.GEANT4_VERSION }}-cpp${{ env.CPP_STANDARD }}-${{
matrix.platform_id }}
- name: Build and Install Geant4 (without datasets)
if:
steps.cache-geant4.outputs.cache-hit != 'true' && matrix.os !=
'ubuntu-latest'
run: |
git clone https://github.com/Geant4/geant4.git ${{ github.workspace }}/geant4-source --depth 1 --branch v${{ env.GEANT4_VERSION }}
cmake -B geant4-build -S geant4-source ${{ env.CMAKE_ARGS }} -DCMAKE_BUILD_TYPE=Release -DCMAKE_INSTALL_PREFIX=${{ env.Geant4_DIR }} -DXERCESC_ROOT_DIR=${{ github.workspace }}/xerces -DCMAKE_CXX_STANDARD=${{ env.CPP_STANDARD }} -DGEANT4_USE_GDML=ON -DGEANT4_INSTALL_EXAMPLES=OFF -DGEANT4_INSTALL_DATA=OFF -DGEANT4_BUILD_TLS_MODEL=global-dynamic -DBUILD_STATIC_LIBS=ON -DBUILD_SHARED_LIBS=OFF ${{ matrix.os == 'windows-latest' && '-DCMAKE_CXX_FLAGS_RELEASE="/MT"' || '-G Ninja -DCMAKE_CXX_FLAGS=-fPIC -DCMAKE_C_FLAGS=-fPIC -DGEANT4_USE_SYSTEM_EXPAT=OFF' }}
cmake --build geant4-build --parallel $(nproc) --config Release --target install
- name: Setup Python
uses: actions/setup-python@v5
with:
python-version: 3.12
- name: Build wheel
uses: pypa/cibuildwheel@v2.21.2
env:
CIBW_TEST_COMMAND:
python -m pytest {project}/tests -vv --reruns 10 --reruns-delay 30
--only-rerun "(?i)http|timeout|connection|socket|resolve"
CIBW_ENVIRONMENT: >
SKLEARN_SKIP_NETWORK_TESTS=1 SKLEARN_BUILD_PARALLEL=3
CIBW_BUILD: cp${{ matrix.python }}-${{ matrix.platform_id }}
CIBW_ARCHS: all
CIBW_MANYLINUX_X86_64_IMAGE: ${{ matrix.manylinux_image }}
CIBW_MANYLINUX_I686_IMAGE: ${{ matrix.manylinux_image }}
CIBW_TEST_SKIP: "*-macosx_arm64" # test on arm64 is not supported yet
CIBW_BEFORE_ALL_LINUX: |
python3 -m pip install cmake ninja
git clone https://github.com/apache/xerces-c.git /tmp/xerces
git -C /tmp/xerces checkout tags/v${{ env.XERCES_VERSION }}
cmake -G Ninja -B /tmp/xerces/build -S /tmp/xerces -DCMAKE_CXX_STANDARD=${{ env.CPP_STANDARD }} -DCMAKE_BUILD_TYPE=Release -DBUILD_SHARED_LIBS=OFF -Dnetwork-accessor=socket -Dtranscoder=iconv -DCMAKE_CXX_FLAGS=-fPIC -DCMAKE_C_FLAGS=-fPIC
cmake --build /tmp/xerces/build --parallel $(nproc) --target install > /dev/null 2>&1
rm -rf /tmp/xerces
git clone https://github.com/Geant4/geant4.git /tmp/geant4 --branch=v${{ env.GEANT4_VERSION }} --depth=1
cmake -G Ninja -B /tmp/geant4/build -S /tmp/geant4 -DCMAKE_CXX_STANDARD=${{ env.CPP_STANDARD }} -DCMAKE_BUILD_TYPE=Release -DGEANT4_USE_GDML=ON -DGEANT4_INSTALL_EXAMPLES=OFF -DGEANT4_INSTALL_DATA=OFF -DGEANT4_BUILD_TLS_MODEL=global-dynamic -DCMAKE_CXX_FLAGS=-fPIC -DCMAKE_C_FLAGS=-fPIC -DGEANT4_USE_SYSTEM_EXPAT=OFF -DBUILD_STATIC_LIBS=ON -DBUILD_SHARED_LIBS=OFF
cmake --build /tmp/geant4/build --parallel $(nproc) --target install > /dev/null 2>&1
rm -rf /tmp/geant4
CIBW_ENVIRONMENT_MACOS: >
MACOSX_DEPLOYMENT_TARGET=11.0 ${{ matrix.platform_id ==
'macosx_arm64' && 'SKIP_PYBIND11_STUBGEN=1' || '' }}
- name: Upload wheel
uses: actions/upload-artifact@v4
with:
name: cibw-wheels-${{ matrix.os }}-${{ strategy.job-index }}
path: wheelhouse/*.whl
check-wheels-size:
name: Check wheels size
needs: wheels
runs-on: ubuntu-latest
steps:
- name: Download wheels
uses: actions/download-artifact@v4
with:
path: dist
merge-multiple: true
- name: Check wheel size
shell: bash
run: |
ls -lh dist
for file in dist/*.whl
do
size=$(du -m "$file" | cut -f1)
if [ "$size" -le 2 ]; then
echo "Error: $file is smaller than 2MB"
exit 1
else
echo "$file is larger than 2MB"
fi
done
upload-pypi:
name: Upload wheels to PyPI
needs: [sdist, wheels, check-wheels-size]
runs-on: ubuntu-latest
if: github.event_name == 'release' && github.event.action == 'published'
steps:
- name: Setup Python
uses: actions/setup-python@v5
with:
python-version: 3.12
- name: Download wheels
uses: actions/download-artifact@v4
with:
path: dist
merge-multiple: true
- name: Publish to PyPI
uses: pypa/gh-action-pypi-publish@v1.10.2
with:
password: ${{ secrets.PYPI_API_TOKEN }}
publish-docker:
name: Publish Docker image
needs: [upload-pypi]
runs-on: ubuntu-latest
permissions:
contents: read
packages: write
steps:
- uses: actions/checkout@v4
- name: Log in to the GitHub Container registry
uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.CONTAINER_REGISTRY_GITHUB_TOKEN }}
- name: Build Docker image
uses: docker/build-push-action@v6
with:
context: .
push: false
tags: |
ghcr.io/lobis/geant4-python-application:latest
ghcr.io/lobis/geant4-python-application:${{ github.event.release.tag_name }}
labels: |
maintainer.name=Luis Antonio Obis Aparicio
maintainer.email=luis.antonio.obis@gmail.com
org.opencontainers.image.source=${{ github.repository }}
- name: Test image
run: |
docker run --rm ghcr.io/lobis/geant4-python-application:latest -c 'import geant4_python_application; app = geant4_python_application.Application()'
- name: Publish
run: |
docker push ghcr.io/lobis/geant4-python-application:latest