Skip to content

Commit 107a6a1

Browse files
committed
.github/workflows/dist.yml: Update, add Windows
1 parent 5d39b8c commit 107a6a1

File tree

1 file changed

+261
-18
lines changed

1 file changed

+261
-18
lines changed

.github/workflows/dist.yml

Lines changed: 261 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ jobs:
2424
run: |
2525
python3 -m pip install build
2626
python3 -m build --sdist
27-
- uses: actions/upload-artifact@v3
27+
- uses: actions/upload-artifact@v4
2828
with:
2929
path: "dist/*.tar.gz"
3030
name: dist
@@ -48,7 +48,9 @@ jobs:
4848
arch: x86_64
4949
- os: ubuntu-latest
5050
arch: i686
51-
- os: macos-latest
51+
- os: ubuntu-24.04-arm
52+
arch: aarch64
53+
- os: macos-13
5254
arch: auto
5355
- os: macos-14
5456
arch: auto
@@ -58,8 +60,7 @@ jobs:
5860
# Non-Python packages to install as spkgs
5961
TARGETS_PRE: gmp mpfr mpc ppl-ensure
6062
# Disable building PyPy wheels on all platforms
61-
# Disable musllinux until #33083 provides alpine package information
62-
CIBW_SKIP: "pp* *-musllinux*"
63+
CIBW_SKIP: "pp*"
6364
#
6465
CIBW_ARCHS: ${{ matrix.arch }}
6566
# https://cibuildwheel.readthedocs.io/en/stable/options/#requires-python
@@ -68,13 +69,17 @@ jobs:
6869
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"
6970
# Use 'build', not 'pip wheel'
7071
CIBW_BUILD_FRONTEND: build
72+
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}"
73+
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}"
74+
CIBW_MANYLINUX_X86_64_IMAGE: manylinux_2_28
75+
CIBW_MANYLINUX_AARCH64_IMAGE: manylinux_2_28
7176
steps:
7277
- uses: actions/checkout@v4
7378
with:
74-
repository: sagemath/sage
75-
ref: develop
79+
repository: passagemath/passagemath
80+
ref: main
7681

77-
- uses: actions/download-artifact@v3
82+
- uses: actions/download-artifact@v4
7883
with:
7984
name: dist
8085
path: dist
@@ -87,6 +92,39 @@ jobs:
8792
python-version: "3.8 - 3.12"
8893
update-environment: false
8994

95+
- name: Retrieve configure tarball cache
96+
id: cache-configure
97+
uses: actions/cache/restore@v4
98+
with:
99+
path: |
100+
build/pkgs/configure
101+
upstream/configure*
102+
key: >-
103+
configure-build=${{
104+
hashFiles('build',
105+
'configure.ac',
106+
'm4')
107+
}}
108+
109+
- name: Bootstrap
110+
if: steps.cache-configure.outputs.cache-hit != 'true'
111+
# Patch python3 spkg-configure to allow Python 3.8.0 during the CIBW_BEFORE_ALL phase
112+
run: |
113+
export PATH=$(pwd)/build/bin:$PATH
114+
eval $(sage-print-system-package-command auto --sudo --yes update)
115+
eval $(sage-print-system-package-command auto --sudo --yes --no-install-recommends --spkg install _bootstrap bzip2 xz liblzma)
116+
sed -i.bak '/m4_pushdef.*MIN_VERSION/s/3[0-9.]*/3.8.0/' build/pkgs/python3/spkg-configure.m4
117+
./bootstrap -s
118+
119+
- name: Save configure tarball cache
120+
if: steps.cache-configure.outputs.cache-hit != 'true'
121+
uses: actions/cache/save@v4
122+
with:
123+
path: |
124+
build/pkgs/configure
125+
upstream/configure*
126+
key: ${{ steps.cache-configure.outputs.cache-primary-key }}
127+
90128
- name: Build platform wheels
91129
# We build the wheel from the sdist.
92130
# But we must run cibuildwheel with the unpacked source directory, not a tarball,
@@ -96,17 +134,211 @@ jobs:
96134
# https://cibuildwheel.readthedocs.io/en/stable/options/#before-all
97135
run: |
98136
"${{ steps.python.outputs.python-path }}" -m pip install pipx
137+
if [ ! -x ./configure ]; then ./bootstrap -D; fi
138+
touch configure
99139
export PATH=build/bin:$PATH
100-
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)) || echo error ignored) ) && ./bootstrap && ./configure --enable-build-as-root --enable-fat-binary && MAKE=\"make -j6\" make V=0 $TARGETS_PRE"
140+
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"
101141
mkdir -p unpacked
102-
for pkg in pplpy; do
142+
for pkg in passagemath_ppl; do
103143
(cd unpacked && tar xfz - ) < dist/$pkg*.tar.gz
104-
"${{ steps.python.outputs.python-path }}" -m pipx run cibuildwheel==2.17.0 unpacked/$pkg*
144+
"${{ steps.python.outputs.python-path }}" -m pipx run cibuildwheel==2.21.3 unpacked/$pkg*
105145
done
106146
107-
- uses: actions/upload-artifact@v3
147+
build_wheels_windows:
148+
name: Build wheels on ${{ matrix.os }} using ${{ matrix.env }}
149+
runs-on: ${{ matrix.os }}
150+
needs: sdists_for_pypi
151+
strategy:
152+
fail-fast: false
153+
matrix:
154+
include:
155+
- os: windows-2022
156+
msystem: ucrt64
157+
env: ucrt-x86_64
158+
arch: auto
159+
build: "win_*64"
160+
- os: windows-11-arm
161+
msystem: clangarm64
162+
env: clang-aarch64
163+
arch: auto
164+
build: "win_*64"
165+
env:
166+
# SPKGs to install as system packages
167+
SPKGS: _bootstrap _prereq
168+
# Non-Python packages to install as spkgs
169+
TARGETS_PRE: ppl-ensure
170+
# Disable building PyPy wheels on all platforms
171+
CIBW_SKIP: "pp*"
172+
#
173+
CIBW_ARCHS: ${{ matrix.arch }}
174+
# https://cibuildwheel.readthedocs.io/en/stable/options/#requires-python
175+
CIBW_PROJECT_REQUIRES_PYTHON: ">=3.9"
176+
# Run before wheel build
177+
CIBW_BEFORE_BUILD_WINDOWS: |
178+
pip install delvewheel
179+
# Environment during wheel build
180+
# PYTHONUTF8=1 is for delvewheel
181+
CIBW_ENVIRONMENT: >-
182+
PATH="D:\\a\\sage\\sage\\sage-local\\bin;D:\\a\\sage\\sage\\build\\bin;$PATH"
183+
INCLUDE="D:\\a\\sage\\sage\\sage-local\\include;%INCLUDE%"
184+
LIB="D:\\a\\sage\\sage\\sage-local\\bin;D:\\a\\sage\\sage\\sage-local\\lib;%LIB%"
185+
PKG_CONFIG_PATH=$(pwd)/prefix/lib/pkgconfig:$PKG_CONFIG_PATH
186+
ACLOCAL_PATH=/usr/share/aclocal
187+
PIP_FIND_LINKS=D:\\a\\sage\\sage\\wheelhouse' 'D:\\a\\sage\\sage\\dist
188+
SAGE_NUM_THREADS=6
189+
PYTHONUTF8=1
190+
# Use 'build', not 'pip wheel'
191+
CIBW_BUILD_FRONTEND: build
192+
# CIBW_REPAIR_WHEEL_COMMAND_WINDOWS: "delvewheel repair -vv --custom-patch -w {dest_dir} {wheel}"
193+
CIBW_REPAIR_WHEEL_COMMAND_WINDOWS: "delvewheel repair -vv -w {dest_dir} {wheel}"
194+
#
195+
CIBW_PLATFORM: windows
196+
steps:
197+
- uses: actions/checkout@v4
198+
with:
199+
repository: passagemath/passagemath
200+
ref: main
201+
202+
- uses: actions/download-artifact@v4
203+
with:
204+
name: dist
205+
path: dist
206+
207+
- uses: msys2/setup-msys2@v2
208+
name: Setup msys2
108209
with:
109-
name: wheels
210+
install: >-
211+
mingw-w64-${{ matrix.env }}-gcc
212+
autotools
213+
python
214+
python-pip
215+
python-setuptools
216+
patch
217+
bison
218+
mingw-w64-${{ matrix.env }}-cmake
219+
mingw-w64-${{ matrix.env }}-ninja
220+
mingw-w64-${{ matrix.env }}-gtest
221+
mingw-w64-${{ matrix.env }}-ncurses
222+
mingw-w64-${{ matrix.env }}-readline
223+
mingw-w64-${{ matrix.env }}-texinfo
224+
msystem: ${{ matrix.msystem }}
225+
path-type: inherit
226+
227+
- name: Retrieve configure tarball cache
228+
id: cache-configure
229+
uses: actions/cache/restore@v4
230+
with:
231+
path: |
232+
build/pkgs/configure
233+
upstream/configure*
234+
key: >-
235+
configure-build=${{
236+
hashFiles('build',
237+
'configure.ac',
238+
'm4')
239+
}}
240+
241+
- name: Bootstrap
242+
if: steps.cache-configure.outputs.cache-hit != 'true'
243+
# Patch python3 spkg-configure to allow Python 3.8.0 during the CIBW_BEFORE_ALL phase
244+
run: |
245+
export PATH=$(pwd)/build/bin:$PATH
246+
eval $(sage-print-system-package-command auto --yes update)
247+
eval $(sage-print-system-package-command auto --yes --no-install-recommends --spkg install _bootstrap bzip2 xz liblzma)
248+
sed -i.bak '/m4_pushdef.*MIN_VERSION/s/3[0-9.]*/3.8.0/' build/pkgs/python3/spkg-configure.m4
249+
./bootstrap -s
250+
shell: msys2 {0}
251+
252+
- name: Save configure tarball cache
253+
if: steps.cache-configure.outputs.cache-hit != 'true'
254+
uses: actions/cache/save@v4
255+
with:
256+
path: |
257+
build/pkgs/configure
258+
upstream/configure*
259+
key: ${{ steps.cache-configure.outputs.cache-primary-key }}
260+
261+
- name: Retrieve SAGE_LOCAL cache
262+
id: cache-sage-local
263+
uses: actions/cache/restore@v4
264+
with:
265+
path: |
266+
config.status
267+
sage-local
268+
key: >-
269+
${{ runner.os }}-cibuildwheel-${{ matrix.arch }}-build=${{
270+
hashFiles('build',
271+
'configure.ac',
272+
'm4')
273+
}}
274+
restore-keys: |
275+
${{ runner.os }}-cibuildwheel-${{ matrix.arch }}
276+
277+
- name: Unpack and prepare
278+
id: unpack
279+
# We build the wheels from the sdists so that MANIFEST filtering becomes effective.
280+
# But we must run cibuildwheel with the unpacked source directory, not a tarball,
281+
# so that SAGE_ROOT is copied into the build containers.
282+
#
283+
# In the CIBW_BEFORE_ALL phase, we install libraries using the Sage distribution.
284+
# https://cibuildwheel.readthedocs.io/en/stable/options/#before-all
285+
# For Linux, this is repeated for each of the packages that we build wheels for
286+
# because CIBW starts with a fresh container on each invocation.
287+
# Therefore we cache it in a directory mounted from the host: /host
288+
# https://cibuildwheel.pypa.io/en/stable/faq/#linux-builds-in-containers
289+
#
290+
# - configure --with-sage-venv makes the SAGE_VENV separate from SAGE_LOCAL.
291+
# SAGE_LOCAL is put in PATH for the wheel building.
292+
# SAGE_VENV must not be in PATH so it does not shadow cibuildwheel's build tools.
293+
#
294+
run: |
295+
if [ ! -x ./configure ]; then ./bootstrap -D; fi
296+
touch configure
297+
SAGE_LOCAL=$(pwd)/sage-local
298+
# We set the installation records to the same mtime so that no rebuilds due to dependencies
299+
# among these packages are triggered.
300+
dummy="$SAGE_LOCAL"/var/lib/sage/installed/.dummy
301+
if [ -f "$dummy" ]; then
302+
touch "$dummy"
303+
for tree in "$SAGE_LOCAL" "$SAGE_LOCAL"/var/lib/sage/venv*; do
304+
inst="$tree"/var/lib/sage/installed
305+
if [ -d "$inst" ]; then
306+
# -r is --reference; the macOS version of touch does not accept the long option.
307+
(cd "$inst" && touch -r "$dummy" .dummy *)
308+
# Show what has been built already.
309+
ls -l "$tree" "$inst"
310+
fi
311+
done
312+
fi
313+
314+
export PATH=build/bin:$PATH
315+
echo CIBW_BEFORE_ALL="msys2 tools/cibw_before_all_windows.sh" >> "$GITHUB_ENV"
316+
mkdir -p unpacked
317+
set -x
318+
for sdist in dist/$pkg*.tar.gz; do
319+
(cd unpacked && tar xfz - && base=${sdist#dist/} && mv ${base%.tar.gz} ${base%-*}) < $sdist
320+
done
321+
shell: msys2 {0}
322+
323+
- name: passagemath-ppl wheels
324+
id: passagemath-ppl
325+
uses: pypa/cibuildwheel@v2.23.0
326+
with:
327+
package-dir: unpacked/passagemath_ppl
328+
329+
- name: Save SAGE_LOCAL cache
330+
if: (success() || failure()) && steps.unpack.outcome == 'success'
331+
uses: actions/cache/save@v4
332+
with:
333+
path: |
334+
config.status
335+
sage-local
336+
!sage-local/lib64
337+
key: ${{ steps.cache-sage-local.outputs.cache-primary-key }}
338+
339+
- uses: actions/upload-artifact@v4
340+
with:
341+
name: ${{ matrix.os }}-${{ matrix.arch }}-wheels
110342
path: ./wheelhouse/*.whl
111343

112344
pypi-publish:
@@ -118,18 +350,29 @@ jobs:
118350
env:
119351
CAN_DEPLOY: ${{ secrets.SAGEMATH_PYPI_API_TOKEN != '' }}
120352
steps:
121-
122-
- uses: actions/download-artifact@v3
353+
- uses: actions/download-artifact@v4
123354
with:
124-
name: wheels
125-
path: wheelhouse
126-
355+
name: dist
356+
path: dist
357+
- uses: actions/download-artifact@v4
358+
with:
359+
pattern: "*-wheels"
360+
path: dist
361+
merge-multiple: true
127362
- name: Publish package distributions to PyPI
128363
uses: pypa/gh-action-pypi-publish@release/v1
129364
with:
130365
user: __token__
131366
password: ${{ secrets.SAGEMATH_PYPI_API_TOKEN }}
132-
packages_dir: wheelhouse/
367+
packages_dir: dist/
133368
skip_existing: true
134369
verbose: true
135370
if: env.CAN_DEPLOY == 'true'
371+
- uses: softprops/action-gh-release@v2
372+
with:
373+
generate_release_notes: true
374+
prerelease: ${{ contains(github.ref, 'alpha') || contains(github.ref, 'beta') || contains(github.ref, 'dev') || contains(github.ref, 'rc') }}
375+
files: |
376+
dist/*
377+
permissions:
378+
contents: write

0 commit comments

Comments
 (0)