-
Notifications
You must be signed in to change notification settings - Fork 11
393 lines (363 loc) · 14.9 KB
/
dist.yml
File metadata and controls
393 lines (363 loc) · 14.9 KB
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
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
name: Distributions
on:
push:
pull_request:
workflow_dispatch:
concurrency:
# Cancel previous runs of this workflow for the same branch
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true
jobs:
sdists_for_pypi:
name: Build sdist (and upload to PyPI on release tags)
runs-on: ubuntu-latest
env:
CAN_DEPLOY: ${{ secrets.PYPI_PASSWORD != '' }}
steps:
- uses: actions/checkout@v4
- uses: actions/setup-python@v4
- name: make sdist
run: |
python3 -m pip install build
python3 -m build --sdist
- uses: actions/upload-artifact@v4
with:
path: "dist/*.tar.gz"
name: dist
- uses: pypa/gh-action-pypi-publish@release/v1
with:
user: ${{ secrets.PYPI_USERNAME }}
password: ${{ secrets.PYPI_PASSWORD }}
skip_existing: true
verbose: true
if: env.CAN_DEPLOY == 'true' && github.event_name == 'push' && startsWith(github.ref, 'refs/tags')
build_wheels:
name: Build wheels on ${{ matrix.os }}, arch ${{ matrix.arch }}
runs-on: ${{ matrix.os }}
needs: sdists_for_pypi
strategy:
fail-fast: false
matrix:
include:
- os: ubuntu-latest
arch: x86_64
- os: ubuntu-latest
arch: i686
- os: ubuntu-24.04-arm
arch: aarch64
- os: macos-15-intel
arch: x86_64
- os: macos-14
arch: arm64
env:
# SPKGs to install as system packages
SPKGS: _bootstrap _prereq
# Non-Python packages to install as spkgs
TARGETS_PRE: gmp mpfr normaliz
# Disable building PyPy wheels on all platforms
CIBW_SKIP: "pp*"
#
CIBW_ARCHS: ${{ matrix.arch }}
# https://cibuildwheel.readthedocs.io/en/stable/options/#requires-python
CIBW_PROJECT_REQUIRES_PYTHON: ">=3.9"
# Environment during wheel build
CIBW_ENVIRONMENT: "PATH=$(pwd)/local/bin:$PATH CPATH=$(pwd)/local/include:$CPATH LIBRARY_PATH=$(pwd)/local/lib:$LIBRARY_PATH LD_LIBRARY_PATH=$(pwd)/local/lib:$LD_LIBRARY_PATH PKG_CONFIG_PATH=$(pwd)/local/share/pkgconfig:$PKG_CONFIG_PATH ACLOCAL_PATH=/usr/share/aclocal"
# Use 'build', not 'pip wheel'
CIBW_BUILD_FRONTEND: build
CIBW_REPAIR_WHEEL_COMMAND_LINUX: "set -x && export LD_LIBRARY_PATH=$(pwd)/prefix/lib:$LD_LIBRARY_PATH && auditwheel -v -v -v -v repair -w {dest_dir} {wheel}"
CIBW_REPAIR_WHEEL_COMMAND_MACOS: "set -x && export DYLD_FALLBACK_LIBRARY_PATH=$(pwd)/prefix/lib:$DYLD_FALLBACK_LIBRARY_PATH && delocate-wheel --require-archs {delocate_archs} -w {dest_dir} -v {wheel}"
CIBW_MANYLINUX_X86_64_IMAGE: manylinux_2_28
CIBW_MANYLINUX_AARCH64_IMAGE: manylinux_2_28
steps:
- uses: actions/checkout@v4
with:
repository: passagemath/passagemath
ref: main
- uses: actions/download-artifact@v4
with:
name: dist
path: dist
- uses: actions/setup-python@v5
# As of 2024-02-03, the macOS M1 runners do not have preinstalled python or pipx.
# Installing pipx follows the approach of https://github.com/pypa/cibuildwheel/pull/1743
id: python
with:
python-version: "3.8 - 3.12"
update-environment: false
- name: Retrieve configure tarball cache
id: cache-configure
uses: actions/cache/restore@v4
with:
path: |
build/pkgs/configure
upstream/configure*
key: >-
configure-build=${{
hashFiles('build',
'configure.ac',
'm4')
}}
- name: Bootstrap
if: steps.cache-configure.outputs.cache-hit != 'true'
# Patch python3 spkg-configure to allow Python 3.8.0 during the CIBW_BEFORE_ALL phase
run: |
export PATH=$(pwd)/build/bin:$PATH
eval $(sage-print-system-package-command auto --sudo --yes update)
eval $(sage-print-system-package-command auto --sudo --yes --no-install-recommends --spkg install _bootstrap bzip2 xz liblzma)
sed -i.bak '/m4_pushdef.*MIN_VERSION/s/3[0-9.]*/3.8.0/' build/pkgs/python3/spkg-configure.m4
./bootstrap -s
- name: Save configure tarball cache
if: steps.cache-configure.outputs.cache-hit != 'true'
uses: actions/cache/save@v4
with:
path: |
build/pkgs/configure
upstream/configure*
key: ${{ steps.cache-configure.outputs.cache-primary-key }}
- name: Build platform wheels
# We build the wheel from the sdist.
# But we must run cibuildwheel with the unpacked source directory, not a tarball,
# so that SAGE_ROOT is copied into the build containers.
#
# In the CIBW_BEFORE_ALL phase, we install libraries using the Sage distribution.
# https://cibuildwheel.readthedocs.io/en/stable/options/#before-all
run: |
"${{ steps.python.outputs.python-path }}" -m pip install pipx
if [ ! -x ./configure ]; then ./bootstrap -D; fi
touch configure
export PATH=build/bin:$PATH
export CIBW_BEFORE_ALL="( $(sage-print-system-package-command debian --yes --no-install-recommends install $(sage-get-system-packages debian $SPKGS)) || $(sage-print-system-package-command fedora --yes --no-install-recommends install $(sage-get-system-packages fedora $SPKGS | sed s/pkg-config/pkgconfig/)) || ( $(sage-print-system-package-command homebrew --yes --no-install-recommends install $(sage-get-system-packages homebrew $SPKGS)) || $(sage-print-system-package-command alpine --yes --no-install-recommends install $(sage-get-system-packages alpine $SPKGS)) || echo error ignored) ) && ./configure --enable-build-as-root --enable-fat-binary --disable-python-distutils-check && MAKE=\"make -j6\" make V=0 $TARGETS_PRE"
mkdir -p unpacked
for pkg in pynormaliz; do
(cd unpacked && tar xfz - ) < dist/$pkg*.tar.gz
"${{ steps.python.outputs.python-path }}" -m pipx run cibuildwheel==3.3.0 unpacked/$pkg*
done
- uses: actions/upload-artifact@v4
if: always()
with:
name: ${{ matrix.os }}-${{ matrix.build }}-${{ matrix.arch }}-wheels
path: ./wheelhouse/*.whl
build_wheels_windows:
name: Build wheels on ${{ matrix.os }} using ${{ matrix.env }}
runs-on: ${{ matrix.os }}
needs: sdists_for_pypi
strategy:
fail-fast: false
matrix:
include:
- os: windows-2022
msystem: ucrt64
env: ucrt-x86_64
arch: auto
build: "win_*64"
- os: windows-11-arm
msystem: clangarm64
env: clang-aarch64
arch: auto
build: "win_*64"
env:
# SPKGs to install as system packages
SPKGS: _bootstrap _prereq
# Non-Python packages to install as spkgs
TARGETS_PRE: normaliz
# Disable building PyPy wheels on all platforms
CIBW_SKIP: "pp*"
#
CIBW_ARCHS: ${{ matrix.arch }}
# https://cibuildwheel.readthedocs.io/en/stable/options/#requires-python
CIBW_PROJECT_REQUIRES_PYTHON: ">=3.9"
# Run before wheel build
CIBW_BEFORE_BUILD_WINDOWS: |
pip install delvewheel
# Environment during wheel build
# PYTHONUTF8=1 is for delvewheel
CIBW_ENVIRONMENT: >-
PATH="D:\\a\\sage\\sage\\sage-local\\bin;D:\\a\\sage\\sage\\build\\bin;$PATH"
INCLUDE="D:\\a\\sage\\sage\\sage-local\\include;%INCLUDE%"
LIB="D:\\a\\sage\\sage\\sage-local\\bin;D:\\a\\sage\\sage\\sage-local\\lib;%LIB%"
PKG_CONFIG_PATH=$(pwd)/prefix/lib/pkgconfig:$PKG_CONFIG_PATH
ACLOCAL_PATH=/usr/share/aclocal
PIP_FIND_LINKS=D:\\a\\sage\\sage\\wheelhouse' 'D:\\a\\sage\\sage\\dist
SAGE_NUM_THREADS=6
PYTHONUTF8=1
# Use 'build', not 'pip wheel'
CIBW_BUILD_FRONTEND: build
# CIBW_REPAIR_WHEEL_COMMAND_WINDOWS: "delvewheel repair -vv --custom-patch -w {dest_dir} {wheel}"
CIBW_REPAIR_WHEEL_COMMAND_WINDOWS: "delvewheel repair -vv -w {dest_dir} {wheel}"
#
CIBW_PLATFORM: windows
steps:
- uses: actions/checkout@v4
with:
repository: passagemath/passagemath
ref: main
- uses: actions/download-artifact@v4
with:
name: dist
path: dist
- uses: msys2/setup-msys2@v2
name: Setup msys2
with:
install: >-
mingw-w64-${{ matrix.env }}-gcc
autotools
python
python-pip
python-setuptools
patch
bison
mingw-w64-${{ matrix.env }}-cmake
mingw-w64-${{ matrix.env }}-ninja
mingw-w64-${{ matrix.env }}-gtest
mingw-w64-${{ matrix.env }}-ncurses
mingw-w64-${{ matrix.env }}-readline
mingw-w64-${{ matrix.env }}-texinfo
msystem: ${{ matrix.msystem }}
path-type: inherit
- name: Retrieve configure tarball cache
id: cache-configure
uses: actions/cache/restore@v4
with:
path: |
build/pkgs/configure
upstream/configure*
key: >-
configure-build=${{
hashFiles('build',
'configure.ac',
'm4')
}}
- name: Bootstrap
if: steps.cache-configure.outputs.cache-hit != 'true'
# Patch python3 spkg-configure to allow Python 3.8.0 during the CIBW_BEFORE_ALL phase
run: |
export PATH=$(pwd)/build/bin:$PATH
eval $(sage-print-system-package-command auto --yes update)
eval $(sage-print-system-package-command auto --yes --no-install-recommends --spkg install _bootstrap bzip2 xz liblzma)
sed -i.bak '/m4_pushdef.*MIN_VERSION/s/3[0-9.]*/3.8.0/' build/pkgs/python3/spkg-configure.m4
./bootstrap -s
shell: msys2 {0}
- name: Save configure tarball cache
if: steps.cache-configure.outputs.cache-hit != 'true'
uses: actions/cache/save@v4
with:
path: |
build/pkgs/configure
upstream/configure*
key: ${{ steps.cache-configure.outputs.cache-primary-key }}
- name: Retrieve SAGE_LOCAL cache
id: cache-sage-local
uses: actions/cache/restore@v4
with:
path: |
config.status
sage-local
key: >-
${{ runner.os }}-cibuildwheel-${{ matrix.arch }}-build=${{
hashFiles('build',
'configure.ac',
'm4')
}}
restore-keys: |
${{ runner.os }}-cibuildwheel-${{ matrix.arch }}
- name: Unpack and prepare
id: unpack
# We build the wheels from the sdists so that MANIFEST filtering becomes effective.
# But we must run cibuildwheel with the unpacked source directory, not a tarball,
# so that SAGE_ROOT is copied into the build containers.
#
# In the CIBW_BEFORE_ALL phase, we install libraries using the Sage distribution.
# https://cibuildwheel.readthedocs.io/en/stable/options/#before-all
# For Linux, this is repeated for each of the packages that we build wheels for
# because CIBW starts with a fresh container on each invocation.
# Therefore we cache it in a directory mounted from the host: /host
# https://cibuildwheel.pypa.io/en/stable/faq/#linux-builds-in-containers
#
# - configure --with-sage-venv makes the SAGE_VENV separate from SAGE_LOCAL.
# SAGE_LOCAL is put in PATH for the wheel building.
# SAGE_VENV must not be in PATH so it does not shadow cibuildwheel's build tools.
#
run: |
if [ ! -x ./configure ]; then ./bootstrap -D; fi
touch configure
SAGE_LOCAL=$(pwd)/sage-local
# We set the installation records to the same mtime so that no rebuilds due to dependencies
# among these packages are triggered.
dummy="$SAGE_LOCAL"/var/lib/sage/installed/.dummy
if [ -f "$dummy" ]; then
touch "$dummy"
for tree in "$SAGE_LOCAL" "$SAGE_LOCAL"/var/lib/sage/venv*; do
inst="$tree"/var/lib/sage/installed
if [ -d "$inst" ]; then
# -r is --reference; the macOS version of touch does not accept the long option.
(cd "$inst" && touch -r "$dummy" .dummy *)
# Show what has been built already.
ls -l "$tree" "$inst"
fi
done
fi
export PATH=build/bin:$PATH
echo CIBW_BEFORE_ALL="msys2 tools/cibw_before_all_windows.sh" >> "$GITHUB_ENV"
mkdir -p unpacked
set -x
for sdist in dist/$pkg*.tar.gz; do
(cd unpacked && tar xfz - && base=${sdist#dist/} && mv ${base%.tar.gz} ${base%-*}) < $sdist
done
shell: msys2 {0}
- name: pynormaliz wheels
id: pynormaliz
uses: pypa/cibuildwheel@v3.3.0
with:
package-dir: unpacked/pynormaliz
- name: Save SAGE_LOCAL cache
if: (success() || failure()) && steps.unpack.outcome == 'success'
uses: actions/cache/save@v4
with:
path: |
config.status
sage-local
!sage-local/lib64
key: ${{ steps.cache-sage-local.outputs.cache-primary-key }}
- uses: actions/upload-artifact@v4
with:
name: ${{ matrix.os }}-${{ matrix.arch }}-wheels
path: ./wheelhouse/*.whl
- uses: actions/upload-artifact@v4
if: always()
with:
name: unpacked-${{ matrix.os }}
path: ./unpacked
- uses: actions/upload-artifact@v4
if: always()
with:
name: sage-local-${{ matrix.os }}
path: ./sage-local
- uses: actions/upload-artifact@v4
if: always()
with:
name: logs-${{ matrix.os }}
path: ./logs
pypi-publish:
# This needs to be a separate job because pypa/gh-action-pypi-publish cannot run on macOS
# https://github.com/pypa/gh-action-pypi-publish
name: Upload wheels to PyPI
needs: [build_wheels, build_wheels_windows]
if: (success() || failure()) && github.event_name == 'push' && startsWith(github.ref, 'refs/tags')
runs-on: ubuntu-latest
env:
CAN_DEPLOY: ${{ secrets.PYPI_PASSWORD != '' }}
steps:
- uses: actions/download-artifact@v4
with:
pattern: "*-wheels"
path: wheelhouse
merge-multiple: true
- name: Publish package distributions to PyPI
uses: pypa/gh-action-pypi-publish@release/v1
with:
user: ${{ secrets.PYPI_USERNAME }}
password: ${{ secrets.PYPI_PASSWORD }}
packages_dir: wheelhouse/
skip_existing: true
verbose: true
if: env.CAN_DEPLOY == 'true'