Skip to content

Commit 6916e5e

Browse files
nanae772Hiroshiba
andauthored
chore: uvへ移行する(Dockerコンテナ以外) (#1616)
Co-authored-by: Hiroshiba <[email protected]>
1 parent ae6219a commit 6916e5e

23 files changed

+1470
-3232
lines changed

.gitattributes

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
test/**/__snapshots__/**/*.json linguist-generated=true
22

3-
* text=auto
3+
* text=auto eol=lf
44
*.png -text
55
*.wav -text

.github/actions/prepare_python/action.yml

Lines changed: 16 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -2,18 +2,9 @@ name: "Prepare Python"
22
description: "Python ランタイムと依存パッケージをインストールし、Python バージョンを出力する"
33

44
inputs:
5-
only-export-python-version:
6-
description: "Python バージョンの出力のみをおこなうか否か"
5+
dependency-group:
6+
description: "uv の依存パッケージインストール時に指定するグループ"
77
required: false
8-
default: "false"
9-
requirements-suffix:
10-
description: "依存パッケージインストール時に `requirements` へ付ける接尾語"
11-
required: false
12-
default: ""
13-
python-version:
14-
description: "インストールされる Python ランタイムのバージョン。デフォルト値はこのリポジトリが想定する Python バージョン。"
15-
required: false
16-
default: "3.11.9"
178
outputs:
189
python-version:
1910
description: "Python version"
@@ -22,19 +13,25 @@ outputs:
2213
runs:
2314
using: "composite"
2415
steps:
25-
- name: <Setup> Set up Python
26-
if: ${{ inputs.only-export-python-version == 'false' }}
27-
uses: actions/setup-python@v5
16+
- name: <Setup> Install uv
17+
uses: astral-sh/setup-uv@v5
2818
with:
29-
python-version: ${{ inputs.python-version }}
30-
cache: pip
19+
enable-cache: false # TODO: uvの上手いキャッシュのやり方を考える
3120

3221
- name: <Setup> Install Python dependencies
33-
if: ${{ inputs.only-export-python-version == 'false' }}
34-
run: python -m pip install -r requirements${{ inputs.requirements-suffix }}.txt
22+
run: |
23+
if [[ -n "${{ inputs.dependency-group }}" ]]; then
24+
uv sync --group ${{ inputs.dependency-group }}
25+
else
26+
uv sync
27+
fi
3528
shell: bash
3629

3730
- name: <Deploy> Export Python version
3831
id: export-python-version
39-
run: echo "python-version=${{ inputs.python-version }}" >> $GITHUB_OUTPUT
32+
run: |
33+
PYTHON_VERSION=$(
34+
uv run python -c 'import platform; print(platform.python_version())'
35+
)
36+
echo "python-version=${PYTHON_VERSION}" >> "$GITHUB_OUTPUT"
4037
shell: bash

.github/workflows/build-docs.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ jobs:
2727
uses: ./.github/actions/prepare_python
2828

2929
- name: <Build> Make documents
30-
run: PYTHONPATH=. python tools/make_docs.py
30+
run: PYTHONPATH=. uv run tools/make_docs.py
3131

3232
- name: <Deploy> Deploy documents to GitHub Pages
3333
uses: peaceiris/actions-gh-pages@v4

.github/workflows/build-engine-container.yml

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -105,8 +105,6 @@ jobs:
105105
- name: <Setup> Prepare Python version
106106
id: prepare-python
107107
uses: ./.github/actions/prepare_python
108-
with:
109-
only-export-python-version: true
110108

111109
- name: <Setup> Set up Docker Buildx
112110
id: buildx
@@ -145,7 +143,7 @@ jobs:
145143
{
146144
echo "tags<<EOF"
147145
148-
python3 tools/generate_docker_image_names.py \
146+
uv run tools/generate_docker_image_names.py \
149147
--repository "${{ env.IMAGE_NAME }}" \
150148
--version "${{ needs.config.outputs.version_or_latest }}" \
151149
--prefix "${{ matrix.prefixes }}"
@@ -218,8 +216,6 @@ jobs:
218216
- name: <Setup> Prepare Python version
219217
id: prepare-python
220218
uses: ./.github/actions/prepare_python
221-
with:
222-
only-export-python-version: true
223219

224220
- name: <Setup> Set up Docker Buildx
225221
id: buildx

.github/workflows/build-engine-package.yml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -288,7 +288,7 @@ jobs:
288288
- name: <Setup> Prepare Python Runtime / Python Dependencies
289289
uses: ./.github/actions/prepare_python
290290
with:
291-
requirements-suffix: "-build"
291+
dependency-group: build
292292

293293
- name: <Setup> Prepare custom PyInstaller
294294
if: runner.os == 'Windows'
@@ -299,7 +299,7 @@ jobs:
299299
# try 5 times, sleep 5 seconds before retry
300300
for _ in $(seq 5); do
301301
EXIT_CODE=0
302-
python3 -c "import pyopenjtalk; pyopenjtalk._lazy_init()" || EXIT_CODE=$?
302+
uv run python -c "import pyopenjtalk; pyopenjtalk._lazy_init()" || EXIT_CODE=$?
303303
304304
if [ "$EXIT_CODE" = "0" ]; then
305305
break
@@ -441,7 +441,7 @@ jobs:
441441
cp resources/engine_manifest_assets/dependency_licenses.json licenses.json
442442
443443
- name: <Build> Generate filemap.json
444-
run: python tools/generate_filemap.py --target_dir resources/character_info
444+
run: uv run tools/generate_filemap.py --target_dir resources/character_info
445445

446446
- name: <Build> Build VOICEVOX ENGINE run.py
447447
run: |
@@ -471,7 +471,7 @@ jobs:
471471
CORE_MODEL_DIR_PATH="download/core/model" \
472472
LIBCORE_PATH="$LIBCORE_PATH" \
473473
LIBONNXRUNTIME_PATH="$LIBONNXRUNTIME_PATH" \
474-
pyinstaller --noconfirm run.spec
474+
uv run pyinstaller --noconfirm run.spec
475475
476476
# Because PyInstaller does not copy dynamic loaded libraries,
477477
# manually move DLL dependencies into `dist/run/` (cache already saved)

.github/workflows/test-engine-container.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ jobs:
4444
- name: <Setup> Prepare Python Runtime / Python Dependencies
4545
uses: ./.github/actions/prepare_python
4646
with:
47-
requirements-suffix: "-dev"
47+
dependency-group: dev
4848

4949
- name: <Setup> Declare variables
5050
id: docker_vars
@@ -86,4 +86,4 @@ jobs:
8686
exit 1
8787
8888
- name: <Test> Test ENGINE application docker container
89-
run: python tools/check_release_build.py --skip_run_process --skip_check_manifest --dist_dir dist/
89+
run: uv run tools/check_release_build.py --skip_run_process --skip_check_manifest --dist_dir dist/

.github/workflows/test-engine-package.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ jobs:
6969
- name: <Setup> Prepare Python Runtime / Python Dependencies
7070
uses: ./.github/actions/prepare_python
7171
with:
72-
requirements-suffix: "-dev"
72+
dependency-group: dev
7373

7474
- name: <Setup> Download ENGINE package
7575
run: |
@@ -84,4 +84,4 @@ jobs:
8484
run: chmod +x dist/run
8585

8686
- name: <Test> Test ENGINE package
87-
run: python tools/check_release_build.py --dist_dir dist/
87+
run: uv run tools/check_release_build.py --dist_dir dist/

.github/workflows/test-security.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ jobs:
2020
- name: <Setup> Prepare Python Runtime / Python Dependencies
2121
uses: ./.github/actions/prepare_python
2222
with:
23-
requirements-suffix: "-dev"
23+
dependency-group: dev
2424

2525
- name: <Test> Check Python dependency security
2626
uses: pypa/[email protected]

.github/workflows/test.yml

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -23,43 +23,43 @@ jobs:
2323
- name: <Setup> Prepare Python Runtime / Python Dependencies
2424
uses: ./.github/actions/prepare_python
2525
with:
26-
requirements-suffix: "-dev"
26+
dependency-group: dev
2727

28-
- name: <Test> Validate poetry.lock
28+
- name: <Test> Validate uv.lock
2929
run: |
30-
poetry lock
30+
uv lock
3131
git diff --exit-code
3232
3333
- name: <Test> Check dependency lists
3434
run: |
35-
poetry export --without-hashes -o requirements.txt.check
36-
poetry export --without-hashes --with dev -o requirements-dev.txt.check
37-
poetry export --without-hashes --with build -o requirements-build.txt.check
35+
uv export --no-annotate --no-hashes --no-header -o requirements.txt.check
36+
uv export --group dev --no-annotate --no-hashes --no-header -o requirements-dev.txt.check
37+
uv export --group build --no-annotate --no-hashes --no-header -o requirements-build.txt.check
3838
3939
diff -q requirements.txt requirements.txt.check || \
4040
diff -q requirements-dev.txt requirements-dev.txt.check || \
4141
diff -q requirements-build.txt requirements-build.txt.check > /dev/null
4242
if [ $? = 1 ]; then
43-
echo "poetry export has some diff"
43+
echo "uv export has some diff"
4444
exit 1
4545
fi
4646
4747
- name: <Test> Check linting
48-
run: ruff check
48+
run: uv run ruff check
4949

5050
- name: <Test> Check formatting
51-
run: ruff format --check
51+
run: uv run ruff format --check
5252

5353
- name: <Test> Check typing
54-
run: mypy .
54+
run: uv run mypy .
5555

5656
- name: <Test> Test codes and coverage
57-
run: coverage run --omit=test/* -m pytest
57+
run: uv run coverage run --omit=test/* -m pytest
5858

5959
- name: <Deploy> Submit coverage results to Coveralls
6060
if: runner.os == 'Linux'
6161
# Coveralls へのアップロードが失敗しても CI は継続させる
62-
run: coveralls --service=github || echo "::warning::Coveralls failed, but continuing"
62+
run: uv run coveralls --service=github || echo "::warning::Coveralls failed, but continuing"
6363
env:
6464
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
6565

@@ -68,7 +68,7 @@ jobs:
6868

6969
- name: <Test> Test names by checking typo
7070
if: runner.os == 'Linux'
71-
run: typos
71+
run: uv run typos
7272

7373
lint-builders:
7474
runs-on: ubuntu-22.04

.pre-commit-config.yaml

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -5,46 +5,46 @@ repos:
55
hooks:
66
- id: check-linting
77
name: check-linting
8-
entry: ruff check
8+
entry: uv run ruff check
99
language: python
1010
types: [file, python]
1111
stages: [pre-push]
1212
pass_filenames: false
1313
- id: check-formatting
1414
name: check-formatting
15-
entry: ruff format --check
15+
entry: uv run ruff format --check
1616
language: python
1717
types: [file, python]
1818
stages: [pre-push]
1919
pass_filenames: false
2020
- id: check-typing
2121
name: check-typing
22-
entry: mypy .
22+
entry: uv run mypy .
2323
language: python
2424
types: [file, python]
2525
stages: [pre-push]
2626
pass_filenames: false
27-
- id: poetry-check # `pyproject.toml` と `poetry.lock` が整合する
28-
name: poetry-check
29-
entry: poetry check
27+
- id: uv-check # `pyproject.toml` と `uv.lock` が整合する
28+
name: uv-check
29+
entry: uv lock --check
3030
language: python
3131
stages: [pre-push]
3232
pass_filenames: false
33-
- id: poetry-export
34-
name: poetry-export
35-
entry: poetry export --without-hashes -o requirements.txt
33+
- id: uv-export
34+
name: uv-export
35+
entry: uv export --no-annotate --no-hashes --no-header -o requirements.txt
3636
language: python
3737
stages: [pre-push]
3838
pass_filenames: false
39-
- id: poetry-export-dev
40-
name: poetry-export-dev
41-
entry: poetry export --without-hashes --with dev -o requirements-dev.txt
39+
- id: uv-export-dev
40+
name: uv-export-dev
41+
entry: uv export --group dev --no-annotate --no-hashes --no-header -o requirements-dev.txt
4242
language: python
4343
stages: [pre-push]
4444
pass_filenames: false
45-
- id: poetry-export-build
46-
name: poetry-export-build
47-
entry: poetry export --without-hashes --with build -o requirements-build.txt
45+
- id: uv-export-build
46+
name: uv-export-build
47+
entry: uv export --group build --no-annotate --no-hashes --no-header -o requirements-build.txt
4848
language: python
4949
stages: [pre-push]
5050
pass_filenames: false

0 commit comments

Comments
 (0)