Skip to content

Commit a7baa9b

Browse files
committed
zstandard: rebuild workflow from upstream wheel.yml
Reshape the workflow after indygreg/python-zstandard's own .github/workflows/wheel.yml instead of build-numpy.yml, as discussed in the review, and follow the current development guide. Their Linux job is a py x arch x abi x image matrix driven entirely by [tool.cibuildwheel] in pyproject.toml. On riscv64 there is one image and no musllinux for now, so it collapses to the Python versions, keeping upstream's job name, matrix key, cibuildwheel invocation and env layout. Build frontend, environment, test-command, test-groups and test-sources all come from the project's own config rather than being restated here, and PIP_EXTRA_INDEX_URL is forwarded into the container instead of being set through CIBW_ENVIRONMENT so that upstream's ZSTD_WARNINGS_AS_ERRORS survives. Replace the inline pyproject rewrite with a patch under patches/zstandard/, so the change to the enable groups carries an Upstream-Status tag pointing at the commit that dropped them upstream after the 0.25.0 tag. Trim the matrix to the default 3.12 to 3.14t set, drop the submodule fetch since the project has none, and switch publishing to the publish-wheels action with the permissions it needs, dropping the branch check that the dry-run logic now handles. Refs #163. Signed-off-by: Bruno Verachten <gounthar@gmail.com>
1 parent 4af963f commit a7baa9b

2 files changed

Lines changed: 89 additions & 45 deletions

File tree

.github/workflows/build-zstandard.yml

Lines changed: 54 additions & 45 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ on:
1111
pull_request:
1212
paths:
1313
- '.github/workflows/build-zstandard.yml'
14-
- 'actions/publish-to-gitlab/**'
14+
- 'patches/zstandard/**'
1515

1616
concurrency:
1717
group: ${{ github.workflow }}-${{ inputs.version || '0.25.0' }}-${{ github.head_ref || github.run_id }}
@@ -26,82 +26,91 @@ env:
2626
UV_EXTRA_INDEX_URL: https://pypi.riseproject.dev/simple/
2727
UV_INDEX_STRATEGY: unsafe-best-match
2828
UV_ONLY_BINARY: ':all:'
29+
MANYLINUX_RISCV64_IMAGE: quay.io/pypa/manylinux_2_39_riscv64
30+
# The version upstream runs in wheel.yml since they moved off 3.1.4
31+
CIBUILDWHEEL_VERSION: '4.1.0'
2932

3033
jobs:
31-
build_wheels:
32-
name: Build zstandard ${{ inputs.version || '0.25.0' }} ${{ matrix.python }}-manylinux_riscv64
34+
# Upstream's Linux job builds a py x arch x abi x image matrix. On riscv64
35+
# only one image exists, and musllinux is left out for now, so the matrix
36+
# collapses to the Python versions.
37+
linux:
38+
name: Build zstandard ${{ inputs.version || '0.25.0' }} ${{ matrix.py }}-manylinux_riscv64
3339
runs-on: ubuntu-24.04-riscv
3440
strategy:
3541
fail-fast: false
3642
matrix:
37-
python: ["cp311", "cp312", "cp313", "cp314", "cp314t"]
43+
py: ["cp312", "cp313", "cp314", "cp314t"]
3844

3945
steps:
40-
# zstandard vendors the zstd C library as a submodule and, unlike numpy,
41-
# tags releases without a leading `v` (e.g. `0.25.0`), so the ref is the
42-
# bare version.
46+
# zstandard tags releases without a leading `v` (e.g. `0.25.0`), so the ref
47+
# is the bare version.
4348
- name: Checkout zstandard ${{ env.ZSTANDARD_VERSION }}
4449
uses: actions/checkout@9c091bb21b7c1c1d1991bb908d89e4e9dddfe3e0 # v7.0.0
4550
with:
4651
repository: indygreg/python-zstandard
4752
ref: ${{ env.ZSTANDARD_VERSION }}
48-
submodules: recursive
4953
persist-credentials: false
5054

51-
# zstandard 0.25.0 targets cibuildwheel 3.x and pins
52-
# `enable = ["cpython-freethreading", "cpython-prerelease"]`. cibuildwheel
53-
# 4.x dropped the cpython-freethreading group (freethreaded builds are on
54-
# by default now) and errors out on it at config-parse. Strip it so the
55-
# pinned 4.1.0 can read the config; freethreaded cp314t still builds.
56-
# Upstream HEAD already removed it, so this is only needed for this tag.
57-
- name: Make pyproject enable groups compatible with cibuildwheel 4.x
58-
working-directory: ${{ github.workspace }}
55+
- name: Checkout python-wheels
56+
uses: actions/checkout@9c091bb21b7c1c1d1991bb908d89e4e9dddfe3e0 # v7.0.0
57+
with:
58+
path: python-wheels
59+
persist-credentials: false
60+
61+
# 0.25.0 still lists the cpython-freethreading enable group, which
62+
# cibuildwheel 4.x rejects. Upstream dropped it after the tag.
63+
- name: Patch zstandard source
5964
run: |
60-
python3 - <<'PY'
61-
import pathlib
62-
p = pathlib.Path("pyproject.toml")
63-
t = p.read_text()
64-
for tok in ('"cpython-freethreading", ', ', "cpython-freethreading"',
65-
'"cpython-freethreading"'):
66-
t = t.replace(tok, "")
67-
p.write_text(t)
68-
PY
65+
git apply python-wheels/patches/zstandard/${{ env.ZSTANDARD_VERSION }}/00*.patch
6966
67+
- name: Install uv
68+
uses: astral-sh/setup-uv@fac544c07dec837d0ccb6301d7b5580bf5edae39 # v8.2.0
69+
with:
70+
python-version: '3.12'
71+
activate-environment: true
72+
enable-cache: false
73+
74+
# Upstream runs `uvx -p 3.13 cibuildwheel@4.1.0`. We build with the 3.12
75+
# environment the development guide standardises on for these runners.
76+
# Everything else (build-frontend, environment, test-command, test-groups,
77+
# test-sources) comes from [tool.cibuildwheel] in the project's own
78+
# pyproject.toml. PIP_EXTRA_INDEX_URL is forwarded rather than set through
79+
# CIBW_ENVIRONMENT so that upstream's ZSTD_WARNINGS_AS_ERRORS survives; it
80+
# gets cffi and the dev test group from our registry instead of building
81+
# them in the container.
7082
- name: Build wheels
71-
uses: pypa/cibuildwheel@294735312765b09d24a2fbec22660ce817587d55 # v4.1.0
83+
run: uvx cibuildwheel@${{ env.CIBUILDWHEEL_VERSION }}
7284
env:
73-
CIBW_BUILD: ${{ matrix.python }}-manylinux_riscv64
85+
CIBW_ARCHS: riscv64
86+
CIBW_BUILD: ${{ matrix.py }}-manylinux_riscv64
87+
CIBW_BUILD_VERBOSITY: '1'
88+
CIBW_MANYLINUX_RISCV64_IMAGE: ${{ env.MANYLINUX_RISCV64_IMAGE }}
89+
CIBW_ENVIRONMENT_PASS_LINUX: PIP_EXTRA_INDEX_URL
90+
PIP_EXTRA_INDEX_URL: https://pypi.riseproject.dev/simple/
7491

92+
# Upstream skips the upload for freethreaded builds; we keep ours, since
93+
# cp314t is part of the matrix we publish.
7594
- uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7.0.1
7695
with:
77-
name: zstandard-${{ env.ZSTANDARD_VERSION }}-${{ matrix.python }}-manylinux_riscv64
96+
name: zstandard-${{ env.ZSTANDARD_VERSION }}-${{ matrix.py }}-manylinux_riscv64
7897
path: ./wheelhouse/*.whl
7998
if-no-files-found: error
8099

81100
publish:
82101
name: Publish zstandard ${{ inputs.version || '0.25.0' }} to GitLab
83-
needs: build_wheels
84-
# Only publish when the workflow was triggered from main with a specific
85-
# version. Manual trigger is the only entry point, so checking the ref is
86-
# enough to gate uploads.
87-
if: github.ref == 'refs/heads/main'
102+
needs: [linux]
88103
runs-on: ubuntu-latest
89104
permissions:
90-
contents: read
105+
contents: write
106+
pull-requests: write
91107

92108
steps:
93-
- name: Download wheels
94-
uses: actions/download-artifact@3e5f45b2cfb9172054b4087a40e8e0b5a5461e7c # v8.0.1
95-
with:
96-
pattern: zstandard-${{ env.ZSTANDARD_VERSION }}-*-manylinux_riscv64
97-
path: dist
98-
merge-multiple: true
99-
100-
- name: Publish to GitLab PyPI registry
101-
uses: riseproject-dev/python-wheels/actions/publish-to-gitlab@main
109+
- name: Publish wheels and open docs PR
110+
uses: riseproject-dev/python-wheels/actions/publish-wheels@main
102111
with:
112+
artifact-pattern: zstandard-${{ env.ZSTANDARD_VERSION }}-*-manylinux_riscv64
103113
gitlab-username: ${{ vars.GITLAB_DEPLOY_USER }}
104114
gitlab-token: ${{ secrets.GITLAB_DEPLOY_TOKEN }}
105115
gitlab-project-id: ${{ vars.GITLAB_PROJECT_ID }}
106-
files: |
107-
dist/*.whl
116+
gh-token: ${{ secrets.GITHUB_TOKEN }}
Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
From be3446eddb233ac9876bf659b61ece62fc259565 Mon Sep 17 00:00:00 2001
2+
From: Bruno Verachten <gounthar@gmail.com>
3+
Date: Tue, 28 Jul 2026 15:25:31 +0200
4+
Subject: [PATCH] ci: drop cpython-freethreading from cibuildwheel enable
5+
groups
6+
7+
Upstream-Status: Backport [https://github.com/indygreg/python-zstandard/commit/a77fea59e5c285ce957cbbe3bb5f99f84dc60dc7]
8+
9+
cibuildwheel 4.x removed the cpython-freethreading enable group, since
10+
freethreaded builds are selected by the build identifier now, and errors out
11+
at config-parse time when it is still listed. Upstream dropped it in the same
12+
commit that moved their CI from cibuildwheel 3.1.4 to 4.1.0, which landed after
13+
the 0.25.0 tag, so we carry it here until the next release.
14+
15+
Signed-off-by: Bruno Verachten <gounthar@gmail.com>
16+
---
17+
pyproject.toml | 2 +-
18+
1 file changed, 1 insertion(+), 1 deletion(-)
19+
20+
diff --git a/pyproject.toml b/pyproject.toml
21+
index d707859..ee64416 100644
22+
--- a/pyproject.toml
23+
+++ b/pyproject.toml
24+
@@ -62,7 +62,7 @@ line-length = 80
25+
select = ["E4", "E7", "E9", "F", "I"]
26+
27+
[tool.cibuildwheel]
28+
-enable = ["cpython-freethreading", "cpython-prerelease"]
29+
+enable = ["cpython-prerelease"]
30+
build-frontend = "build[uv]"
31+
32+
# Turn compiler warnings into errors.
33+
--
34+
2.47.3
35+

0 commit comments

Comments
 (0)