Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
109 changes: 109 additions & 0 deletions .github/workflows/build-mecab.yml
Original file line number Diff line number Diff line change
@@ -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 {project}/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
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
From 3c987e4e01cd9dd9a0c57fee502aea58b6e512a9 Mon Sep 17 00:00:00 2001
From: Ludovic Henry <git@ludovic.dev>
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)