Skip to content

Commit aac2fd6

Browse files
authored
fix: relax pynini version constraint to >=2.1.6 (#345)
* 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. * ci: add macOS and Windows to test matrix * ci: trigger on toml and yml changes * ci: fix macOS/Windows pynini installation in CI * ci: fix Windows deps and disable fail-fast * ci: test Windows with pip only (no conda) * ci: use conda for Windows, pip+openfst for macOS, pip for Linux * fix: specify utf-8 encoding when reading test files for Windows * ci: cache brew/conda/pip to speed up macOS and Windows CI
1 parent 030d1e3 commit aac2fd6

3 files changed

Lines changed: 57 additions & 10 deletions

File tree

.github/workflows/unittest.yml

Lines changed: 55 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -6,31 +6,78 @@ on:
66
paths:
77
- '**.py'
88
- '**.tsv'
9+
- '**.toml'
10+
- '**.yml'
911

1012
jobs:
1113
unit-test:
12-
runs-on: ubuntu-latest
14+
runs-on: ${{ matrix.os }}
1315
strategy:
16+
fail-fast: false
1417
matrix:
15-
python-version: [3.9]
18+
os: [ubuntu-latest, macos-latest, windows-latest]
19+
python-version: ['3.9']
1620
steps:
1721
- uses: actions/checkout@v4
1822
with:
1923
fetch-depth: 0
20-
- name: Set up Python ${{ matrix.python-version }}
24+
- name: Set up Python ${{ matrix.python-version }} (non-Windows)
25+
if: runner.os != 'Windows'
2126
uses: actions/setup-python@v4
2227
with:
2328
python-version: ${{ matrix.python-version }}
24-
- name: Install dependencies
29+
- name: Cache Homebrew (macOS)
30+
if: runner.os == 'macOS'
31+
uses: actions/cache@v4
32+
with:
33+
path: |
34+
/opt/homebrew/Cellar/openfst
35+
/opt/homebrew/include/fst
36+
/opt/homebrew/lib/libfst*
37+
key: brew-openfst-${{ runner.os }}
38+
- name: Install openfst (macOS)
39+
if: runner.os == 'macOS'
40+
run: |
41+
brew install openfst || true
42+
echo "CPLUS_INCLUDE_PATH=/opt/homebrew/include:$CPLUS_INCLUDE_PATH" >> $GITHUB_ENV
43+
echo "LIBRARY_PATH=/opt/homebrew/lib:$LIBRARY_PATH" >> $GITHUB_ENV
44+
- name: Cache pip (non-Windows)
45+
if: runner.os != 'Windows'
46+
uses: actions/cache@v4
47+
with:
48+
path: ~/.cache/pip
49+
key: pip-${{ runner.os }}-${{ hashFiles('pyproject.toml') }}
50+
- name: Install dependencies (non-Windows)
51+
if: runner.os != 'Windows'
2552
run: |
2653
python -m pip install --upgrade pip
2754
pip install .[test]
55+
- name: Set up Conda (Windows)
56+
if: runner.os == 'Windows'
57+
uses: conda-incubator/setup-miniconda@v3
58+
with:
59+
python-version: ${{ matrix.python-version }}
60+
activate-environment: test
61+
use-only-tar-bz2: true
62+
- name: Cache Conda (Windows)
63+
if: runner.os == 'Windows'
64+
uses: actions/cache@v4
65+
with:
66+
path: C:\Miniconda\envs\test
67+
key: conda-${{ runner.os }}-${{ hashFiles('pyproject.toml') }}
68+
- name: Install dependencies (Windows)
69+
if: runner.os == 'Windows'
70+
shell: bash -el {0}
71+
run: |
72+
conda install -c conda-forge pynini
73+
python -m pip install --upgrade pip
74+
pip install .[test] --no-deps
75+
pip install flake8 pytest importlib_resources
2876
- name: Lint with flake8
77+
shell: bash -el {0}
2978
run: |
30-
# stop the build if there are Python syntax errors or undefined names
3179
flake8 . --count --select=E9,F63,F7,F82 --show-source --statistics
32-
# exit-zero treats all errors as warnings. The GitHub editor is 127 chars wide
3380
flake8 . --count --exit-zero --max-complexity=10 --max-line-length=127 --statistics
3481
- name: Test with pytest
35-
run: |
36-
pytest
82+
shell: bash -el {0}
83+
run: pytest

pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ classifiers = [
1919
dynamic = ["version"]
2020
dependencies = [
2121
# Core dependencies for text processing functionality
22-
"pynini>=2.1.6,<2.1.7",
22+
"pynini>=2.1.6",
2323
"importlib_resources"
2424
]
2525

tn/chinese/test/utils.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ def parse_test_case(file_name):
1919
file = os.path.dirname(os.path.abspath(__file__)) + os.path.sep + file_name
2020

2121
delimiter = "=>"
22-
with open(file) as fin:
22+
with open(file, encoding="utf-8") as fin:
2323
for line in fin:
2424
assert delimiter in line
2525
arr = line.strip().split(delimiter)

0 commit comments

Comments
 (0)