-
Notifications
You must be signed in to change notification settings - Fork 14
239 lines (220 loc) · 9.45 KB
/
build-wheels.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
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
# Controls when the workflow will run
on:
# Run this workflow after the TREXIO CI completed
workflow_run:
workflows: [ "TREXIO CI" ]
branches: [ master ]
types:
- completed
# Workflow to build and publish wheels.
# in the get_commit_message job: Include [wheel build] in your commit message to trigger this build.
name: Build CPython wheels
jobs:
get_commit_message:
if: ${{ github.event.workflow_run.conclusion == 'success' }}
name: Get commit message
runs-on: ubuntu-22.04
outputs:
message: ${{ steps.commit_message.outputs.message }}
steps:
- name: Checkout the repo
uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11
# Gets the correct commit message for pull request
with:
ref: ${{ github.event.pull_request.head.sha }}
- name: Get commit message
id: commit_message
run: |
set -xe
COMMIT_MSG=$(git log --no-merges -1 --oneline)
echo "message=$COMMIT_MSG" >> $GITHUB_OUTPUT
echo github.ref ${{ github.ref }}
build_macos_wheels:
name: build linux wheels for different versions of cpython on macos
needs: get_commit_message
if: >-
contains(needs.get_commit_message.outputs.message, '[wheel build]') ||
(github.repository == 'trex-coe/trexio' && startswith(github.ref, 'refs/tags/v'))
runs-on: ${{ matrix.buildplat[0] }}
env:
HDF5_INSTALLDIR: "/tmp/hdf5"
strategy:
# Ensure that a wheel builder finishes even if another fails
fail-fast: false
matrix:
# Github Actions doesn't support pairing matrix values together, let's improvise
# https://github.com/github/feedback/discussions/7835#discussioncomment-1769026
buildplat:
- [macos-13, macosx_x86_64]
- [macos-14, macosx_arm64]
# test config
python: ["cp310", "cp312"]
#python: ["cp38", "cp39", "cp310", "cp311", "cp312"]
#exclude:
# - buildplat: [macos-14, macosx_arm64]
# python: "cp38"
steps:
- uses: actions/checkout@e2f20e631ae6d7dd3b768f56a5d2af784dd54791
- uses: actions/setup-python@39cd14951b08e74b54015e9e001cdefcf80e669f # v5.1.1
with:
python-version: "3.x"
- name: install dependencies
run: |
brew install emacs
brew install automake
brew install libtool
brew install swig
brew install wget
- name: install hdf5
run: |
wget https://github.com/HDFGroup/hdf5/archive/refs/tags/hdf5-1_12_3.tar.gz
tar -xzf hdf5-1_12_3.tar.gz
cd hdf5-hdf5-1_12_3
./autogen.sh
./configure CC=gcc-12 --prefix $HDF5_INSTALLDIR --enable-build-mode=production --with-szlib
make -j3
make install
- name: configure with autotools
run: |
./autogen.sh
export PATH=${PATH}:${HDF5_INSTALLDIR}/bin
./configure FC=gfortran-12 --enable-silent-rules
make -j3
make -j3 check
- name: prepare python
run: |
export H5_CFLAGS="-I${HDF5_INCLUDEDIR}/include"
export H5_LDFLAGS="-L${HDF5_INCLUDEDIR}/lib"
make python-install
- name: cleanup python
run: |
rm -rf src/ tools/
mv python/* .
- name: Build wheels
uses: pypa/cibuildwheel@bd033a44476646b606efccdd5eed92d5ea1d77ad # v2.20.0
env:
CIBW_PRERELEASE_PYTHONS: False
CIBW_FREE_THREADED_SUPPORT: False
CIBW_BUILD: ${{ matrix.python }}-${{ matrix.buildplat[1] }}
CIBW_BUILD_VERBOSITY: 3
CIBW_BUILD_FRONTEND: "build"
CIBW_ENVIRONMENT_LINUX: H5_CFLAGS="-I/tmp/hdf5/include" H5_LDFLAGS="-L/tmp/hdf5/lib"
CIBW_TEST_REQUIRES: pytest
CIBW_TEST_COMMANDS: "pytest -v --all python/test/test_api.py"
- uses: actions/upload-artifact@834a144ee995460fba8ed112a2fc961b36a5ec5a # v4.3.6
with:
name: ${{ matrix.python }}-${{ matrix.buildplat[1] }}
path: ./wheelhouse/*.whl
# build_linux_wheels:
# name: build linux wheels for different versions of cpython on manylinux_x86_64
# needs: get_commit_message
# if: >-
# contains(needs.get_commit_message.outputs.message, '[wheel build]') ||
# (github.repository == 'trex-coe/trexio' && startswith(github.ref, 'refs/tags/v'))
# runs-on: ubuntu-22.04
# strategy:
# matrix:
# manylinux_tag: [2014_x86_64, 2_28_x86_64]
#
# steps:
# - name: Checkout the branch
# uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11
#
# - name: Set up Python
# uses: actions/setup-python@39cd14951b08e74b54015e9e001cdefcf80e669f
# with:
# python-version: '3.10'
#
# - name: Install build dependencies
# run: python -m pip install -U setuptools
#
# - name: Compute the PYTREXIO_VERSION environment variable
# run: echo "PYTREXIO_VERSION=$(grep __version__ python/pytrexio/_version.py | cut -d\ -f3 | tr -d '"')" >> $GITHUB_ENV
#
# - name: Print the PYTREXIO_VERSION
# run: echo ${{ env.PYTREXIO_VERSION }}
#
# # Conventional download-artifact action does not work for artifact produced in a different workflow,
# # which is the case here (TREXIO CI produced the Python API distribution tarball)
# - name: Download the Python API distribution tarball
# uses: dawidd6/action-download-artifact@v2
# with:
# # Specify the name of the workflow file which uploaded the tarball
# workflow: actions.yml
# workflow_conclusion: success
# name: pytrexio-source
# path: python
#
# # at the moment we have to pull the custom container with pre-installed HDF5
# # the containers are built and stored in GitHub container registry ghcr.io/q-posev
# - name: Pull the manylinux Docker container with HDF5
# run: docker pull ghcr.io/q-posev/hdf5_1_12_on_${{ matrix.manylinux_tag }}:latest
#
# - name: Build wheels for different versions of CPython inside the Docker container
# run: >
# docker run --rm
# --env PLAT=manylinux${{ matrix.manylinux_tag }}
# --volume `pwd`:/tmp
# --workdir /tmp
# ghcr.io/q-posev/hdf5_1_12_on_${{ matrix.manylinux_tag }}
# /bin/bash build_manylinux_wheels.sh trexio-${{ env.PYTREXIO_VERSION }}.tar.gz
# working-directory: python
#
# - name: Upload produced wheels as artifacts
# uses: actions/upload-artifact@834a144ee995460fba8ed112a2fc961b36a5ec5a
# with:
# name: pytrexio-manylinux-${{ matrix.manylinux_tag }}
# path: ./python/wheelhouse/*.whl
#
#
# publish_wheels:
# name: Publish all wheels on PyPI
# needs: [build_linux_wheels]
# runs-on: ubuntu-22.04
#
# steps:
# - name: Checkout the branch
# uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11
#
# - name: Set up Python
# uses: actions/setup-python@39cd14951b08e74b54015e9e001cdefcf80e669f
# with:
# python-version: '3.10'
#
# - name: Install build dependencies
# run: python -m pip install -U setuptools twine
#
# - name: Download the build artifacts (wheels) of this workflow
# uses: actions/download-artifact@v4
# with:
# path: dist
#
# - name: Download the Python API distribution tarball
# uses: dawidd6/action-download-artifact@v2
# with:
# workflow: actions.yml
# workflow_conclusion: success
# name: pytrexio-source
# path: dist
#
# # The artifacts have to be in dist/ directory so that
# # pypa/gh-action-pypi-publish action can discover them
# - name: Display and rearrange the downloaded artifacts
# run: |
# ls -R
# mv pytrexio-manylinux-*/trexio-*.whl ./
# rm -rf -- pytrexio-manylinux-*/
# ls -sh -w 1
# working-directory: dist
#
- name: Publish distribution 📦 to Test PyPI
uses: pypa/gh-action-pypi-publish@master
with:
password: ${{ secrets.TEST_PYPI_API_TOKEN }}
repository_url: https://test.pypi.org/legacy/
#verbose: true
#- name: Publish distribution 📦 to PyPI
# uses: pypa/gh-action-pypi-publish@master
# with:
# password: ${{ secrets.PYPI_API_TOKEN }}
# #if: startsWith(github.ref, 'refs/tags')