Skip to content

Commit 2105645

Browse files
committed
chore: migrate project management and CI/CD to uv
- Add pyproject.toml and uv.lock for uv-based dependency management. - Update Makefile to use 'uv build' for package building. - Update .github/workflows/ci.yml to use astral-sh/setup-uv and uv commands. - Update .circleci/config.yml to install and use uv for testing. - Add uv installation instructions to README.rst and README_en.rst.
1 parent 2f68f19 commit 2105645

7 files changed

Lines changed: 7036 additions & 22 deletions

File tree

.circleci/config.yml

Lines changed: 13 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -22,26 +22,24 @@ jobs:
2222
# keys:
2323
# - v1-dependencies-{{ .Environment.TOX_ENV }}-{{ checksum "requirements_dev.txt" }}
2424

25+
- run:
26+
name: install uv
27+
command: curl -LsSf https://astral.sh/uv/install.sh | sh
28+
2529
- run:
2630
name: install dependencies
2731
command: |
28-
# pip install -U pip virtualenv --user
29-
if ! which virtualenv; then
30-
pip install 'virtualenv<=20.0.21' --user
31-
fi
32-
export PATH="~/.local/bin:$PATH"
33-
34-
virtualenv venv
35-
. venv/bin/activate
32+
export PATH="$HOME/.local/bin:$PATH"
33+
uv venv
34+
. .venv/bin/activate
3635
37-
pip install coveralls
38-
pip install 'tox<4.0.0'
36+
uv pip install coveralls 'tox<4.0.0'
3937
4038
if [[ $RUN_CHECK == 1 ]]; then
41-
pip install -U -r requirements_dev.txt
39+
uv pip install -r requirements_dev.txt
4240
fi
4341
if [[ $(echo $TOX_ENV | grep pypy3) ]]; then
44-
pip install setuptools==60.10.0
42+
uv pip install setuptools==60.10.0
4543
fi
4644
4745
if [[ $(python -c "import sys; print(sys.stdin.encoding)" |grep None) ]]; then
@@ -56,7 +54,8 @@ jobs:
5654
- run:
5755
name: run tests
5856
command: |
59-
. venv/bin/activate
57+
export PATH="$HOME/.local/bin:$PATH"
58+
. .venv/bin/activate
6059
6160
if [[ $RUN_CHECK == 1 ]]; then
6261
pre-commit run --all-files
@@ -66,7 +65,7 @@ jobs:
6665
6766
tox -e $TOX_ENV
6867
69-
python setup.py install
68+
uv pip install .
7069
pypinyin hello
7170
echo hello | pypinyin
7271
pypinyin < setup.cfg

.github/workflows/ci.yml

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -17,25 +17,29 @@ jobs:
1717
steps:
1818
- uses: actions/checkout@v5
1919

20+
- name: Set up uv
21+
uses: astral-sh/setup-uv@v5
22+
2023
- name: Set up Python ${{ matrix.python-version }}
2124
uses: actions/setup-python@v6
2225
with:
2326
python-version: ${{ matrix.python-version }}
2427

2528
- name: Install dependencies
2629
run: |
27-
python -m pip install -r requirements_dev.txt
30+
uv pip install --system -r requirements_dev.txt
31+
uv pip install --system .
2832
2933
- name: Run tests
3034
run: |
31-
py.test tests/ pypinyin/
35+
python -m pytest tests/ pypinyin/
3236
3337
- name: test cli
3438
if: startsWith(matrix.os,'ubuntu')
3539
run: |
3640
set -xe
37-
python setup.py sdist
38-
python -m pip install dist/*.gz
41+
uv build
42+
uv pip install --system dist/*.tar.gz
3943
python -m pypinyin test
4044
python -m pypinyin.tools.toneconvert to-tone 'zhong4 xin1'
4145

Makefile

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -29,15 +29,13 @@ doctest:
2929
.PHONY: publish
3030
publish: clean
3131
@echo "publish to pypi"
32-
python setup.py sdist
33-
python setup.py bdist_wheel
32+
uv build
3433
twine upload dist/*
3534

3635
.PHONY: publish_test
3736
publish_test: clean
3837
@echo "publish to test pypi"
39-
python setup.py sdist
40-
python setup.py bdist_wheel
38+
uv build
4139
twine upload --repository test dist/*
4240

4341
.PHONY: docs_html

README.rst

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,12 @@
3333
3434
pip install pypinyin
3535
36+
使用 `uv` 安装:
37+
38+
.. code-block:: bash
39+
40+
uv add pypinyin
41+
3642
3743
使用示例
3844
--------

README_en.rst

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,12 @@ Install
3333
3434
$ pip install pypinyin
3535
36+
Install with `uv`:
37+
38+
.. code-block:: bash
39+
40+
$ uv add pypinyin
41+
3642
3743
Usage cases
3844
--------

pyproject.toml

Lines changed: 78 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,78 @@
1+
[build-system]
2+
requires = ["setuptools>=42", "wheel"]
3+
build-backend = "setuptools.build_meta"
4+
5+
[project]
6+
name = "pypinyin"
7+
description = "汉字拼音转换模块/工具."
8+
readme = "README.rst"
9+
dynamic = ["version"]
10+
requires-python = ">=2.6, !=3.0.*, !=3.1.*, !=3.2.*, <4"
11+
license = {text = "MIT"}
12+
authors = [{name = "mozillazg, 闲耘", email = "mozillazg101@gmail.com"}]
13+
classifiers = [
14+
"Development Status :: 5 - Production/Stable",
15+
"Intended Audience :: Developers",
16+
"License :: OSI Approved :: MIT License",
17+
"Operating System :: OS Independent",
18+
"Programming Language :: Python",
19+
"Programming Language :: Python :: 2",
20+
"Programming Language :: Python :: 2.7",
21+
"Programming Language :: Python :: 3",
22+
"Programming Language :: Python :: 3.4",
23+
"Programming Language :: Python :: 3.5",
24+
"Programming Language :: Python :: 3.6",
25+
"Programming Language :: Python :: 3.7",
26+
"Programming Language :: Python :: 3.8",
27+
"Programming Language :: Python :: 3.9",
28+
"Programming Language :: Python :: 3.10",
29+
"Programming Language :: Python :: 3.11",
30+
"Programming Language :: Python :: 3.12",
31+
"Programming Language :: Python :: 3.13",
32+
"Programming Language :: Python :: Implementation :: CPython",
33+
"Programming Language :: Python :: Implementation :: PyPy",
34+
"Topic :: Utilities",
35+
"Topic :: Text Processing"
36+
]
37+
keywords = ["pinyin", "拼音"]
38+
dependencies = [
39+
"argparse; python_version < '2.7'",
40+
"enum34; python_version < '3.4'",
41+
"typing; python_version < '3.5'"
42+
]
43+
44+
[project.urls]
45+
Documentation = "https://pypinyin.readthedocs.io/"
46+
Source = "https://github.com/mozillazg/python-pinyin"
47+
Tracker = "https://github.com/mozillazg/python-pinyin/issues"
48+
49+
[project.scripts]
50+
pypinyin = "pypinyin.__main__:main"
51+
52+
[project.entry-points.pyinstaller40]
53+
hook-dirs = "pypinyin.__pyinstaller:get_hook_dirs"
54+
55+
[dependency-groups]
56+
dev = [
57+
"argparse",
58+
"bumpversion",
59+
"mypy; python_version >= '3.5'",
60+
"pre-commit",
61+
"pygments>=2.7.4; python_version >= '3.5'",
62+
"pytest",
63+
"pytest-cov",
64+
"pytest-random-order",
65+
"setuptools",
66+
"sphinx>=3.0.4; python_version >= '3.5'",
67+
"tox",
68+
"twine",
69+
"wheel>=0.21"
70+
]
71+
72+
[tool.setuptools]
73+
packages = ["pypinyin", "pypinyin.contrib", "pypinyin.seg", "pypinyin.style", "pypinyin.tools", "pypinyin.__pyinstaller"]
74+
include-package-data = true
75+
zip-safe = false
76+
77+
[tool.setuptools.dynamic]
78+
version = {attr = "pypinyin.__version__"}

0 commit comments

Comments
 (0)