-
Notifications
You must be signed in to change notification settings - Fork 123
247 lines (223 loc) · 8.33 KB
/
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
240
241
242
243
244
245
246
247
name: Build NEURON Python wheels
on:
push:
branches:
- master
pull_request:
branches:
- master
schedule:
- cron: "0 0 * * *"
workflow_dispatch:
inputs:
rel_release:
description: Release branch/commit
default: 'release/x.y'
required: true
rel_version:
description: Release version (tag name), in format major.minor.patch
default: ''
required: false
upload:
description: Whether to upload to PyPI or not
default: false
required: true
type: boolean
build_type:
description: The type of build (release or nightly)
default: 'nightly'
options:
- 'nightly'
- 'release'
base_image_x86_64:
description: The custom base container image to use for manylinux builds (x86_64)
base_image_aarch64:
description: The custom base container image to use for manylinux builds (aarch64)
jobs:
build-test:
name: Build and test Python ${{ matrix.python-version }} wheel on ${{ matrix.os }}
runs-on: ${{ matrix.os }}
timeout-minutes: 60
strategy:
matrix:
os: ['macos-13', 'ubuntu-22.04', 'ubuntu-22.04-arm']
python-version: ['3.9']
include:
- python-version: '3.9'
python-org-version: '3.9.13'
python-installer-name: 'macos11.pkg'
- os: 'ubuntu-22.04'
base_image: 'docker.io/neuronsimulator/neuron_wheel:manylinux_2_28_x86_64'
- os: 'ubuntu-22.04-arm'
base_image: 'docker.io/neuronsimulator/neuron_wheel:manylinux_2_28_aarch64'
steps:
- name: Check out code
if: github.event_name != 'workflow_dispatch'
uses: actions/checkout@v4
with:
submodules: recursive
fetch-depth: 0
- name: Check out code for specific release
if: github.event_name == 'workflow_dispatch'
uses: actions/checkout@v4
with:
ref: ${{ github.event.inputs.rel_release }}
submodules: recursive
- name: Install Python from python.org
if: runner.os == 'macOS'
run: |
installer="python-${{ matrix.python-org-version }}-${{ matrix.python-installer-name }}"
url="https://www.python.org/ftp/python/${{ matrix.python-org-version }}/${installer}"
curl $url -o $installer
sudo installer -pkg $installer -target /
- name: Install System Dependencies
if: runner.os == 'macOS'
run: |
brew install --cask xquartz
brew install flex bison cmake mpich
brew unlink mpich && brew install openmpi
cmake --version
# Uninstall libomp for compatibility with issue #817
brew uninstall --ignore-dependencies libomp || echo "libomp doesn't exist"
echo "$(brew --prefix)/opt/cmake/bin:$(brew --prefix)/opt/flex/bin:$(brew --prefix)/opt/bison/bin" >> $GITHUB_PATH
- name: Install readline
if: runner.os == 'macOS'
run: |
sudo mkdir -p /opt/nrnwheel/$(uname -m)
sudo bash packaging/python/build_static_readline_osx.bash
- name: Set env
run: |
BUILD_TYPE="${{ github.event.inputs.build_type }}"
UPLOAD="${{ github.event.inputs.upload }}"
# if they're empty, it means its not a workflow_dispatch, so we set a default
BUILD_TYPE="${BUILD_TYPE:-nightly}"
UPLOAD="${UPLOAD:-false}"
if [ "${BUILD_TYPE}" = 'nightly' ]
then
echo "NRN_NIGHTLY_UPLOAD=true" >> $GITHUB_ENV
echo "NEURON_NIGHTLY_TAG=-nightly" >> $GITHUB_ENV
else
echo "NRN_NIGHTLY_UPLOAD=false" >> $GITHUB_ENV
echo "NEURON_NIGHTLY_TAG=" >> $GITHUB_ENV
fi
- name: Override env for scheduled run
if: github.event_name == 'schedule'
run: |
echo "NRN_NIGHTLY_UPLOAD=true" >> $GITHUB_ENV
echo "NEURON_NIGHTLY_TAG=-nightly" >> $GITHUB_ENV
- name: Set custom version
if: github.event.inputs.rel_version != ''
run: |
echo SETUPTOOLS_SCM_PRETEND_VERSION=${{ github.event.inputs.rel_version }} >> $GITHUB_ENV
- name: Build MacOS wheel
if: runner.os == 'macOS'
run: |
packaging/python/build_wheels.bash osx ${{ matrix.python-version }} coreneuron
- name: Build Manylinux wheel
if: runner.os != 'macOS'
run: |
# manylinux does not support multi-platform images yet (see
# https://github.com/pypa/manylinux/issues/1306), so as a workaround,
# we use two custom input variables, one for x86, and one for arm
if [[ "${{ runner.os }}" =~ .*arm$ ]]
then
BASE_IMAGE="${{ github.event.inputs.base_image_aarch64 }}"
BASE_IMAGE="${BASE_IMAGE:-${{ matrix.base_image }}}"
else
BASE_IMAGE="${{ github.event.inputs.base_image_x86_64 }}"
BASE_IMAGE="${BASE_IMAGE:-${{ matrix.base_image }}}"
fi
docker run --rm \
-w /root/nrn \
-v $(pwd):/root/nrn \
-e NEURON_NIGHTLY_TAG \
-e NRN_NIGHTLY_UPLOAD \
-e SETUPTOOLS_SCM_PRETEND_VERSION \
-e NRN_BUILD_FOR_UPLOAD=1 \
${BASE_IMAGE} \
packaging/python/build_wheels.bash linux ${{ matrix.python-version }} coreneuron
- name: Upload wheel files
uses: actions/upload-artifact@v4
with:
name: wheels-${{ matrix.python-version }}-${{ matrix.os }}
path: wheelhouse/*.whl
- name: Setup Python ${{ matrix.python-version }} for testing
uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python-version }}
- name: Install test dependencies
if: runner.os != 'macOS'
run: |
sudo apt update
sudo apt install -y mpich openmpi-bin libopenmpi-dev libmpich-dev
- name: Test wheel with ${{ matrix.python-version }}
run: |
minor_version="$(python${{ matrix.python-version }} -c 'import sys;print(sys.version_info.minor)')"
packaging/python/test_wheels.sh $(which python${{ matrix.python-version }}) wheelhouse/*cp3${minor_version}*.whl
merge:
name: Merge artifacts
runs-on: ubuntu-latest
needs: [build-test]
steps:
- name: Merge Artifacts
id: merge-artifacts
uses: actions/upload-artifact/merge@v4
with:
delete-merged: true
name: wheels
pattern: wheels-*
- name: Create comment with URL to artifact
if: github.event.pull_request
uses: peter-evans/create-or-update-comment@v4
with:
issue-number: ${{ github.event.pull_request.number }}
body: |
✔️ ${{ github.sha }} -> [artifacts URL](${{ steps.merge-artifacts.outputs.artifact-url }})
pypi-publish-nightly:
name: Upload nightly wheels to PyPI
runs-on: ubuntu-latest
needs: merge
if: github.event_name == 'schedule'
environment:
name: pypi
url: https://pypi.org/p/neuron-nightly
permissions:
id-token: write # IMPORTANT: this permission is mandatory for trusted publishing
steps:
- name: Download wheels from artifact
uses: actions/download-artifact@v4
with:
name: wheels
- name: Publish package distributions to PyPI
uses: pypa/gh-action-pypi-publish@release/v1
pypi-publish-release:
name: Upload release wheels to PyPI
runs-on: ubuntu-latest
needs: merge
if: github.event_name == 'workflow_dispatch' && github.event.inputs.upload == 'true'
environment:
name: pypi
url: https://pypi.org/p/neuron
permissions:
id-token: write # IMPORTANT: this permission is mandatory for trusted publishing
steps:
- name: Download wheels from artifact
uses: actions/download-artifact@v4
with:
name: wheels
- name: Publish package distributions to PyPI
uses: pypa/gh-action-pypi-publish@release/v1
final:
name: Final CI
needs: [merge]
if: ${{ always() }}
runs-on: ubuntu-latest
steps:
- name: Check if CI matrix is successful
if: >-
${{
contains(needs.*.result, 'failure')
|| contains(needs.*.result, 'cancelled')
|| contains(needs.*.result, 'skipped')
}}
run: exit 1