From 7ddcee076ce44e16076bda187903325c403fb1e1 Mon Sep 17 00:00:00 2001 From: pengzhendong <275331498@qq.com> Date: Tue, 9 Jun 2026 17:37:02 +0800 Subject: [PATCH 1/9] fix: relax pynini version constraint to >=2.1.6 (#317) Remove upper bound on pynini version to allow installation with pynini 2.1.7+, which is easier to install on macOS. --- pyproject.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pyproject.toml b/pyproject.toml index 0e2929b..246add5 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -19,7 +19,7 @@ classifiers = [ dynamic = ["version"] dependencies = [ # Core dependencies for text processing functionality - "pynini>=2.1.6,<2.1.7", + "pynini>=2.1.6", "importlib_resources" ] From 39c62b64f13292778eb9aeeefa301f1aae6bd746 Mon Sep 17 00:00:00 2001 From: pengzhendong <275331498@qq.com> Date: Tue, 9 Jun 2026 17:37:51 +0800 Subject: [PATCH 2/9] ci: add macOS and Windows to test matrix --- .github/workflows/unittest.yml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.github/workflows/unittest.yml b/.github/workflows/unittest.yml index 48d216d..aada63f 100644 --- a/.github/workflows/unittest.yml +++ b/.github/workflows/unittest.yml @@ -9,9 +9,10 @@ on: jobs: unit-test: - runs-on: ubuntu-latest + runs-on: ${{ matrix.os }} strategy: matrix: + os: [ubuntu-latest, macos-latest, windows-latest] python-version: [3.9] steps: - uses: actions/checkout@v4 From 4e2349f4a922835a6f12f2750c70847b25e5cbab Mon Sep 17 00:00:00 2001 From: pengzhendong <275331498@qq.com> Date: Tue, 9 Jun 2026 17:38:50 +0800 Subject: [PATCH 3/9] ci: trigger on toml and yml changes --- .github/workflows/unittest.yml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.github/workflows/unittest.yml b/.github/workflows/unittest.yml index aada63f..01e8313 100644 --- a/.github/workflows/unittest.yml +++ b/.github/workflows/unittest.yml @@ -6,6 +6,8 @@ on: paths: - '**.py' - '**.tsv' + - '**.toml' + - '**.yml' jobs: unit-test: From c08d37bdd0906f61ae8dd880711febfe9bfe46af Mon Sep 17 00:00:00 2001 From: pengzhendong <275331498@qq.com> Date: Tue, 9 Jun 2026 17:44:25 +0800 Subject: [PATCH 4/9] ci: fix macOS/Windows pynini installation in CI --- .github/workflows/unittest.yml | 25 ++++++++++++++++++------- 1 file changed, 18 insertions(+), 7 deletions(-) diff --git a/.github/workflows/unittest.yml b/.github/workflows/unittest.yml index 01e8313..4ed351b 100644 --- a/.github/workflows/unittest.yml +++ b/.github/workflows/unittest.yml @@ -20,20 +20,31 @@ jobs: - uses: actions/checkout@v4 with: fetch-depth: 0 - - name: Set up Python ${{ matrix.python-version }} - uses: actions/setup-python@v4 + - name: Set up Conda + uses: conda-incubator/setup-miniconda@v3 with: python-version: ${{ matrix.python-version }} + activate-environment: test + - name: Install openfst (macOS) + if: runner.os == 'macOS' + run: | + brew install openfst + echo "CPLUS_INCLUDE_PATH=/opt/homebrew/include:$CPLUS_INCLUDE_PATH" >> $GITHUB_ENV + echo "LIBRARY_PATH=/opt/homebrew/lib:$LIBRARY_PATH" >> $GITHUB_ENV + - name: Install pynini via conda (Windows) + if: runner.os == 'Windows' + shell: bash -el {0} + run: conda install -c conda-forge pynini - name: Install dependencies + shell: bash -el {0} run: | python -m pip install --upgrade pip - pip install .[test] + pip install .[test] ${{ runner.os == 'Windows' && '--no-deps' || '' }} - name: Lint with flake8 + shell: bash -el {0} run: | - # stop the build if there are Python syntax errors or undefined names flake8 . --count --select=E9,F63,F7,F82 --show-source --statistics - # exit-zero treats all errors as warnings. The GitHub editor is 127 chars wide flake8 . --count --exit-zero --max-complexity=10 --max-line-length=127 --statistics - name: Test with pytest - run: | - pytest + shell: bash -el {0} + run: pytest From b4d3f8dd9fb9c674438ad877dbbcfa33a4e1891c Mon Sep 17 00:00:00 2001 From: pengzhendong <275331498@qq.com> Date: Tue, 9 Jun 2026 17:48:17 +0800 Subject: [PATCH 5/9] ci: fix Windows deps and disable fail-fast --- .github/workflows/unittest.yml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.github/workflows/unittest.yml b/.github/workflows/unittest.yml index 4ed351b..f0b9bae 100644 --- a/.github/workflows/unittest.yml +++ b/.github/workflows/unittest.yml @@ -13,6 +13,7 @@ jobs: unit-test: runs-on: ${{ matrix.os }} strategy: + fail-fast: false matrix: os: [ubuntu-latest, macos-latest, windows-latest] python-version: [3.9] @@ -40,6 +41,7 @@ jobs: run: | python -m pip install --upgrade pip pip install .[test] ${{ runner.os == 'Windows' && '--no-deps' || '' }} + pip install flake8 pytest importlib_resources - name: Lint with flake8 shell: bash -el {0} run: | From 20d9090308ce5d9cfa048164847d33937740bcc6 Mon Sep 17 00:00:00 2001 From: pengzhendong <275331498@qq.com> Date: Tue, 9 Jun 2026 17:54:54 +0800 Subject: [PATCH 6/9] ci: test Windows with pip only (no conda) --- .github/workflows/unittest.yml | 27 ++++----------------------- 1 file changed, 4 insertions(+), 23 deletions(-) diff --git a/.github/workflows/unittest.yml b/.github/workflows/unittest.yml index f0b9bae..33d1843 100644 --- a/.github/workflows/unittest.yml +++ b/.github/workflows/unittest.yml @@ -15,38 +15,19 @@ jobs: strategy: fail-fast: false matrix: - os: [ubuntu-latest, macos-latest, windows-latest] + os: [windows-latest] python-version: [3.9] steps: - uses: actions/checkout@v4 with: fetch-depth: 0 - - name: Set up Conda - uses: conda-incubator/setup-miniconda@v3 + - name: Set up Python ${{ matrix.python-version }} + uses: actions/setup-python@v4 with: python-version: ${{ matrix.python-version }} - activate-environment: test - - name: Install openfst (macOS) - if: runner.os == 'macOS' - run: | - brew install openfst - echo "CPLUS_INCLUDE_PATH=/opt/homebrew/include:$CPLUS_INCLUDE_PATH" >> $GITHUB_ENV - echo "LIBRARY_PATH=/opt/homebrew/lib:$LIBRARY_PATH" >> $GITHUB_ENV - - name: Install pynini via conda (Windows) - if: runner.os == 'Windows' - shell: bash -el {0} - run: conda install -c conda-forge pynini - name: Install dependencies - shell: bash -el {0} run: | python -m pip install --upgrade pip - pip install .[test] ${{ runner.os == 'Windows' && '--no-deps' || '' }} - pip install flake8 pytest importlib_resources - - name: Lint with flake8 - shell: bash -el {0} - run: | - flake8 . --count --select=E9,F63,F7,F82 --show-source --statistics - flake8 . --count --exit-zero --max-complexity=10 --max-line-length=127 --statistics + pip install .[test] - name: Test with pytest - shell: bash -el {0} run: pytest From a70eda20fb9d6460cb768029a6d3461991c25e46 Mon Sep 17 00:00:00 2001 From: pengzhendong <275331498@qq.com> Date: Tue, 9 Jun 2026 17:56:22 +0800 Subject: [PATCH 7/9] ci: use conda for Windows, pip+openfst for macOS, pip for Linux --- .github/workflows/unittest.yml | 36 ++++++++++++++++++++++++++++++---- 1 file changed, 32 insertions(+), 4 deletions(-) diff --git a/.github/workflows/unittest.yml b/.github/workflows/unittest.yml index 33d1843..fd0ecfa 100644 --- a/.github/workflows/unittest.yml +++ b/.github/workflows/unittest.yml @@ -15,19 +15,47 @@ jobs: strategy: fail-fast: false matrix: - os: [windows-latest] - python-version: [3.9] + os: [ubuntu-latest, macos-latest, windows-latest] + python-version: ['3.9'] steps: - uses: actions/checkout@v4 with: fetch-depth: 0 - - name: Set up Python ${{ matrix.python-version }} + - name: Set up Python ${{ matrix.python-version }} (non-Windows) + if: runner.os != 'Windows' uses: actions/setup-python@v4 with: python-version: ${{ matrix.python-version }} - - name: Install dependencies + - name: Install openfst (macOS) + if: runner.os == 'macOS' + run: | + brew install openfst + echo "CPLUS_INCLUDE_PATH=/opt/homebrew/include:$CPLUS_INCLUDE_PATH" >> $GITHUB_ENV + echo "LIBRARY_PATH=/opt/homebrew/lib:$LIBRARY_PATH" >> $GITHUB_ENV + - name: Install dependencies (non-Windows) + if: runner.os != 'Windows' run: | python -m pip install --upgrade pip pip install .[test] + - name: Set up Conda (Windows) + if: runner.os == 'Windows' + uses: conda-incubator/setup-miniconda@v3 + with: + python-version: ${{ matrix.python-version }} + activate-environment: test + - name: Install dependencies (Windows) + if: runner.os == 'Windows' + shell: bash -el {0} + run: | + conda install -c conda-forge pynini + python -m pip install --upgrade pip + pip install .[test] --no-deps + pip install flake8 pytest importlib_resources + - name: Lint with flake8 + shell: bash -el {0} + run: | + flake8 . --count --select=E9,F63,F7,F82 --show-source --statistics + flake8 . --count --exit-zero --max-complexity=10 --max-line-length=127 --statistics - name: Test with pytest + shell: bash -el {0} run: pytest From e21d5924056921bf8e861520bb1b3664fc92a014 Mon Sep 17 00:00:00 2001 From: pengzhendong <275331498@qq.com> Date: Tue, 9 Jun 2026 18:03:50 +0800 Subject: [PATCH 8/9] fix: specify utf-8 encoding when reading test files for Windows --- tn/chinese/test/utils.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tn/chinese/test/utils.py b/tn/chinese/test/utils.py index 5978baa..c4fd4af 100644 --- a/tn/chinese/test/utils.py +++ b/tn/chinese/test/utils.py @@ -19,7 +19,7 @@ def parse_test_case(file_name): file = os.path.dirname(os.path.abspath(__file__)) + os.path.sep + file_name delimiter = "=>" - with open(file) as fin: + with open(file, encoding="utf-8") as fin: for line in fin: assert delimiter in line arr = line.strip().split(delimiter) From f865adad2e5a0e24580905c39434cbb476361c11 Mon Sep 17 00:00:00 2001 From: pengzhendong <275331498@qq.com> Date: Tue, 9 Jun 2026 18:05:57 +0800 Subject: [PATCH 9/9] ci: cache brew/conda/pip to speed up macOS and Windows CI --- .github/workflows/unittest.yml | 24 +++++++++++++++++++++++- 1 file changed, 23 insertions(+), 1 deletion(-) diff --git a/.github/workflows/unittest.yml b/.github/workflows/unittest.yml index fd0ecfa..90b4947 100644 --- a/.github/workflows/unittest.yml +++ b/.github/workflows/unittest.yml @@ -26,12 +26,27 @@ jobs: uses: actions/setup-python@v4 with: python-version: ${{ matrix.python-version }} + - name: Cache Homebrew (macOS) + if: runner.os == 'macOS' + uses: actions/cache@v4 + with: + path: | + /opt/homebrew/Cellar/openfst + /opt/homebrew/include/fst + /opt/homebrew/lib/libfst* + key: brew-openfst-${{ runner.os }} - name: Install openfst (macOS) if: runner.os == 'macOS' run: | - brew install openfst + brew install openfst || true echo "CPLUS_INCLUDE_PATH=/opt/homebrew/include:$CPLUS_INCLUDE_PATH" >> $GITHUB_ENV echo "LIBRARY_PATH=/opt/homebrew/lib:$LIBRARY_PATH" >> $GITHUB_ENV + - name: Cache pip (non-Windows) + if: runner.os != 'Windows' + uses: actions/cache@v4 + with: + path: ~/.cache/pip + key: pip-${{ runner.os }}-${{ hashFiles('pyproject.toml') }} - name: Install dependencies (non-Windows) if: runner.os != 'Windows' run: | @@ -43,6 +58,13 @@ jobs: with: python-version: ${{ matrix.python-version }} activate-environment: test + use-only-tar-bz2: true + - name: Cache Conda (Windows) + if: runner.os == 'Windows' + uses: actions/cache@v4 + with: + path: C:\Miniconda\envs\test + key: conda-${{ runner.os }}-${{ hashFiles('pyproject.toml') }} - name: Install dependencies (Windows) if: runner.os == 'Windows' shell: bash -el {0}