Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
94 changes: 94 additions & 0 deletions .github/workflows/build-zstd.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,94 @@
# SPDX-FileCopyrightText: 2026 The RISE Project
# SPDX-License-Identifier: MIT
---
# Based on upstream's own wheel builders (e.g.
# https://github.com/sergey-dryabzhinsky/python-zstd/blob/v1.5.7.2/.github/workflows/Build_wheels_for_cpython313_x86_64_u24.yml),
# which cross-build under debootstrap chroots per interpreter; narrowed here to
# cibuildwheel's default (bundled libzstd, no --external/--legacy/--libzstd-use-asm).
name: Build zstd wheels (riscv64)

on:
workflow_dispatch:
inputs:
version:
description: 'zstd version to build (git tag without leading v, e.g. 1.5.7.2)'
required: true
default: '1.5.7.2'
pull_request:
paths:
- '.github/workflows/build-zstd.yml'
- 'patches/zstd/**'

concurrency:
group: ${{ github.workflow }}-${{ inputs.version || '1.5.7.2' }}-${{ github.head_ref || github.run_id }}
cancel-in-progress: true

permissions:
contents: read # to fetch code (actions/checkout)

env:
# `inputs.version` is empty on pull_request events; default to 1.5.7.2 there.
ZSTD_VERSION: ${{ inputs.version || '1.5.7.2' }}
MANYLINUX_RISCV64_IMAGE: quay.io/pypa/manylinux_2_39_riscv64

jobs:
setup:
uses: $/.github/workflows/_setup.yml

build_wheels:
needs: [setup]
name: Build zstd ${{ inputs.version || '1.5.7.2' }} ${{ matrix.python }}-manylinux_riscv64
runs-on: ubuntu-24.04-riscv
timeout-minutes: 120
strategy:
fail-fast: false
matrix:
python: ["cp312", "cp313", "cp314", "cp314t"]

steps:
- name: Checkout zstd v${{ env.ZSTD_VERSION }}
uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
with:
repository: sergey-dryabzhinsky/python-zstd
ref: v${{ env.ZSTD_VERSION }}
submodules: recursive
persist-credentials: false

- name: Checkout python-wheels
uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
with:
path: python-wheels
persist-credentials: false

- name: Patch zstd source
run: git apply python-wheels/patches/zstd/${{ env.ZSTD_VERSION }}/*.patch

- name: Build wheels
uses: pypa/cibuildwheel@1828c10ab37f080699c7b81cea34097c684a7074 # v4.2.0
with:
output-dir: wheelhouse/
only: ${{ matrix.python }}-manylinux_riscv64
env:
CIBW_MANYLINUX_RISCV64_IMAGE: ${{ env.MANYLINUX_RISCV64_IMAGE }}
CIBW_TEST_REQUIRES: pytest
# Upstream's own suite (setup.py test); test_speed.py is a set of
# 30-second throughput benchmarks with no assertions.
CIBW_TEST_COMMAND: >-
python -c "import importlib.metadata as m; l = sorted(str(p).rsplit('/', 1)[-1] for p in m.files('zstd') if 'LICENSE' in str(p)); assert l == ['LICENSE', 'LICENSE.zstd'], l"
&& python -m pytest -q {package}/tests --ignore={package}/tests/test_speed.py

- uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7.0.1
with:
name: zstd-${{ env.ZSTD_VERSION }}-${{ matrix.python }}-manylinux_riscv64
path: wheelhouse/*.whl
if-no-files-found: error

publish:
name: Publish zstd ${{ inputs.version || '1.5.7.2' }}
needs: [setup, build_wheels]
permissions:
contents: write
pull-requests: write
uses: $/.github/workflows/_publish-wheel.yml
with:
artifact-pattern: zstd-${{ inputs.version || '1.5.7.2' }}-*-manylinux_riscv64
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: Ludovic Henry <git@ludovic.dev>
Date: Thu, 3 Sep 2026 23:26:10 +0200
Subject: [PATCH] package the vendored Zstandard licence with the wheels

Upstream-Status: To upstream [not yet submitted; the same gap exists in every zstd wheel on PyPI, so it needs a maintainer discussion rather than a drive-by PR]

MANIFEST.in only grafts src/, zstd/lib/{common,compress,decompress,legacy}
and tests/, so every release sdist and every wheel on PyPI carries the
wrapper's own LICENSE but not the one for the bundled zstd C sources it
compiles into the extension.

setup.py's default build links the zstd/ submodule's lib/common,
lib/compress and lib/decompress sources straight into the zstd
extension (--external/ZSTD_EXTERNAL is required to use a system
libzstd instead), but neither the git submodule's own LICENSE nor a
copy of it ships in the sdist, so the resulting wheel redistributes
Zstandard in binary form without the copyright notice its BSD licence
requires to travel with it.

Add zstd 1.5.7's own LICENSE at the project root; setuptools' default
license_files glob picks it up with no setup.py change.
---
LICENSE.zstd | 30 ++++++++++++++++++++++++++++++
1 file changed, 30 insertions(+)
create mode 100644 LICENSE.zstd

diff --git a/LICENSE.zstd b/LICENSE.zstd
new file mode 100644
index 0000000..7580028
--- /dev/null
+++ b/LICENSE.zstd
@@ -0,0 +1,30 @@
+BSD License
+
+For Zstandard software
+
+Copyright (c) Meta Platforms, Inc. and affiliates. All rights reserved.
+
+Redistribution and use in source and binary forms, with or without modification,
+are permitted provided that the following conditions are met:
+
+ * Redistributions of source code must retain the above copyright notice, this
+ list of conditions and the following disclaimer.
+
+ * Redistributions in binary form must reproduce the above copyright notice,
+ this list of conditions and the following disclaimer in the documentation
+ and/or other materials provided with the distribution.
+
+ * Neither the name Facebook, nor Meta, nor the names of its contributors may
+ be used to endorse or promote products derived from this software without
+ specific prior written permission.
+
+THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
+ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR
+ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
+ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.