-
Notifications
You must be signed in to change notification settings - Fork 32
261 lines (225 loc) · 7.99 KB
/
build.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
248
249
250
251
252
253
254
255
256
257
258
259
260
261
name: Build
on: [push, pull_request]
jobs:
test-linux:
name: "Run tests on Linux"
runs-on: ubuntu-latest
strategy:
matrix:
python: ["3.11", "3.10", "3.9", "3.8"]
steps:
- uses: actions/checkout@v1
- uses: actions/setup-python@v1
with:
python-version: ${{ matrix.python }}
- name: Run Tests (Linux)
run: |
python -m pip install --upgrade pip setuptools wheel
python -m pip install pytest-cov numpy "Cython<3.0.4"
python setup.py build_ext -i
python -m pip install .
pytest --cov-report html --cov-report xml --cov-report annotate --cov=pixell pixell/tests/ -s
- uses: codecov/codecov-action@v2
with:
token: ${{ secrets.CODECOV_TOKEN }} # not required for public repos
verbose: true # optional (default = false)
test-macos:
name: "Run tests on MacOS"
runs-on: macos-latest
env:
# LDFLAGS: "-ld64" # For MacOS 13 and above (XCode CLT 15 and above.)
CC: gcc-12
CXX: gcc-12
FC: gfortran-12
DUCC0_NUM_THREADS: 2
steps:
- uses: actions/checkout@v1
- uses: actions/setup-python@v1
with:
python-version: "3.9"
- name: Install Dependencies (MacOS)
run: |
python -m pip install --upgrade pip setuptools wheel
python -m pip install numpy "Cython<3.0.4"
- name: Install Package (MacOS)
# The built-in fortran compiler does not link to gfortran (just numbered versions)
# and build_ext does not play nicely with that. So we link gfortran-X to gfortran.
run: |
ln -s $FC $(dirname $(which $FC))/gfortran
echo "Using FC=$FC CXX=$CXX CC=$CC"
python setup.py build_ext -i
python -m pip install .
- name: Run Tests (MacOS)
run: |
pytest pixell/tests/ -s
build_wheels_linux:
name: Build wheels on Linux
runs-on: ubuntu-latest
strategy:
# Ensure that a wheel builder finishes even if another fails
fail-fast: false
matrix:
os: [ubuntu-20.04]
cp: [cp38, cp39, cp310, cp311]
include:
- cp: cp38
numpyver: "1.20"
- cp: cp39
numpyver: "1.20"
- cp: cp310
numpyver: "1.22"
- cp: cp311
numpyver: "1.22"
steps:
- uses: actions/checkout@v2
- uses: actions/setup-python@v2
name: Install Python
with:
python-version: '3.8'
- name: Install cibuildwheel and other dependencies
run: |
python -m pip install -U pip
python -m pip install -U setuptools
python -m pip install --upgrade pip setuptools wheel
python -m pip install pytest-cov numpy "Cython<3.0.4"
python -m pip install cibuildwheel
- name: Test and build wheels
run: |
ln -s $FC $(dirname $(which $FC))/gfortran
bash scripts/build_wheels.sh
env:
CIBW_ENVIRONMENT: OMP_NUM_THREADS=2
OPENBLAS_NUM_THREADS=2
CIBW_BEFORE_BUILD: "python -m pip install numpy==${{ matrix.numpyver }} scipy 'cython<3.0.4'"
CIBW_BUILD_VERBOSITY: 3
# If users are still on 32 bit systems or PPC they should build from source.
CIBW_BUILD: "${{ matrix.cp }}-manylinux_{x86_64,aarch64}"
CIBW_TEST_REQUIRES: pytest
CIBW_TEST_COMMAND: >
cd /
pytest {project}/pixell/tests -s
PYTHON: "python"
PIP: "pip"
- uses: actions/upload-artifact@v2
with:
path: ./wheelhouse/*.whl
build_wheels_macos:
name: Build wheels on MacOS
runs-on: macos-latest
env:
CC: gcc-12
CXX: gcc-12
FC: gfortran-12
DUCC0_NUM_THREADS: 2
strategy:
# Ensure that a wheel builder finishes even if another fails
fail-fast: false
matrix:
os: [macos-latest]
# We don't build 3.7 wheels for MacOS because that's x86 only.
cp: [cp38, cp39, cp310, cp311]
include:
- cp: cp38
numpyver: "1.20"
- cp: cp39
numpyver: "1.20"
- cp: cp310
numpyver: "1.22"
- cp: cp311
numpyver: "1.22"
steps:
- uses: actions/checkout@v2
- uses: actions/setup-python@v2
name: Install Python
with:
python-version: '3.9'
- name: Install cibuildwheel and other dependencies
run: |
python -m pip install -U pip
python -m pip install -U setuptools
python -m pip install --upgrade pip setuptools wheel
python -m pip install pytest-cov numpy "Cython<3.0.4"
python -m pip install cibuildwheel
- name: Test and build wheels
run: |
ln -s $FC $(dirname $(which $FC))/gfortran
bash scripts/build_wheels.sh
env:
CIBW_ENVIRONMENT: OMP_NUM_THREADS=2
OPENBLAS_NUM_THREADS=2
CIBW_BEFORE_BUILD: "python -m pip install numpy==${{ matrix.numpyver }} scipy 'cython<3.0.4'"
CIBW_BUILD_VERBOSITY: 3
# To build for both x86_64 and arm64, uncomment the following lines.
# That would require a fortran compiler that can cross-comile from
# x86_64 to arm64, as well as an OMP library that's cross-compiled.
# CIBW_BUILD: "${{ matrix.cp }}-macosx_{x86_64,arm64}"
CIBW_BUILD: "${{ matrix.cp }}-macosx_x86_64"
#CIBW_ARCHS_MACOS: "x86_64 arm64"
CIBW_ARCHS_MACOS: "x86_64"
CIBW_TEST_REQUIRES: pytest
CIBW_TEST_COMMAND: >
cd /
pytest {project}/pixell/tests -s
# Cannot test arm64 on non-native runner
CIBW_TEST_SKIP: "*_arm64"
PYTHON: "python"
PIP: "pip"
- uses: actions/upload-artifact@v2
with:
path: ./wheelhouse/*.whl
build_sdist:
name: Build source distribution
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: actions/setup-python@v2
name: Install Python
with:
python-version: '3.8'
- name: Build sdist
run: |
python -m pip install -U pip
python -m pip install -U setuptools
python -m pip install --upgrade pip setuptools wheel
python -m pip install "Cython<3.0.4"
python -m pip install numpy
python setup.py sdist
- uses: actions/upload-artifact@v2
with:
path: dist/*.tar.gz
upload_pypi:
needs: [build_wheels_linux, build_wheels_macos, build_sdist]
runs-on: ubuntu-latest
# upload to PyPI on every tag starting with 'v'
if: github.event_name == 'push' && startsWith(github.event.ref, 'refs/tags/v')
# alternatively, to publish when a GitHub Release is created, use the following rule:
# if: github.event_name == 'release' && github.event.action == 'published'
steps:
- uses: actions/download-artifact@v2
with:
name: artifact
path: dist
- uses: pypa/gh-action-pypi-publish@release/v1
with:
user: __token__
password: ${{ secrets.PYPI_TOKEN }}
# To test: repository_url: https://test.pypi.org/legacy/
# Automatically upload builds to PyPI test when all tests pass.
# Requires some thought about versioning before activating.
# upload_pypi_test:
# needs: [build_wheels_linux, build_wheels_macos, build_sdist]
# runs-on: ubuntu-latest
# environment:
# name: testpypi
# url: https://test.pypi.org/p/pixell
# # Upload to pypi testing on every successful test run and build generation
# steps:
# - uses: actions/download-artifact@v2
# with:
# name: artifact
# path: dist
# - uses: pypa/gh-action-pypi-publish@release/v1
# with:
# repository-url: https://test.pypi.org/legacy/
# user: __token__
# password: ${{ secrets.PYPI_TEST_TOKEN }}