Skip to content

Commit 248fde3

Browse files
author
Release Manager
committed
sagemathgh-37099: GH Actions: Build platform-independent wheels of sagemath-environment, sage-setup, sage-sws2rst for PyPI <!-- ^^^^^ Please provide a concise, informative and self-explanatory title. Don't put issue numbers in there, do this in the PR body below. For example, instead of "Fixes sagemath#1234" use "Introduce new method to calculate 1+1" --> <!-- Describe your changes here in detail --> <!-- Why is this change required? What problem does it solve? --> We already build platform wheels for **sagemath-{objects,categories,repl}** for PyPI using cibuildwheel. Here we add building of platform-independent wheels for **sagemath- environment** and **sage-setup** and **sage-sws2rst** to the GH Actions workflow. (They are needed, for example, for pyodide / jupyterlite.) To test locally: `make pypi-noarch-wheels` We also update actions/upload-artifact, actions/download-artifact to v4. This requires a restructuring, as we can no longer upload the wheels for different architectures (built by separate matrix jobs) to the same artifact: https://github.com/actions/upload-artifact?tab=readme-ov- file#not-uploading-to-the-same-artifact Instead we upload them as separate artifacts and deploy them to PyPI directly from the job that built them. This is: - part of sagemath#31251 <!-- If this PR resolves an open issue, please link to it here. For example "Fixes sagemath#12345". --> <!-- If your change requires a documentation PR, please link it appropriately. --> ### 📝 Checklist <!-- Put an `x` in all the boxes that apply. --> <!-- If your change requires a documentation PR, please link it appropriately --> <!-- If you're unsure about any of these, don't hesitate to ask. We're here to help! --> <!-- Feel free to remove irrelevant items. --> - [x] The title is concise, informative, and self-explanatory. - [x] The description explains in detail what this PR is about. - [ ] I have linked a relevant issue or discussion. - [ ] I have created tests covering the changes. - [ ] I have updated the documentation accordingly. ### ⌛ Dependencies <!-- List all open PRs that this PR logically depends on - sagemath#12345: short description why this is a dependency - sagemath#34567: ... --> <!-- If you're unsure about any of these, don't hesitate to ask. We're here to help! --> URL: sagemath#37099 Reported by: Matthias Köppe Reviewer(s): Kwankyu Lee, Matthias Köppe
2 parents 90e08c8 + c3eb320 commit 248fde3

File tree

2 files changed

+50
-21
lines changed

2 files changed

+50
-21
lines changed

.github/workflows/dist.yml

+37-18
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ jobs:
4747
./configure && make dist
4848
env:
4949
MAKE: make -j8
50-
- uses: actions/upload-artifact@v3
50+
- uses: actions/upload-artifact@v4
5151
if: success() || failure()
5252
with:
5353
path: |
@@ -61,7 +61,7 @@ jobs:
6161
runs-on: ubuntu-latest
6262
if: (success() || failure()) && github.repository == 'sagemath/sage' && startsWith(github.ref, 'refs/tags/') && !contains(github.ref, 'beta') && !contains(github.ref, 'rc')
6363
steps:
64-
- uses: actions/download-artifact@v3
64+
- uses: actions/download-artifact@v4
6565
with:
6666
name: release_dist
6767
- uses: softprops/action-gh-release@v1
@@ -91,7 +91,7 @@ jobs:
9191
make pypi-sdists V=0
9292
(mkdir dist && mv upstream/sage*.tar.gz dist/)
9393
ls -l dist
94-
- uses: actions/upload-artifact@v3
94+
- uses: actions/upload-artifact@v4
9595
with:
9696
path: "dist/*.tar.gz"
9797
name: dist
@@ -103,6 +103,36 @@ jobs:
103103
verbose: true
104104
if: env.CAN_DEPLOY == 'true'
105105

106+
noarch_wheels_for_pypi:
107+
108+
runs-on: ubuntu-latest
109+
env:
110+
CAN_DEPLOY: ${{ secrets.SAGEMATH_PYPI_API_TOKEN != '' }}
111+
steps:
112+
- uses: actions/checkout@v4
113+
- name: Install bootstrap prerequisites
114+
run: |
115+
sudo DEBIAN_FRONTEND=noninteractive apt-get update
116+
sudo DEBIAN_FRONTEND=noninteractive apt-get install $(build/bin/sage-get-system-packages debian _bootstrap)
117+
- name: make pypi-noarch-wheels
118+
run: |
119+
./bootstrap
120+
./configure
121+
make pypi-noarch-wheels V=0
122+
(mkdir dist && mv venv/var/lib/sage/wheels/sage*-none-any.whl dist/)
123+
ls -l dist
124+
- uses: actions/upload-artifact@v4
125+
with:
126+
path: "dist/*.whl"
127+
name: noarch-wheels
128+
- uses: pypa/gh-action-pypi-publish@release/v1
129+
with:
130+
user: __token__
131+
password: ${{ secrets.SAGEMATH_PYPI_API_TOKEN }}
132+
skip-existing: true
133+
verbose: true
134+
if: env.CAN_DEPLOY == 'true'
135+
106136
build_wheels:
107137
name: Build wheels on ${{ matrix.os }}, arch ${{ matrix.arch }}
108138
runs-on: ${{ matrix.os }}
@@ -120,6 +150,7 @@ jobs:
120150
- os: macos-14
121151
arch: arm64
122152
env:
153+
CAN_DEPLOY: ${{ secrets.SAGEMATH_PYPI_API_TOKEN != '' }}
123154
# SPKGs to install as system packages
124155
SPKGS: _bootstrap _prereq
125156
# Non-Python packages to install as spkgs
@@ -138,7 +169,7 @@ jobs:
138169
steps:
139170
- uses: actions/checkout@v4
140171

141-
- uses: actions/download-artifact@v3
172+
- uses: actions/download-artifact@v4
142173
with:
143174
name: dist
144175
path: dist
@@ -170,23 +201,11 @@ jobs:
170201
"${{ steps.python.outputs.python-path }}" -m pipx run cibuildwheel==2.17.0 unpacked/$pkg*
171202
done
172203
173-
- uses: actions/upload-artifact@v3
204+
- uses: actions/upload-artifact@v4
174205
with:
175-
name: wheels
206+
name: ${{ matrix.os }}-${{ matrix.arch }}-wheels
176207
path: ./wheelhouse/*.whl
177208

178-
upload_wheels:
179-
needs: build_wheels
180-
runs-on: ubuntu-latest
181-
env:
182-
CAN_DEPLOY: ${{ secrets.SAGEMATH_PYPI_API_TOKEN != '' }}
183-
steps:
184-
185-
- uses: actions/download-artifact@v3
186-
with:
187-
name: wheels
188-
path: wheelhouse
189-
190209
- uses: pypa/gh-action-pypi-publish@release/v1
191210
with:
192211
user: __token__

build/make/Makefile.in

+13-3
Original file line numberDiff line numberDiff line change
@@ -128,11 +128,14 @@ PIP_PACKAGES = @SAGE_PIP_PACKAGES@
128128
# Packages that use the 'script' package build rules
129129
SCRIPT_PACKAGES = @SAGE_SCRIPT_PACKAGES@
130130

131-
# Packages for which we build wheels for PyPI
132-
PYPI_WHEEL_PACKAGES = \
131+
# Packages for which we build platform-independent wheels for PyPI
132+
PYPI_NOARCH_WHEEL_PACKAGES = \
133133
sage_sws2rst \
134134
sage_setup \
135135
sagemath_environment \
136+
137+
# Packages for which we build wheels for PyPI
138+
PYPI_WHEEL_PACKAGES = $(PYPI_NOARCH_WHEEL_PACKAGES) \
136139
sagemath_objects \
137140
sagemath_repl \
138141
sagemath_categories \
@@ -220,7 +223,7 @@ SAGE_I_TARGETS = sagelib doc
220223
# Tell make not to look for files with these names:
221224
.PHONY: all all-sage all-toolchain all-build all-sageruntime \
222225
all-start build-start base toolchain toolchain-deps base-toolchain \
223-
pypi-sdists pypi-wheels wheels \
226+
pypi-sdists pypi-noarch-wheels pypi-wheels wheels \
224227
sagelib \
225228
doc doc-html doc-html-jsmath doc-html-mathjax doc-pdf \
226229
doc-uninstall \
@@ -453,6 +456,13 @@ pypi-sdists: $(PYPI_SDIST_PACKAGES:%=%-sdist)
453456
# Ensuring wheels are present, even for packages that may have been installed
454457
# as editable. Until we have better uninstallation of script packages, we
455458
# just remove the timestamps, which will lead to rebuilds of the packages.
459+
pypi-noarch-wheels:
460+
for a in $(PYPI_NOARCH_WHEEL_PACKAGES); do \
461+
rm -f $(SAGE_VENV)/var/lib/sage/installed/$$a-*; \
462+
done
463+
$(MAKE_REC) SAGE_EDITABLE=no SAGE_WHEELS=yes $(PYPI_NOARCH_WHEEL_PACKAGES)
464+
@echo "Built wheels are in venv/var/lib/sage/wheels/"
465+
456466
pypi-wheels:
457467
for a in $(PYPI_WHEEL_PACKAGES); do \
458468
rm -f $(SAGE_VENV)/var/lib/sage/installed/$$a-*; \

0 commit comments

Comments
 (0)