Skip to content

Commit d6bc430

Browse files
authored
🧑‍💻 Dev: 迁移使用 uv 管理项目依赖 (#3607)
1 parent c45f956 commit d6bc430

File tree

28 files changed

+3433
-9944
lines changed

28 files changed

+3433
-9944
lines changed

.devcontainer/devcontainer.json

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,10 @@
11
{
2-
"name": "Default Linux Universal",
3-
"image": "mcr.microsoft.com/devcontainers/universal:2-linux",
2+
"name": "Ubuntu",
3+
"image": "mcr.microsoft.com/devcontainers/base:ubuntu",
44
"features": {
5-
"ghcr.io/devcontainers-extra/features/poetry:2": {}
5+
"ghcr.io/jsburckhardt/devcontainer-features/uv:1": {},
6+
"ghcr.io/devcontainers/features/node:1": {},
7+
"ghcr.io/meaningful-ooo/devcontainer-features/fish:2": {}
68
},
79
"postCreateCommand": "./scripts/setup-envs.sh",
810
"customizations": {

.github/actions/build-api-doc/action.yml

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,5 @@ runs:
55
using: "composite"
66
steps:
77
- run: |
8-
poetry run nb-autodoc nonebot \
9-
-s nonebot.plugins \
10-
-u nonebot.internal \
11-
-u nonebot.internal.*
12-
cp -r ./build/nonebot/* ./website/docs/api/
13-
yarn prettier
8+
uv run --no-sync bash ./scripts/build-api-docs.sh
149
shell: bash

.github/actions/setup-python/action.yml

Lines changed: 7 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -5,36 +5,20 @@ inputs:
55
python-version:
66
description: Python version
77
required: false
8-
default: "3.10"
9-
env-dir:
10-
description: Environment directory
8+
default: "3.12"
9+
env-group:
10+
description: Environment group
1111
required: false
12-
default: "."
13-
no-root:
14-
description: Do not install package in the environment
15-
required: false
16-
default: "false"
12+
default: "pydantic-v2"
1713

1814
runs:
1915
using: "composite"
2016
steps:
21-
- name: Install poetry
22-
run: pipx install poetry
23-
shell: bash
24-
25-
- uses: actions/setup-python@v5
17+
- uses: astral-sh/setup-uv@v6
2618
with:
2719
python-version: ${{ inputs.python-version }}
28-
cache: "poetry"
29-
cache-dependency-path: |
30-
./poetry.lock
31-
${{ inputs.env-dir }}/poetry.lock
20+
cache-suffix: ${{ inputs.env-group }}
3221

3322
- run: |
34-
cd ${{ inputs.env-dir }}
35-
if [ "${{ inputs.no-root }}" = "true" ]; then
36-
poetry install --all-extras --no-root
37-
else
38-
poetry install --all-extras
39-
fi
23+
uv sync --all-extras --locked --group ${{ inputs.env-group }}
4024
shell: bash

.github/workflows/codecov.yml

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ on:
1313
- ".github/actions/setup-python/**"
1414
- ".github/workflows/codecov.yml"
1515
- "pyproject.toml"
16-
- "poetry.lock"
16+
- "uv.lock"
1717

1818
jobs:
1919
test:
@@ -40,13 +40,11 @@ jobs:
4040
uses: ./.github/actions/setup-python
4141
with:
4242
python-version: ${{ matrix.python-version }}
43-
env-dir: ./envs/${{ matrix.env }}
44-
no-root: true
43+
env-group: ${{ matrix.env }}
4544

4645
- name: Run Pytest
4746
run: |
48-
cd ./envs/${{ matrix.env }}
49-
poetry run bash "../../scripts/run-tests.sh"
47+
uv run --no-sync bash ./scripts/run-tests.sh
5048
5149
- name: Upload test results
5250
uses: codecov/test-results-action@v1

.github/workflows/pyright.yml

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ on:
1313
- ".github/actions/setup-python/**"
1414
- ".github/workflows/pyright.yml"
1515
- "pyproject.toml"
16-
- "poetry.lock"
16+
- "uv.lock"
1717

1818
jobs:
1919
pyright:
@@ -33,11 +33,10 @@ jobs:
3333
- name: Setup Python environment
3434
uses: ./.github/actions/setup-python
3535
with:
36-
env-dir: ./envs/${{ matrix.env }}
37-
no-root: true
36+
env-group: ${{ matrix.env }}
3837

3938
- run: |
40-
(cd ./envs/${{ matrix.env }} && echo "$(poetry env info --path)/bin" >> $GITHUB_PATH)
39+
echo "$(dirname $(uv python find))" >> $GITHUB_PATH
4140
if [ "${{ matrix.env }}" = "pydantic-v1" ]; then
4241
sed -i 's/PYDANTIC_V2 = true/PYDANTIC_V2 = false/g' ./pyproject.toml
4342
fi

.github/workflows/release-drafter.yml

Lines changed: 6 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,7 @@ jobs:
8484
- name: Get Version
8585
id: version
8686
run: |
87-
echo "VERSION=$(poetry version -s)" >> $GITHUB_OUTPUT
87+
echo "VERSION=$(uv version --short)" >> $GITHUB_OUTPUT
8888
echo "TAG_VERSION=${GITHUB_REF#refs/tags/v}" >> $GITHUB_OUTPUT
8989
echo "TAG_NAME=${GITHUB_REF#refs/tags/}" >> $GITHUB_OUTPUT
9090
@@ -102,10 +102,8 @@ jobs:
102102

103103
- name: Build Package
104104
run: |
105-
poetry build
106-
107-
- name: Publish package to PyPI
108-
uses: pypa/gh-action-pypi-publish@release/v1
105+
uv build
106+
uv publish
109107
110108
- name: Publish package to GitHub
111109
run: |
@@ -117,13 +115,9 @@ jobs:
117115
run: |
118116
yarn build:plugin --out-dir ../packages/nonebot-plugin-docs/nonebot_plugin_docs/dist
119117
cd packages/nonebot-plugin-docs/
120-
poetry version ${{ steps.version.outputs.VERSION }}
121-
poetry build
122-
123-
- name: Publish Doc Package to PyPI
124-
uses: pypa/gh-action-pypi-publish@release/v1
125-
with:
126-
packages-dir: packages/nonebot-plugin-docs/dist/
118+
uv version ${{ steps.version.outputs.VERSION }}
119+
uv build
120+
uv publish
127121
128122
- name: Publish Doc Package to GitHub
129123
run: |

.github/workflows/release.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ jobs:
2727
- name: Build API Doc
2828
uses: ./.github/actions/build-api-doc
2929

30-
- run: echo "TAG_NAME=v$(poetry version -s)" >> $GITHUB_ENV
30+
- run: echo "TAG_NAME=v$(uv version --short)" >> $GITHUB_ENV
3131

3232
- name: Archive Changelog
3333
uses: docker://ghcr.io/nonebot/auto-changelog:master
@@ -39,14 +39,14 @@ jobs:
3939

4040
- name: Archive Files
4141
run: |
42-
yarn archive $(poetry version -s)
42+
yarn archive $(uv version --short)
4343
yarn prettier
4444
4545
- name: Push Tag
4646
run: |
4747
git config user.name noneflow[bot]
4848
git config user.email 129742071+noneflow[bot]@users.noreply.github.com
4949
git add .
50-
git commit -m ":bookmark: Release $(poetry version -s)"
50+
git commit -m ":bookmark: Release $(uv version --short)"
5151
git tag ${{ env.TAG_NAME }}
5252
git push && git push --tags

.github/workflows/ruff.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ on:
1313
- ".github/actions/setup-python/**"
1414
- ".github/workflows/ruff.yml"
1515
- "pyproject.toml"
16-
- "poetry.lock"
16+
- "uv.lock"
1717

1818
jobs:
1919
ruff:

CONTRIBUTING.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -18,15 +18,15 @@
1818

1919
## Pull Request
2020

21-
NoneBot 使用 [poetry](https://python-poetry.org/) 管理项目依赖,由于 pre-commit 也经其管理,所以在此一并说明。
21+
NoneBot 使用 [uv](https://docs.astral.sh/uv/) 管理项目依赖,由于 pre-commit 也经其管理,所以在此一并说明。
2222

23-
下面的命令能在已安装 poetry 和 yarn 的情况下帮你快速配置开发环境。
23+
下面的命令能在已安装 uv 和 yarn 的情况下帮你快速配置开发环境。
2424

2525
```bash
2626
# 安装 python 依赖
27-
poetry install
27+
uv sync --all-extras
2828
# 安装 pre-commit git hook
29-
pre-commit install
29+
uv run pre-commit install
3030
```
3131

3232
### 使用 GitHub Codespaces(Dev Container)

0 commit comments

Comments
 (0)