From b013042b3cf1842ed41e8ac88f0aff99d59e0aa8 Mon Sep 17 00:00:00 2001 From: Ludovic Henry Date: Thu, 10 Sep 2026 09:03:42 +0200 Subject: [PATCH] libvalkey: add build-libvalkey.yml for riscv64 wheels Builds the libvalkey Python bindings (a hiredis-style C extension over the vendored libvalkey C client, checked out as a submodule) for riscv64, mirroring hiredis's own build-from-checkout shape since libvalkey-py has the same setup.py + vendored-submodule layout and no pyproject.toml. Carries a licensing patch, following the precedent set for hiredis: setuptools' default LICEN[CS]E* glob only picks up files at the project root, so the vendored libvalkey C library's BSD-3-Clause COPYING notice (required by its redistribution clause) is missing from the wheel unless copied there as LICENSE.libvalkey. --- .github/workflows/build-libvalkey.yml | 99 +++++++++++++++++++ ...d-libvalkey-licence-next-to-the-pack.patch | 88 +++++++++++++++++ 2 files changed, 187 insertions(+) create mode 100644 .github/workflows/build-libvalkey.yml create mode 100644 patches/libvalkey/4.1.0/0001-add-the-vendored-libvalkey-licence-next-to-the-pack.patch diff --git a/.github/workflows/build-libvalkey.yml b/.github/workflows/build-libvalkey.yml new file mode 100644 index 000000000..b7ecec4ad --- /dev/null +++ b/.github/workflows/build-libvalkey.yml @@ -0,0 +1,99 @@ +# SPDX-FileCopyrightText: 2026 The RISE Project +# SPDX-License-Identifier: MIT +--- +# This workflow is based on: https://github.com/valkey-io/libvalkey-py/blob/v4.1.0/.github/workflows/pypi-publish.yaml +name: Build libvalkey wheels (riscv64) + +on: + workflow_dispatch: + inputs: + version: + description: 'libvalkey version to build (git tag without the leading v, e.g. 4.1.0)' + required: true + default: '4.1.0' + pull_request: + paths: + - '.github/workflows/build-libvalkey.yml' + - 'patches/libvalkey/**' + +concurrency: + group: ${{ github.workflow }}-${{ inputs.version || '4.1.0' }}-${{ 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 4.1.0 there. + LIBVALKEY_VERSION: ${{ inputs.version || '4.1.0' }} + MANYLINUX_RISCV64_IMAGE: quay.io/pypa/manylinux_2_39_riscv64 + +jobs: + setup: + uses: $/.github/workflows/_setup.yml + + build_wheels: + needs: [setup] + name: Build libvalkey ${{ inputs.version || '4.1.0' }} ${{ matrix.python }}-manylinux_riscv64 + runs-on: ubuntu-24.04-riscv + strategy: + fail-fast: false + matrix: + python: ["cp312", "cp313", "cp314", "cp314t"] + + steps: + - name: Checkout libvalkey v${{ env.LIBVALKEY_VERSION }} + uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1 + with: + repository: valkey-io/libvalkey-py + ref: v${{ env.LIBVALKEY_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 libvalkey source + run: git apply python-wheels/patches/libvalkey/${{ env.LIBVALKEY_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 + CIBW_TEST_SOURCES: tests + CIBW_TEST_COMMAND: >- + python -c "import importlib.metadata as m; f = sorted(p.name for p in m.files('libvalkey') if '.dist-info/licenses/' in str(p)); assert f == ['LICENSE', 'LICENSE.libvalkey'], f" + && python -m pytest tests + + - name: Check the extension made it into the wheel + run: | + python3 - wheelhouse/*.whl <<'EOF' + import sys, zipfile + for whl in sys.argv[1:]: + names = zipfile.ZipFile(whl).namelist() + assert any(n.startswith("libvalkey/libvalkey.") and n.endswith(".so") for n in names), whl + print(whl, "ok") + EOF + + - uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7.0.1 + with: + name: libvalkey-${{ env.LIBVALKEY_VERSION }}-${{ matrix.python }}-manylinux_riscv64 + path: wheelhouse/*.whl + if-no-files-found: error + + publish: + name: Publish libvalkey ${{ inputs.version || '4.1.0' }} + needs: [setup, build_wheels] + permissions: + contents: write + pull-requests: write + uses: $/.github/workflows/_publish-wheel.yml + with: + artifact-pattern: libvalkey-${{ inputs.version || '4.1.0' }}-*-manylinux_riscv64 diff --git a/patches/libvalkey/4.1.0/0001-add-the-vendored-libvalkey-licence-next-to-the-pack.patch b/patches/libvalkey/4.1.0/0001-add-the-vendored-libvalkey-licence-next-to-the-pack.patch new file mode 100644 index 000000000..2054fe9e2 --- /dev/null +++ b/patches/libvalkey/4.1.0/0001-add-the-vendored-libvalkey-licence-next-to-the-pack.patch @@ -0,0 +1,88 @@ +From 14f8fbeac819977c38fa863f36071e2a2bbdb6e6 Mon Sep 17 00:00:00 2001 +From: Ludovic Henry +Date: Thu, 10 Sep 2026 09:01:59 +0200 +Subject: [PATCH] add the vendored libvalkey licence next to the package's own + +Upstream-Status: To upstream [not yet submitted; the same gap exists in every libvalkey wheel on PyPI, so this needs a maintainer discussion rather than a drive-by PR] + +setup.py compiles vendor/libvalkey (BSD 3-clause, itself derived from +hiredis) straight into the libvalkey.libvalkey extension, and that +licence requires the copyright notice to be reproduced with binary +redistributions. The wheel ships only the package's own MIT LICENSE: +setuptools globs license files from the project root, and +vendor/libvalkey/COPYING is not there (MANIFEST.in's 'include +vendor/libvalkey/COPYING' only affects the sdist, not the wheel's +dist-info/licenses/). + +Add the vendored notice at the root as LICENSE.libvalkey, which the +default LICEN[CS]E* glob picks up, so it lands in dist-info/licenses/ +beside LICENSE with no packaging change. + +Signed-off-by: Ludovic Henry +--- + LICENSE.libvalkey | 53 +++++++++++++++++++++++++++++++++++++++++++++++ + 1 file changed, 53 insertions(+) + create mode 100644 LICENSE.libvalkey + +diff --git a/LICENSE.libvalkey b/LICENSE.libvalkey +new file mode 100644 +index 0000000..7c19dd6 +--- /dev/null ++++ b/LICENSE.libvalkey +@@ -0,0 +1,53 @@ ++# License 1 ++ ++BSD 3-Clause License ++ ++Copyright (c) 2024-present, libvalkey contributors ++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 of the copyright holder 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 OWNER 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. ++ ++# License 2 ++ ++BSD 3-Clause License ++ ++Copyright (c) 2009-2011, Salvatore Sanfilippo ++Copyright (c) 2010-2011, Pieter Noordhuis ++Copyright (c) 2015-2017, Ieshen Zheng ++Copyright (c) 2020, Nick ++Copyright (c) 2020-2022, Bjorn Svensson ++Copyright (c) 2020-2022, Viktor Söderqvist ++Copyright (c) 2021, Red Hat ++ ++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 of Redis 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 OWNER 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. +-- +2.50.1 (Apple Git-155) +