From 8c677c56d0ad42f44a65a757436c95a97c433466 Mon Sep 17 00:00:00 2001 From: lzy <130823924+WhizZest@users.noreply.github.com> Date: Sun, 22 Feb 2026 02:43:21 +0800 Subject: [PATCH 1/7] fix: Resolve installation bug #292 and modernize package management - Fix IndexError in setup.py version extraction logic - Upgrade pynini dependency to support post-release versions - Replace manual version management with setuptools_scm - Migrate to modern pyproject.toml configuration - Remove obsolete setup.py and requirements.txt - Enable coexistence with nemo_text_processing in ChatTTS ecosystem --- pyproject.toml | 55 ++++++++++++++++++++++++++++++++++++++++++++++++ requirements.txt | 5 ----- setup.py | 51 -------------------------------------------- 3 files changed, 55 insertions(+), 56 deletions(-) create mode 100644 pyproject.toml delete mode 100644 requirements.txt delete mode 100644 setup.py diff --git a/pyproject.toml b/pyproject.toml new file mode 100644 index 00000000..25a906e1 --- /dev/null +++ b/pyproject.toml @@ -0,0 +1,55 @@ +[build-system] +requires = ["setuptools>=45", "wheel", "setuptools_scm[toml]>=6.2"] +build-backend = "setuptools.build_meta" + +[project] +name = "WeTextProcessing" +authors = [ + {name = "Zhendong Peng", email = "pzd17@tsinghua.org.cn"}, + {name = "Xingchen Song", email = "sxc19@tsinghua.org.cn"} +] +description = "WeTextProcessing, including TN & ITN" +readme = "README.md" +requires-python = ">=3.7" +classifiers = [ + "Programming Language :: Python :: 3", + "Operating System :: OS Independent", + "Topic :: Scientific/Engineering :: Artificial Intelligence", +] +dynamic = ["version"] +dependencies = [ + # Core dependencies for text processing functionality + "pynini>=2.1.6,<2.2.0", + "importlib_resources" +] + +[project.urls] +Homepage = "https://github.com/wenet-e2e/WeTextProcessing" + +[project.scripts] +wetn = "tn.main:main" +weitn = "itn.main:main" + +[project.optional-dependencies] +test = ["pytest"] +dev = [ + # Development tools + "flake8", + "pre-commit==3.5.0", + "pytest" +] + +[tool.setuptools_scm] +version_scheme = "guess-next-dev" +local_scheme = "dirty-tag" +write_to = "tn/_version.py" +fallback_version = "1.0.5" + +[tool.setuptools.packages.find] +where = ["."] +include = ["tn*", "itn*"] +namespaces = false + +[tool.setuptools.package-data] +tn = ["*.fst", "chinese/data/*/*.tsv", "english/data/*/*.tsv", "english/data/*.tsv", "english/data/*/*.far"] +itn = ["*.fst", "chinese/data/*/*.tsv"] \ No newline at end of file diff --git a/requirements.txt b/requirements.txt deleted file mode 100644 index 4c714d3e..00000000 --- a/requirements.txt +++ /dev/null @@ -1,5 +0,0 @@ -flake8 -importlib_resources -pynini==2.1.6 -pytest -pre-commit==3.5.0 diff --git a/setup.py b/setup.py deleted file mode 100644 index e67425fc..00000000 --- a/setup.py +++ /dev/null @@ -1,51 +0,0 @@ -# Copyright (c) 2022 Xingchen Song (sxc19@tsinghua.org.cn) -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -import sys - -from setuptools import find_packages, setup - -version = sys.argv[-1].split("=")[1] -sys.argv = sys.argv[0 : len(sys.argv) - 1] - -with open("README.md", "r", encoding="utf8") as fh: - long_description = fh.read() - -setup( - name="WeTextProcessing", - version=version, - author="Zhendong Peng, Xingchen Song", - author_email="pzd17@tsinghua.org.cn, sxc19@tsinghua.org.cn", - long_description=long_description, - long_description_content_type="text/markdown", - description="WeTextProcessing, including TN & ITN", - url="https://github.com/wenet-e2e/WeTextProcessing", - packages=find_packages(), - package_data={ - "tn": ["*.fst", "chinese/data/*/*.tsv", "english/data/*/*.tsv", "english/data/*.tsv", "english/data/*/*.far"], - "itn": ["*.fst", "chinese/data/*/*.tsv"], - }, - install_requires=["pynini==2.1.6", "importlib_resources"], - entry_points={ - "console_scripts": [ - "wetn = tn.main:main", - "weitn = itn.main:main", - ] - }, - tests_require=["pytest"], - classifiers=[ - "Programming Language :: Python :: 3", - "Operating System :: OS Independent", - "Topic :: Scientific/Engineering :: Artificial Intelligence", - ], -) From e2ecbfae083c011defbb8a56423c6e955dc935af Mon Sep 17 00:00:00 2001 From: lzy <130823924+WhizZest@users.noreply.github.com> Date: Thu, 26 Feb 2026 00:39:46 +0800 Subject: [PATCH 2/7] =?UTF-8?q?feat:=20=E6=9B=B4=E6=96=B0CI=E5=B7=A5?= =?UTF-8?q?=E4=BD=9C=E6=B5=81=E4=BB=A5=E6=94=AF=E6=8C=81=E7=8E=B0=E4=BB=A3?= =?UTF-8?q?Python=E6=89=93=E5=8C=85?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - 修改wheels.yml使用python -m build替代setup.py - 添加build和twine依赖 - 实现智能版本检测(setuptools_scm) - 优化工作流步骤结构 - 更新unittest.yml使用.[test]依赖安装 --- .github/workflows/unittest.yml | 4 +++- .github/workflows/wheels.yml | 31 ++++++++++++++++++++++++------- .gitignore | 3 +++ pyproject.toml | 4 +++- 4 files changed, 33 insertions(+), 9 deletions(-) diff --git a/.github/workflows/unittest.yml b/.github/workflows/unittest.yml index 8a09ffc3..feef9726 100644 --- a/.github/workflows/unittest.yml +++ b/.github/workflows/unittest.yml @@ -14,6 +14,8 @@ jobs: python-version: [3.9] steps: - uses: actions/checkout@v3 + with: + fetch-depth: 0 - name: Set up Python ${{ matrix.python-version }} uses: actions/setup-python@v4 with: @@ -21,7 +23,7 @@ jobs: - name: Install dependencies run: | python -m pip install --upgrade pip - pip install -r requirements.txt + pip install .[test] - name: Lint with flake8 run: | # stop the build if there are Python syntax errors or undefined names diff --git a/.github/workflows/wheels.yml b/.github/workflows/wheels.yml index c676192c..5032bb13 100644 --- a/.github/workflows/wheels.yml +++ b/.github/workflows/wheels.yml @@ -5,7 +5,7 @@ on: inputs: version: description: 'Release version' - required: true + required: false jobs: build: @@ -15,6 +15,8 @@ jobs: python-version: [3.9] steps: - uses: actions/checkout@v3 + with: + fetch-depth: 0 - name: Set up Python ${{ matrix.python-version }} uses: actions/setup-python@v4 with: @@ -22,8 +24,8 @@ jobs: - name: Install dependencies run: | python -m pip install --upgrade pip - pip install -r requirements.txt - pip install wheel + pip install .[test] + pip install build twine - name: Build Graph run: | @@ -37,17 +39,32 @@ jobs: cp tn/*.fst graph cp itn/*.fst graph + - name: Get version from setuptools_scm + id: scm_version + run: | + # Check if version is provided as input + if [ -n "${{ github.event.inputs.version }}" ]; then + echo "VERSION=${{ github.event.inputs.version }}" >> $GITHUB_OUTPUT + else + # Get version from setuptools_scm + pip install setuptools_scm + VERSION=$(python -m setuptools_scm | tail -1) + echo "VERSION=$VERSION" >> $GITHUB_OUTPUT + fi + - name: Upload Graph uses: actions/upload-artifact@v3 with: - name: release-graph-v${{ github.event.inputs.version}} + name: release-graph-v${{ steps.scm_version.outputs.VERSION }} path: graph + - name: Build package + run: | + python -m build + - name: Publish on pypi.org env: TWINE_USERNAME: __token__ TWINE_PASSWORD: ${{ secrets.PYPI_API_TOKEN }} run: | - python setup.py sdist bdist_wheel --version=${{ github.event.inputs.version}} - python -m pip install -U twine - python -m twine upload --repository-url https://upload.pypi.org/legacy/ dist/* + python -m twine upload dist/* diff --git a/.gitignore b/.gitignore index 3a1ec79c..9f51123f 100644 --- a/.gitignore +++ b/.gitignore @@ -42,3 +42,6 @@ build/ dist/ tn/*.far itn/*.far + +# Version file(setuptools_scm generated) +tn/_version.py diff --git a/pyproject.toml b/pyproject.toml index 25a906e1..c75d0802 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -31,7 +31,9 @@ wetn = "tn.main:main" weitn = "itn.main:main" [project.optional-dependencies] -test = ["pytest"] +test = [ + "pytest", + "flake8"] dev = [ # Development tools "flake8", From 9a794f5eb529ce10a987a2c282b110c63a4ee8ca Mon Sep 17 00:00:00 2001 From: lzy <130823924+WhizZest@users.noreply.github.com> Date: Thu, 26 Feb 2026 01:05:49 +0800 Subject: [PATCH 3/7] =?UTF-8?q?fix:=20=E5=9B=9E=E9=80=80pynini=E7=89=88?= =?UTF-8?q?=E6=9C=AC=E7=BA=A6=E6=9D=9F=E4=BB=A5=E8=A7=A3=E5=86=B3=E6=B5=8B?= =?UTF-8?q?=E8=AF=95=E5=A4=B1=E8=B4=A5=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - 将pynini依赖从'>=2.1.6,<2.2.0'改回'==2.1.6' - 解决因版本升级导致的UnitTest失败 - 等待CI验证是否为版本兼容性问题 --- pyproject.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pyproject.toml b/pyproject.toml index c75d0802..0b9de9a7 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.2.0", + "pynini==2.1.6", "importlib_resources" ] From 71498a68d8018e53f14d0bde39642c821a17117b Mon Sep 17 00:00:00 2001 From: lzy <130823924+WhizZest@users.noreply.github.com> Date: Thu, 26 Feb 2026 01:18:29 +0800 Subject: [PATCH 4/7] =?UTF-8?q?fix:=20=E6=9B=B4=E6=96=B0GitHub=20Actions?= =?UTF-8?q?=E5=88=B0=E6=9C=80=E6=96=B0=E7=89=88=E6=9C=AC=E4=BB=A5=E8=A7=A3?= =?UTF-8?q?=E5=86=B3deprecated=E8=AD=A6=E5=91=8A?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - 将actions/checkout从v3更新到v4 - 将actions/upload-artifact从v3更新到v4 - 解决因使用deprecated动作版本导致的构建失败 --- .github/workflows/unittest.yml | 2 +- .github/workflows/wheels.yml | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/.github/workflows/unittest.yml b/.github/workflows/unittest.yml index feef9726..28dc2170 100644 --- a/.github/workflows/unittest.yml +++ b/.github/workflows/unittest.yml @@ -13,7 +13,7 @@ jobs: matrix: python-version: [3.9] steps: - - uses: actions/checkout@v3 + - uses: actions/checkout@v4 with: fetch-depth: 0 - name: Set up Python ${{ matrix.python-version }} diff --git a/.github/workflows/wheels.yml b/.github/workflows/wheels.yml index 5032bb13..1926f319 100644 --- a/.github/workflows/wheels.yml +++ b/.github/workflows/wheels.yml @@ -14,7 +14,7 @@ jobs: matrix: python-version: [3.9] steps: - - uses: actions/checkout@v3 + - uses: actions/checkout@v4 with: fetch-depth: 0 - name: Set up Python ${{ matrix.python-version }} @@ -53,7 +53,7 @@ jobs: fi - name: Upload Graph - uses: actions/upload-artifact@v3 + uses: actions/upload-artifact@v4 with: name: release-graph-v${{ steps.scm_version.outputs.VERSION }} path: graph From 50f27d43c20851eedc5c4c0f39fa2e3adcbf7a6b Mon Sep 17 00:00:00 2001 From: lzy <130823924+WhizZest@users.noreply.github.com> Date: Thu, 26 Feb 2026 02:05:58 +0800 Subject: [PATCH 5/7] =?UTF-8?q?feat:=20=E6=B7=BB=E5=8A=A0PyPI=E5=8F=91?= =?UTF-8?q?=E5=B8=83=E6=9D=A1=E4=BB=B6=E9=99=90=E5=88=B6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - 只在原仓库master分支推送时执行PyPI发布 - 避免fork仓库因缺少认证而失败 - 保持工作流完整性和可测试性 --- .github/workflows/wheels.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/wheels.yml b/.github/workflows/wheels.yml index 1926f319..ac4ef01e 100644 --- a/.github/workflows/wheels.yml +++ b/.github/workflows/wheels.yml @@ -63,6 +63,7 @@ jobs: python -m build - name: Publish on pypi.org + if: github.ref == 'refs/heads/master' && github.repository == 'wenet-e2e/WeTextProcessing' env: TWINE_USERNAME: __token__ TWINE_PASSWORD: ${{ secrets.PYPI_API_TOKEN }} From 58ad20a7bfd8933b727561e1dee5f33114a0f550 Mon Sep 17 00:00:00 2001 From: lzy <130823924+WhizZest@users.noreply.github.com> Date: Thu, 26 Feb 2026 02:09:49 +0800 Subject: [PATCH 6/7] =?UTF-8?q?feat:=20=E6=94=BE=E5=AE=BDpynini=E7=89=88?= =?UTF-8?q?=E6=9C=AC=E9=99=90=E5=88=B6=E4=BB=A5=E6=8F=90=E9=AB=98=E5=85=BC?= =?UTF-8?q?=E5=AE=B9=E6=80=A7?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - 将pynini依赖从'==2.1.6'改为'>=2.1.6,<2.1.7' - 允许2.1.6.x系列的patch版本 - 保持与特定库的兼容性同时增加灵活性 --- pyproject.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pyproject.toml b/pyproject.toml index 0b9de9a7..0e2929b6 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", + "pynini>=2.1.6,<2.1.7", "importlib_resources" ] From 625d0377c1f978bac1ffcc55123bbd42f08e083c Mon Sep 17 00:00:00 2001 From: lzy <130823924+WhizZest@users.noreply.github.com> Date: Thu, 26 Feb 2026 09:53:49 +0800 Subject: [PATCH 7/7] docs: improve version input description in wheels workflow - Update description to clarify that version is optional - Explain that setuptools_scm will determine version automatically if not provided - Improve user experience for workflow dispatch --- .github/workflows/wheels.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/wheels.yml b/.github/workflows/wheels.yml index ac4ef01e..ccb45389 100644 --- a/.github/workflows/wheels.yml +++ b/.github/workflows/wheels.yml @@ -4,7 +4,7 @@ on: workflow_dispatch: inputs: version: - description: 'Release version' + description: 'Release version (optional, will be determined by setuptools_scm if not provided)' required: false jobs: