Skip to content

Commit f4fb649

Browse files
authored
fix: Resolve installation bug #292 and modernize package management (#325)
* 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 * feat: 更新CI工作流以支持现代Python打包 - 修改wheels.yml使用python -m build替代setup.py - 添加build和twine依赖 - 实现智能版本检测(setuptools_scm) - 优化工作流步骤结构 - 更新unittest.yml使用.[test]依赖安装 * fix: 回退pynini版本约束以解决测试失败问题 - 将pynini依赖从'>=2.1.6,<2.2.0'改回'==2.1.6' - 解决因版本升级导致的UnitTest失败 - 等待CI验证是否为版本兼容性问题 * fix: 更新GitHub Actions到最新版本以解决deprecated警告 - 将actions/checkout从v3更新到v4 - 将actions/upload-artifact从v3更新到v4 - 解决因使用deprecated动作版本导致的构建失败 * feat: 添加PyPI发布条件限制 - 只在原仓库master分支推送时执行PyPI发布 - 避免fork仓库因缺少认证而失败 - 保持工作流完整性和可测试性 * feat: 放宽pynini版本限制以提高兼容性 - 将pynini依赖从'==2.1.6'改为'>=2.1.6,<2.1.7' - 允许2.1.6.x系列的patch版本 - 保持与特定库的兼容性同时增加灵活性 * 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
1 parent d29351a commit f4fb649

File tree

6 files changed

+92
-68
lines changed

6 files changed

+92
-68
lines changed

.github/workflows/unittest.yml

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,15 +13,17 @@ jobs:
1313
matrix:
1414
python-version: [3.9]
1515
steps:
16-
- uses: actions/checkout@v3
16+
- uses: actions/checkout@v4
17+
with:
18+
fetch-depth: 0
1719
- name: Set up Python ${{ matrix.python-version }}
1820
uses: actions/setup-python@v4
1921
with:
2022
python-version: ${{ matrix.python-version }}
2123
- name: Install dependencies
2224
run: |
2325
python -m pip install --upgrade pip
24-
pip install -r requirements.txt
26+
pip install .[test]
2527
- name: Lint with flake8
2628
run: |
2729
# stop the build if there are Python syntax errors or undefined names

.github/workflows/wheels.yml

Lines changed: 28 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,8 @@ on:
44
workflow_dispatch:
55
inputs:
66
version:
7-
description: 'Release version'
8-
required: true
7+
description: 'Release version (optional, will be determined by setuptools_scm if not provided)'
8+
required: false
99

1010
jobs:
1111
build:
@@ -14,16 +14,18 @@ jobs:
1414
matrix:
1515
python-version: [3.9]
1616
steps:
17-
- uses: actions/checkout@v3
17+
- uses: actions/checkout@v4
18+
with:
19+
fetch-depth: 0
1820
- name: Set up Python ${{ matrix.python-version }}
1921
uses: actions/setup-python@v4
2022
with:
2123
python-version: ${{ matrix.python-version }}
2224
- name: Install dependencies
2325
run: |
2426
python -m pip install --upgrade pip
25-
pip install -r requirements.txt
26-
pip install wheel
27+
pip install .[test]
28+
pip install build twine
2729
2830
- name: Build Graph
2931
run: |
@@ -37,17 +39,33 @@ jobs:
3739
cp tn/*.fst graph
3840
cp itn/*.fst graph
3941
42+
- name: Get version from setuptools_scm
43+
id: scm_version
44+
run: |
45+
# Check if version is provided as input
46+
if [ -n "${{ github.event.inputs.version }}" ]; then
47+
echo "VERSION=${{ github.event.inputs.version }}" >> $GITHUB_OUTPUT
48+
else
49+
# Get version from setuptools_scm
50+
pip install setuptools_scm
51+
VERSION=$(python -m setuptools_scm | tail -1)
52+
echo "VERSION=$VERSION" >> $GITHUB_OUTPUT
53+
fi
54+
4055
- name: Upload Graph
41-
uses: actions/upload-artifact@v3
56+
uses: actions/upload-artifact@v4
4257
with:
43-
name: release-graph-v${{ github.event.inputs.version}}
58+
name: release-graph-v${{ steps.scm_version.outputs.VERSION }}
4459
path: graph
4560

61+
- name: Build package
62+
run: |
63+
python -m build
64+
4665
- name: Publish on pypi.org
66+
if: github.ref == 'refs/heads/master' && github.repository == 'wenet-e2e/WeTextProcessing'
4767
env:
4868
TWINE_USERNAME: __token__
4969
TWINE_PASSWORD: ${{ secrets.PYPI_API_TOKEN }}
5070
run: |
51-
python setup.py sdist bdist_wheel --version=${{ github.event.inputs.version}}
52-
python -m pip install -U twine
53-
python -m twine upload --repository-url https://upload.pypi.org/legacy/ dist/*
71+
python -m twine upload dist/*

.gitignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,3 +42,6 @@ build/
4242
dist/
4343
tn/*.far
4444
itn/*.far
45+
46+
# Version file(setuptools_scm generated)
47+
tn/_version.py

pyproject.toml

Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
[build-system]
2+
requires = ["setuptools>=45", "wheel", "setuptools_scm[toml]>=6.2"]
3+
build-backend = "setuptools.build_meta"
4+
5+
[project]
6+
name = "WeTextProcessing"
7+
authors = [
8+
{name = "Zhendong Peng", email = "pzd17@tsinghua.org.cn"},
9+
{name = "Xingchen Song", email = "sxc19@tsinghua.org.cn"}
10+
]
11+
description = "WeTextProcessing, including TN & ITN"
12+
readme = "README.md"
13+
requires-python = ">=3.7"
14+
classifiers = [
15+
"Programming Language :: Python :: 3",
16+
"Operating System :: OS Independent",
17+
"Topic :: Scientific/Engineering :: Artificial Intelligence",
18+
]
19+
dynamic = ["version"]
20+
dependencies = [
21+
# Core dependencies for text processing functionality
22+
"pynini>=2.1.6,<2.1.7",
23+
"importlib_resources"
24+
]
25+
26+
[project.urls]
27+
Homepage = "https://github.com/wenet-e2e/WeTextProcessing"
28+
29+
[project.scripts]
30+
wetn = "tn.main:main"
31+
weitn = "itn.main:main"
32+
33+
[project.optional-dependencies]
34+
test = [
35+
"pytest",
36+
"flake8"]
37+
dev = [
38+
# Development tools
39+
"flake8",
40+
"pre-commit==3.5.0",
41+
"pytest"
42+
]
43+
44+
[tool.setuptools_scm]
45+
version_scheme = "guess-next-dev"
46+
local_scheme = "dirty-tag"
47+
write_to = "tn/_version.py"
48+
fallback_version = "1.0.5"
49+
50+
[tool.setuptools.packages.find]
51+
where = ["."]
52+
include = ["tn*", "itn*"]
53+
namespaces = false
54+
55+
[tool.setuptools.package-data]
56+
tn = ["*.fst", "chinese/data/*/*.tsv", "english/data/*/*.tsv", "english/data/*.tsv", "english/data/*/*.far"]
57+
itn = ["*.fst", "chinese/data/*/*.tsv"]

requirements.txt

Lines changed: 0 additions & 5 deletions
This file was deleted.

setup.py

Lines changed: 0 additions & 51 deletions
This file was deleted.

0 commit comments

Comments
 (0)