From 45acd179ffeeec578326cc2f3c6f82a8104dba32 Mon Sep 17 00:00:00 2001 From: Ludovic Henry Date: Tue, 8 Sep 2026 05:45:13 +0200 Subject: [PATCH 1/3] hmmlearn: add build-hmmlearn.yml for riscv64 wheels --- .github/workflows/build-hmmlearn.yml | 91 ++++++++++++++++++++++++++++ 1 file changed, 91 insertions(+) create mode 100644 .github/workflows/build-hmmlearn.yml diff --git a/.github/workflows/build-hmmlearn.yml b/.github/workflows/build-hmmlearn.yml new file mode 100644 index 00000000000..d8a8bf8acb5 --- /dev/null +++ b/.github/workflows/build-hmmlearn.yml @@ -0,0 +1,91 @@ +# SPDX-FileCopyrightText: 2026 The RISE Project +# SPDX-License-Identifier: MIT +--- +# This workflow is based on: https://github.com/hmmlearn/hmmlearn/blob/0.3.3/.github/workflows/build.yml +name: Build hmmlearn wheels (riscv64) + +on: + workflow_dispatch: + inputs: + version: + description: 'hmmlearn version to build (git tag, e.g. 0.3.3)' + required: true + default: '0.3.3' + pull_request: + paths: + - '.github/workflows/build-hmmlearn.yml' + +concurrency: + group: ${{ github.workflow }}-${{ inputs.version || '0.3.3' }}-${{ 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.3.3 there. + HMMLEARN_VERSION: ${{ inputs.version || '0.3.3' }} + MANYLINUX_RISCV64_IMAGE: quay.io/pypa/manylinux_2_39_riscv64 + +jobs: + setup: + uses: $/.github/workflows/_setup.yml + + build_wheels: + needs: [setup] + name: Build hmmlearn ${{ inputs.version || '0.3.3' }} ${{ matrix.python }}-manylinux_riscv64 + runs-on: ubuntu-24.04-riscv + timeout-minutes: 120 + strategy: + fail-fast: false + matrix: + # Per-interpreter (not abi3): the pybind11 extension links the version-specific + # ABI. cp38-cp311 dropped from upstream's cp38-cp313 (gotcha 67/84): hmmlearn's + # hard runtime dependency scikit-learn>=0.16 only has riscv64 wheels on + # pypi.riseproject.dev for cp312/cp313/cp314/cp314t, so older interpreters would + # fall back to a from-source scikit-learn build during the test-install step. + python: + - "cp312" + - "cp313" + - "cp314" + - "cp314t" + + steps: + - name: Checkout hmmlearn ${{ env.HMMLEARN_VERSION }} + uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1 + with: + repository: hmmlearn/hmmlearn + ref: ${{ env.HMMLEARN_VERSION }} + persist-credentials: false + + - 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/ + PIP_ONLY_BINARY=numpy,scipy,scikit-learn + SETUPTOOLS_SCM_PRETEND_VERSION_FOR_HMMLEARN=${{ env.HMMLEARN_VERSION }} + CIBW_TEST_REQUIRES: pytest + # Mirrors upstream's own test invocation (build.yml's CIBW_TEST_COMMAND). + CIBW_TEST_COMMAND: >- + python -I -mpytest --pyargs hmmlearn.tests {project}/doc + + - uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7.0.1 + with: + name: hmmlearn-${{ env.HMMLEARN_VERSION }}-${{ matrix.python }}-manylinux_riscv64 + path: wheelhouse/*.whl + if-no-files-found: error + + publish: + name: Publish hmmlearn ${{ inputs.version || '0.3.3' }} + needs: [setup, build_wheels] + permissions: + contents: write + pull-requests: write + uses: $/.github/workflows/_publish-wheel.yml + with: + artifact-pattern: hmmlearn-${{ inputs.version || '0.3.3' }}-*-manylinux_riscv64 From b38736f69a16c0476579545544af0792251bbd71 Mon Sep 17 00:00:00 2001 From: Ludovic Henry Date: Tue, 8 Sep 2026 06:29:46 +0200 Subject: [PATCH 2/3] hmmlearn: patch deprecated in-place ndarray.shape assignment for numpy 2.5 hmmlearn 0.3.3's own hmm.py/utils.py assign a.shape in place, which numpy 2.5 deprecates; this project's pytest config promotes that DeprecationWarning to a hard error, failing nearly every test. Reproduces with numpy>=2.5 on any architecture, not just riscv64. --- .github/workflows/build-hmmlearn.yml | 10 +++ ...ed-in-place-ndarray.shape-assignment.patch | 62 +++++++++++++++++++ 2 files changed, 72 insertions(+) create mode 100644 patches/hmmlearn/0.3.3/0001-Replace-deprecated-in-place-ndarray.shape-assignment.patch diff --git a/.github/workflows/build-hmmlearn.yml b/.github/workflows/build-hmmlearn.yml index d8a8bf8acb5..2901416cf36 100644 --- a/.github/workflows/build-hmmlearn.yml +++ b/.github/workflows/build-hmmlearn.yml @@ -14,6 +14,7 @@ on: pull_request: paths: - '.github/workflows/build-hmmlearn.yml' + - 'patches/hmmlearn/**' concurrency: group: ${{ github.workflow }}-${{ inputs.version || '0.3.3' }}-${{ github.head_ref || github.run_id }} @@ -58,6 +59,15 @@ jobs: ref: ${{ env.HMMLEARN_VERSION }} persist-credentials: false + - name: Checkout python-wheels + uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1 + with: + path: python-wheels + persist-credentials: false + + - name: Patch hmmlearn source + run: git apply python-wheels/patches/hmmlearn/${{ env.HMMLEARN_VERSION }}/*.patch + - name: Build wheels uses: pypa/cibuildwheel@1828c10ab37f080699c7b81cea34097c684a7074 # v4.2.0 with: diff --git a/patches/hmmlearn/0.3.3/0001-Replace-deprecated-in-place-ndarray.shape-assignment.patch b/patches/hmmlearn/0.3.3/0001-Replace-deprecated-in-place-ndarray.shape-assignment.patch new file mode 100644 index 00000000000..af0287fd9aa --- /dev/null +++ b/patches/hmmlearn/0.3.3/0001-Replace-deprecated-in-place-ndarray.shape-assignment.patch @@ -0,0 +1,62 @@ +From e775ca339d48d2383d849f38b4d7ff1324e5664a Mon Sep 17 00:00:00 2001 +From: Ludovic Henry +Date: Tue, 8 Sep 2026 06:20:37 +0200 +Subject: [PATCH] Replace deprecated in-place ndarray.shape assignment with + reshape + +Upstream-Status: To upstream [not yet submitted; this port workflow does not open upstream issues or PRs] + +NumPy 2.5 deprecates assigning to ndarray.shape in place (only reshapes +that need a copy are still rejected outright; a plain reshape is always +the documented replacement). normalize() and GaussianHMM/GMMHMM's single- +feature covariance init hit this on every array they reshape this way, +turning `DeprecationWarning: Setting the shape on a NumPy array has been +deprecated in NumPy 2.5.` into a hard test failure wherever +`filterwarnings = ["error::DeprecationWarning:hmmlearn", ...]` (this +project's own pytest config) applies. Reproduces with numpy>=2.5 on any +architecture, not just riscv64. + +Signed-off-by: Ludovic Henry +--- + src/hmmlearn/hmm.py | 4 ++-- + src/hmmlearn/utils.py | 2 +- + 2 files changed, 3 insertions(+), 3 deletions(-) + +diff --git a/src/hmmlearn/hmm.py b/src/hmmlearn/hmm.py +index fec0a13..59b3a64 100644 +--- a/src/hmmlearn/hmm.py ++++ b/src/hmmlearn/hmm.py +@@ -316,7 +316,7 @@ class GaussianHMM(_emissions.BaseGaussianHMM, BaseHMM): + if self._needs_init("c", "covars_"): + cv = np.cov(X.T) + self.min_covar * np.eye(X.shape[1]) + if not cv.shape: +- cv.shape = (1, 1) ++ cv = cv.reshape(1, 1) + self.covars_ = \ + _utils.distribute_covar_matrix_to_match_covariance_type( + cv, self.covariance_type, self.n_components).copy() +@@ -576,7 +576,7 @@ class GMMHMM(_emissions.BaseGMMHMM): + if cv is None: + cv = compute_cv() + if not cv.shape: +- cv.shape = (1, 1) ++ cv = cv.reshape(1, 1) + if self.covariance_type == 'tied': + self.covars_ = np.zeros((nc, nf, nf)) + self.covars_[:] = cv +diff --git a/src/hmmlearn/utils.py b/src/hmmlearn/utils.py +index a080e56..751339f 100644 +--- a/src/hmmlearn/utils.py ++++ b/src/hmmlearn/utils.py +@@ -24,7 +24,7 @@ def normalize(a, axis=None): + a_sum[a_sum == 0] = 1 + shape = list(a.shape) + shape[axis] = 1 +- a_sum.shape = shape ++ a_sum = a_sum.reshape(shape) + + a /= a_sum + +-- +2.50.1 (Apple Git-155) + From 988fd626878f31108e67530021cce7a37bb88f86 Mon Sep 17 00:00:00 2001 From: Ludovic Henry Date: Tue, 8 Sep 2026 07:30:15 +0200 Subject: [PATCH 3/3] hmmlearn: keep the GIL enabled under cp314t test runs _hmmc has no Py_mod_gil slot, so cp314t re-enables the GIL at import and warns; hmmlearn's own filterwarnings=["error", ...] turns that into a collection error. -X gil=1 rather than PYTHON_GIL=1, since -I (already in the test command) ignores PYTHON* env vars. --- .github/workflows/build-hmmlearn.yml | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/.github/workflows/build-hmmlearn.yml b/.github/workflows/build-hmmlearn.yml index 2901416cf36..e9745056fc6 100644 --- a/.github/workflows/build-hmmlearn.yml +++ b/.github/workflows/build-hmmlearn.yml @@ -80,9 +80,14 @@ jobs: PIP_ONLY_BINARY=numpy,scipy,scikit-learn SETUPTOOLS_SCM_PRETEND_VERSION_FOR_HMMLEARN=${{ env.HMMLEARN_VERSION }} CIBW_TEST_REQUIRES: pytest - # Mirrors upstream's own test invocation (build.yml's CIBW_TEST_COMMAND). + # Mirrors upstream's own test invocation (build.yml's CIBW_TEST_COMMAND), plus + # -X gil=1: _hmmc has no Py_mod_gil slot, so cp314t re-enables the GIL at + # import and warns; hmmlearn's own filterwarnings=["error", ...] turns that + # into a collection error. CIBW_TEST_ENVIRONMENT's PYTHON_GIL=1 would be the + # usual fix, but -I (already used here) ignores all PYTHON* env vars, so it + # has to be the -X flag instead; a no-op on the non-free-threaded builds. CIBW_TEST_COMMAND: >- - python -I -mpytest --pyargs hmmlearn.tests {project}/doc + python -I -X gil=1 -mpytest --pyargs hmmlearn.tests {project}/doc - uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7.0.1 with: