From 77344590ae0ce0e4a0982af46f048e4e3d76a2d6 Mon Sep 17 00:00:00 2001 From: Ludovic Henry Date: Fri, 25 Sep 2026 12:45:45 +0000 Subject: [PATCH] pocketsphinx: Add version 5.1.1 Build pocketsphinx from the upstream v5.1.1 checkout with cibuildwheel on the riscv64 manylinux image, running upstream's pytest suite against each wheel. The wheel also carries the MT19937, dtoa and yin notices, which are compiled in but missing from upstream's LICENSE. --- .github/workflows/build-pocketsphinx.yml | 126 +++++++++++++++++++++++ docs/packages/pocketsphinx.yaml | 5 + 2 files changed, 131 insertions(+) create mode 100644 .github/workflows/build-pocketsphinx.yml create mode 100644 docs/packages/pocketsphinx.yaml diff --git a/.github/workflows/build-pocketsphinx.yml b/.github/workflows/build-pocketsphinx.yml new file mode 100644 index 00000000000..e336803c5b1 --- /dev/null +++ b/.github/workflows/build-pocketsphinx.yml @@ -0,0 +1,126 @@ +# SPDX-FileCopyrightText: 2026 The RISE Project +# SPDX-License-Identifier: MIT +--- +# This workflow is based on the `build_wheels` job of +# https://github.com/cmusphinx/pocketsphinx/blob/v5.1.1/.github/workflows/release.yml +# and the `python-tests` job of +# https://github.com/cmusphinx/pocketsphinx/blob/v5.1.1/.github/workflows/tests.yml +name: Build pocketsphinx wheels (riscv64) + +on: + workflow_dispatch: + inputs: + version: + description: 'Version glob to (re)build; empty builds every version of docs/packages/pocketsphinx.yaml not released yet' + required: false + default: '' + pull_request: + branches: [main] + paths: + - '.github/workflows/build-pocketsphinx.yml' + - 'docs/packages/pocketsphinx.yaml' + push: + branches: [main] + paths: + - '.github/workflows/build-pocketsphinx.yml' + - 'docs/packages/pocketsphinx.yaml' + +concurrency: + group: ${{ github.workflow }}-${{ github.head_ref || github.run_id }} + cancel-in-progress: true + +permissions: + contents: read # to fetch code (actions/checkout) + +env: + MANYLINUX_RISCV64_IMAGE: quay.io/pypa/manylinux_2_39_riscv64 + +jobs: + setup: + uses: $/.github/workflows/_setup.yml + with: + package: pocketsphinx + version: ${{ inputs.version }} + + build_wheels: + needs: [setup] + if: needs.setup.outputs.versions != '[]' + name: Build pocketsphinx ${{ matrix.version }} ${{ matrix.python }}-manylinux_riscv64 + runs-on: ubuntu-24.04-riscv + timeout-minutes: 180 + strategy: + fail-fast: false + matrix: + version: ${{ fromJSON(needs.setup.outputs.versions) }} + python: ["cp312", "cp313", "cp314"] + + env: + POCKETSPHINX_VERSION: ${{ matrix.version }} + + steps: + - name: Checkout pocketsphinx v${{ env.POCKETSPHINX_VERSION }} + uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1 + with: + repository: cmusphinx/pocketsphinx + ref: v${{ env.POCKETSPHINX_VERSION }} + persist-credentials: false + + # MT19937, dtoa and yin are compiled in, but upstream's LICENSE omits their notices. + - name: Stage the vendored sources' licences + run: | + set -euo pipefail + sed -n '/Copyright (C) 1997 - 2002, Makoto Matsumoto/,/SUCH DAMAGE\./{s/^ //;p}' src/util/genrand.c > LICENSE.mt19937 + sed -n '/The author of this software is David M. Gay/,/PARTICULAR PURPOSE\./{s/^ \* \{0,1\}//;p}' src/util/dtoa.c > LICENSE.dtoa + sed -n '/Copyright (c) 2008 Beyond Access/,/SUCH DAMAGE\./{s/^ \* \{0,1\}//;p}' src/fe/yin.c > LICENSE.yin + for f in LICENSE.mt19937 LICENSE.dtoa LICENSE.yin; do + test "$(wc -l < "$f")" -gt 10 + done + head -n 3 LICENSE.mt19937 LICENSE.dtoa LICENSE.yin + + - 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_ENVIRONMENT: PIP_EXTRA_INDEX_URL=https://pypi.riseproject.dev/simple/ + CIBW_TEST_REQUIRES: pytest memory_profiler + CIBW_TEST_COMMAND: pytest {project} + + - name: Check wheel contents + run: | + python3 - wheelhouse/*.whl <<'EOF' + import sys, zipfile + names = zipfile.ZipFile(sys.argv[1]).namelist() + exts = [n for n in names if n.endswith(".so")] + assert len(exts) == 1 and exts[0].startswith("pocketsphinx/_pocketsphinx.cpython-"), exts + assert exts[0].endswith("-riscv64-linux-gnu.so"), exts + assert "pocketsphinx/model/en-us/en-us.lm.bin" in names, names + licences = {n.split(".dist-info/licenses/", 1)[1] for n in names + if ".dist-info/licenses/" in n and not n.endswith("/")} + assert {"LICENSE", "LICENSE.dtoa", "LICENSE.mt19937", "LICENSE.yin"} <= licences, licences + EOF + + - uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7.0.1 + with: + name: pocketsphinx-${{ env.POCKETSPHINX_VERSION }}-${{ matrix.python }}-manylinux_riscv64 + path: wheelhouse/*.whl + if-no-files-found: error + + publish: + name: Publish pocketsphinx ${{ matrix.version }} + needs: [setup, build_wheels] + if: needs.setup.outputs.versions != '[]' + strategy: + fail-fast: false + matrix: + version: ${{ fromJSON(needs.setup.outputs.versions) }} + permissions: + contents: write + pull-requests: write + uses: $/.github/workflows/_publish-wheel.yml + secrets: + app-private-key: ${{ secrets.RISEPROJECT_APP_PRIVATE_KEY }} + with: + artifact-pattern: pocketsphinx-${{ matrix.version }}-*-manylinux_riscv64 diff --git a/docs/packages/pocketsphinx.yaml b/docs/packages/pocketsphinx.yaml new file mode 100644 index 00000000000..b7678b3791c --- /dev/null +++ b/docs/packages/pocketsphinx.yaml @@ -0,0 +1,5 @@ +package-name: pocketsphinx +source-code: https://github.com/cmusphinx/pocketsphinx +license: BSD-2-Clause AND BSD-3-Clause AND MIT +versions: +- version: 5.1.1