From 7f9d5e4b4cd7bb32c9ad43cd63ad45dacfa32fe6 Mon Sep 17 00:00:00 2001 From: Ludovic Henry Date: Mon, 7 Sep 2026 17:13:23 +0200 Subject: [PATCH 1/4] mecab: add build-mecab.yml for riscv64 wheels --- .github/workflows/build-mecab.yml | 109 ++++++++++++++++++ ...etuptools-default-license_files-glob.patch | 63 ++++++++++ 2 files changed, 172 insertions(+) create mode 100644 .github/workflows/build-mecab.yml create mode 100644 patches/mecab/0.996.13/0001-Add-LICENSE-matching-setuptools-default-license_files-glob.patch diff --git a/.github/workflows/build-mecab.yml b/.github/workflows/build-mecab.yml new file mode 100644 index 000000000..dc4bfc15d --- /dev/null +++ b/.github/workflows/build-mecab.yml @@ -0,0 +1,109 @@ +# SPDX-FileCopyrightText: 2026 The RISE Project +# SPDX-License-Identifier: MIT +--- +# This workflow is based on: https://github.com/shogo82148/mecab/blob/v0.996.13/.github/workflows/test-linux-python.yml +name: Build mecab wheels (riscv64) + +on: + workflow_dispatch: + inputs: + version: + description: 'mecab version to build (git tag without leading v, e.g. 0.996.13)' + required: true + default: '0.996.13' + pull_request: + paths: + - '.github/workflows/build-mecab.yml' + - 'patches/mecab/**' + +concurrency: + group: ${{ github.workflow }}-${{ inputs.version || '0.996.13' }}-${{ 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.996.13 there. + MECAB_VERSION: ${{ inputs.version || '0.996.13' }} + MANYLINUX_RISCV64_IMAGE: quay.io/pypa/manylinux_2_39_riscv64 + +jobs: + setup: + uses: $/.github/workflows/_setup.yml + + build_wheels: + needs: [setup] + name: Build mecab ${{ inputs.version || '0.996.13' }} ${{ matrix.python }}-manylinux_riscv64 + runs-on: ubuntu-24.04-riscv + timeout-minutes: 60 + strategy: + fail-fast: false + matrix: + # Upstream builds no cp314t Linux wheel yet; the extension declares no + # free-threading support either way, so cp314t just re-enables the GIL + # on import (CLAUDE.md gotcha 127) rather than failing. + python: ["cp312", "cp313", "cp314", "cp314t"] + + steps: + - name: Checkout mecab ${{ env.MECAB_VERSION }} + uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1 + with: + repository: shogo82148/mecab + ref: v${{ env.MECAB_VERSION }} + persist-credentials: false + + - name: Checkout python-wheels + uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1 + with: + path: python-wheels + persist-credentials: false + + - name: Patch mecab source + run: git apply python-wheels/patches/mecab/${{ env.MECAB_VERSION }}/*.patch + + - uses: pypa/cibuildwheel@1828c10ab37f080699c7b81cea34097c684a7074 # v4.2.0 + with: + package-dir: mecab/python + env: + CIBW_ARCHS: riscv64 + CIBW_BUILD: ${{ matrix.python }}-manylinux_riscv64 + CIBW_MANYLINUX_RISCV64_IMAGE: ${{ env.MANYLINUX_RISCV64_IMAGE }} + # setup.py always links a system libmecab via mecab-config; this repo + # is the MeCab C++ core and the Python binding in one monorepo, so + # build the core (mecab/mecab) from the same checkout/tag the binding + # comes from. configure.ac has no committed configure script (needs + # autogen.sh/autoreconf) and its AM_ICONV macro needs gettext's m4 + # files, absent from the manylinux image. + CIBW_BEFORE_ALL_LINUX: | + set -eux + dnf install -y gettext-devel + cd mecab/mecab + ./autogen.sh + ./configure --enable-utf8-only + make -j"$(nproc)" + make install + ldconfig + CIBW_ENVIRONMENT: PIP_EXTRA_INDEX_URL=https://pypi.riseproject.dev/simple/ + # Mirrors the sibling mecab-python3 port: install unidic-lite (a small + # pure-Python dictionary package) so the test exercises real + # tokenization instead of failing on "no dictionaries found". + CIBW_TEST_REQUIRES: unidic-lite + CIBW_TEST_COMMAND: >- + python -c "import MeCab, unidic_lite; t = MeCab.Tagger('-d ' + unidic_lite.DICDIR); r = t.parse('太郎はこの本を女性に渡した。'); assert 'EOS' in r and '太郎' in r, r; print(r)" + + - uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7.0.1 + with: + name: mecab-${{ env.MECAB_VERSION }}-${{ matrix.python }}-manylinux_riscv64 + path: ./wheelhouse/*.whl + if-no-files-found: error + + publish: + name: Publish mecab ${{ inputs.version || '0.996.13' }} + needs: [setup, build_wheels] + permissions: + contents: write + pull-requests: write + uses: $/.github/workflows/_publish-wheel.yml + with: + artifact-pattern: mecab-${{ inputs.version || '0.996.13' }}-*-manylinux_riscv64 diff --git a/patches/mecab/0.996.13/0001-Add-LICENSE-matching-setuptools-default-license_files-glob.patch b/patches/mecab/0.996.13/0001-Add-LICENSE-matching-setuptools-default-license_files-glob.patch new file mode 100644 index 000000000..ee5e5142c --- /dev/null +++ b/patches/mecab/0.996.13/0001-Add-LICENSE-matching-setuptools-default-license_files-glob.patch @@ -0,0 +1,63 @@ +From 3c987e4e01cd9dd9a0c57fee502aea58b6e512a9 Mon Sep 17 00:00:00 2001 +From: Ludovic Henry +Date: Mon, 7 Sep 2026 17:11:24 +0200 +Subject: [PATCH] Add LICENSE matching setuptools' default license_files glob + +setuptools only auto-discovers license files at the package root that +match LICEN[CS]E*/COPYING*/NOTICE*/AUTHORS*. The mecab/python binding +declares itself under "GPL-2.0-only OR LGPL-2.1-only OR BSD-3-Clause" +but ships no license text of its own -- release.yml's script-dist step +copies the parent mecab/ tree's COPYING, BSD, GPL, LGPL and AUTHORS +files alongside python/* before building the sdist, yet only COPYING* +and AUTHORS* match setuptools' glob, so BSD/GPL/LGPL never reach the +wheel's dist-info/licenses/ -- and building straight from this git +checkout skips that script-dist copy entirely. + +Add a LICENSE file duplicating the BSD text (the license this package +declares itself under) so it is picked up by the default glob with no +setup.py/pyproject.toml change, mirroring how the sibling mecab-python3 +port resolves the same gap. + +Upstream-Status: To upstream [blocked: this port may only touch riseproject-dev/python-wheels] +--- + mecab/python/LICENSE | 29 +++++++++++++++++++++++++++++ + 1 file changed, 29 insertions(+) + create mode 100644 mecab/python/LICENSE + +diff --git a/mecab/python/LICENSE b/mecab/python/LICENSE +new file mode 100644 +index 0000000..9ae6ded +--- /dev/null ++++ b/mecab/python/LICENSE +@@ -0,0 +1,29 @@ ++Copyright (c) 2001-2008, Taku Kudo ++Copyright (c) 2004-2008, Nippon Telegraph and Telephone Corporation ++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 Nippon Telegraph and Telegraph Corporation ++ 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) From f6c4c02de83dd52692a88374ccf83f808216c966 Mon Sep 17 00:00:00 2001 From: Ludovic Henry Date: Mon, 7 Sep 2026 17:20:28 +0200 Subject: [PATCH 2/4] build-mecab.yml: fix libmecab before-all cwd (before_all runs outside {project}) --- .github/workflows/build-mecab.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/build-mecab.yml b/.github/workflows/build-mecab.yml index dc4bfc15d..1b402959d 100644 --- a/.github/workflows/build-mecab.yml +++ b/.github/workflows/build-mecab.yml @@ -78,7 +78,7 @@ jobs: CIBW_BEFORE_ALL_LINUX: | set -eux dnf install -y gettext-devel - cd mecab/mecab + cd {project}/mecab/mecab ./autogen.sh ./configure --enable-utf8-only make -j"$(nproc)" From 7bba13a79a95db6c6f058c957b9fb3b396b67e44 Mon Sep 17 00:00:00 2001 From: Ludovic Henry Date: Mon, 7 Sep 2026 17:29:08 +0200 Subject: [PATCH 3/4] build-mecab.yml: add diagnostic listing of {project} to debug missing mecab/mecab --- .github/workflows/build-mecab.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/build-mecab.yml b/.github/workflows/build-mecab.yml index 1b402959d..3af82b0ed 100644 --- a/.github/workflows/build-mecab.yml +++ b/.github/workflows/build-mecab.yml @@ -77,6 +77,7 @@ jobs: # files, absent from the manylinux image. CIBW_BEFORE_ALL_LINUX: | set -eux + find {project} -maxdepth 2 dnf install -y gettext-devel cd {project}/mecab/mecab ./autogen.sh From f7bf232ed58eae296b7925eb4681bfd629925655 Mon Sep 17 00:00:00 2001 From: Ludovic Henry Date: Mon, 7 Sep 2026 17:35:05 +0200 Subject: [PATCH 4/4] build-mecab.yml: fix libmecab path -- checkout root already is mecab/, not mecab/mecab --- .github/workflows/build-mecab.yml | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/.github/workflows/build-mecab.yml b/.github/workflows/build-mecab.yml index 3af82b0ed..ce5a1ef4a 100644 --- a/.github/workflows/build-mecab.yml +++ b/.github/workflows/build-mecab.yml @@ -77,9 +77,8 @@ jobs: # files, absent from the manylinux image. CIBW_BEFORE_ALL_LINUX: | set -eux - find {project} -maxdepth 2 dnf install -y gettext-devel - cd {project}/mecab/mecab + cd {project}/mecab ./autogen.sh ./configure --enable-utf8-only make -j"$(nproc)"