diff --git a/.github/workflows/build-pynng.yml b/.github/workflows/build-pynng.yml new file mode 100644 index 000000000..80131196d --- /dev/null +++ b/.github/workflows/build-pynng.yml @@ -0,0 +1,104 @@ +# SPDX-FileCopyrightText: 2026 The RISE Project +# SPDX-License-Identifier: MIT +--- +# Based on upstream's own wheel build: +# https://github.com/codypiersall/pynng/blob/v0.9.0/.github/workflows/cibuildwheel.yml +name: Build pynng wheels (riscv64) + +on: + workflow_dispatch: + inputs: + version: + description: 'pynng version to build (git tag without leading v, e.g. 0.9.0)' + required: true + default: '0.9.0' + pull_request: + paths: + - '.github/workflows/build-pynng.yml' + +concurrency: + group: ${{ github.workflow }}-${{ inputs.version || '0.9.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 0.9.0 there. + PYNNG_VERSION: ${{ inputs.version || '0.9.0' }} + # setup.cfg's own [build_nng]/[build_mbedtls] pins; keep in lockstep with it. + NNG_VERSION: v1.11 + MBEDTLS_VERSION: v3.6.3.1 + MANYLINUX_RISCV64_IMAGE: quay.io/pypa/manylinux_2_39_riscv64 + +jobs: + setup: + uses: $/.github/workflows/_setup.yml + + build_wheels: + needs: [setup] + name: Build pynng ${{ inputs.version || '0.9.0' }} ${{ matrix.python }}-manylinux_riscv64 + runs-on: ubuntu-24.04-riscv + timeout-minutes: 90 + strategy: + fail-fast: false + matrix: + python: ["cp312", "cp313", "cp314", "cp314t"] + + steps: + - name: Checkout pynng v${{ env.PYNNG_VERSION }} + uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1 + with: + repository: codypiersall/pynng + ref: v${{ env.PYNNG_VERSION }} + submodules: recursive + fetch-depth: 0 + persist-credentials: false + + - name: Checkout python-wheels + uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1 + with: + path: python-wheels + persist-credentials: false + + # setup.py's build_nng/build_mbedtls commands `git clone` the nng and + # mbedtls C libraries at build time (not submodules); their licences never + # land in the checkout, so fetch them straight from the pinned tags above. + - name: Stage the nng and mbedtls licences + run: | + curl -fsSL -o LICENSE.nng https://raw.githubusercontent.com/nanomsg/nng/${{ env.NNG_VERSION }}/LICENSE.txt + curl -fsSL -o LICENSE.mbedtls https://raw.githubusercontent.com/ARMmbed/mbedtls/${{ env.MBEDTLS_VERSION }}/LICENSE + + - name: Patch pynng source + run: | + git apply python-wheels/patches/pynng/${{ env.PYNNG_VERSION }}/00*.patch + + - uses: pypa/cibuildwheel@1828c10ab37f080699c7b81cea34097c684a7074 # v4.2.0 + env: + CIBW_ARCHS: riscv64 + # cffi has no manylinux musllinux_riscv64 wheel on our registry, so + # musllinux is dropped here too (accepted per the porting playbook). + CIBW_BUILD: ${{ matrix.python }}-manylinux_riscv64 + CIBW_MANYLINUX_RISCV64_IMAGE: ${{ env.MANYLINUX_RISCV64_IMAGE }} + # cffi, needed to build and to import the extension, has no riscv64 wheel on PyPI. + CIBW_ENVIRONMENT: PIP_EXTRA_INDEX_URL=https://pypi.riseproject.dev/simple/ + CIBW_TEST_REQUIRES: pytest pytest-asyncio pytest-trio trio + CIBW_TEST_COMMAND: >- + python -c "import importlib.metadata as m; l = sorted(str(p).rsplit('/', 1)[-1] for p in m.files('pynng') if str(p).rsplit('/', 1)[-1].startswith('LICENSE')); assert l == ['LICENSE.mbedtls', 'LICENSE.nng', 'LICENSE.txt'], l" + && pytest {project}/test + + - uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7.0.1 + with: + name: pynng-${{ env.PYNNG_VERSION }}-${{ matrix.python }}-manylinux_riscv64 + path: ./wheelhouse/*.whl + if-no-files-found: error + + publish: + name: Publish pynng ${{ inputs.version || '0.9.0' }} + needs: [setup, build_wheels] + permissions: + contents: write + pull-requests: write + uses: $/.github/workflows/_publish-wheel.yml + with: + artifact-pattern: pynng-${{ inputs.version || '0.9.0' }}-*-manylinux_riscv64 diff --git a/patches/pynng/0.9.0/0001-package-the-vendored-nng-and-mbedtls-licences-with-the-wheel.patch b/patches/pynng/0.9.0/0001-package-the-vendored-nng-and-mbedtls-licences-with-the-wheel.patch new file mode 100644 index 000000000..fb19590a1 --- /dev/null +++ b/patches/pynng/0.9.0/0001-package-the-vendored-nng-and-mbedtls-licences-with-the-wheel.patch @@ -0,0 +1,37 @@ +From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 +From: Ludovic Henry +Date: Mon, 7 Sep 2026 22:29:27 +0200 +Subject: [PATCH] package the vendored nng and mbedtls licences with the wheel + +Upstream-Status: To upstream [not yet submitted; the same gap exists in every pynng wheel on PyPI, so it needs a maintainer discussion rather than a drive-by PR] + +setup.py's build_nng/build_mbedtls commands clone and statically link the +nng (MIT) and mbedtls (Apache-2.0 OR GPL-2.0-or-later) C libraries into the +_nng extension at build time, but neither library's own repository is a +submodule or otherwise present in the sdist/checkout, and pyproject.toml +names only pynng's own LICENSE.txt. So every published pynng wheel +redistributes nng and mbedtls in binary form without their licence text. + +Add license-files under [tool.setuptools] naming LICENSE.nng and +LICENSE.mbedtls alongside LICENSE.txt; the build now stages those two +files (fetched from the pinned nng/mbedtls revisions in setup.cfg) before +invoking setuptools, so they land in the wheel's licence metadata. +--- + pyproject.toml | 4 ++++ + 1 file changed, 4 insertions(+) + +diff --git a/pyproject.toml b/pyproject.toml +index ba23ab7..56e4819 100644 +--- a/pyproject.toml ++++ b/pyproject.toml +@@ -62,6 +62,10 @@ Documentation = "https://pynng.readthedocs.io/en/latest/" + + [tool.setuptools_scm] + version_file = "pynng/_version.py" ++ ++[tool.setuptools] ++license-files = ["LICENSE.txt", "LICENSE.nng", "LICENSE.mbedtls"] ++ + [tool.setuptools.packages.find] + include = ["pynng"] +