Skip to content

Commit

Permalink
chore: 使用 uv 来管理项目 (#165)
Browse files Browse the repository at this point in the history
* chore: 使用 uv 来管理项目

* fix: 应该为 uv run poe test

* fix: 升级 tarina
  • Loading branch information
he0119 authored Oct 14, 2024
1 parent 9c1ab3f commit cfb3610
Show file tree
Hide file tree
Showing 7 changed files with 2,336 additions and 476 deletions.
12 changes: 6 additions & 6 deletions .github/workflows/codecov.yml
Original file line number Diff line number Diff line change
Expand Up @@ -33,19 +33,19 @@ jobs:
timezoneMacos: "Asia/Shanghai"
timezoneWindows: "China Standard Time"

- name: Setup rye
uses: eifinger/setup-rye@a64bd427414a77fd506d9a85a590ab36d71cf86a
- name: Setup uv
uses: astral-sh/setup-uv@v3
with:
enable-cache: true
cache-prefix: ${{ env.PYTHON_VERSION }}
cache-suffix: ${{ env.PYTHON_VERSION }}

- name: Install prerequisites
run: |
rye pin ${{ env.PYTHON_VERSION }}
rye sync
uv python pin ${{ env.PYTHON_VERSION }}
uv sync
- name: Run tests
run: rye run test
run: uv run poe test

- name: Upload coverage to Codecov
uses: codecov/codecov-action@v4
Expand Down
10 changes: 5 additions & 5 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,18 +17,18 @@ jobs:
- name: Checkout
uses: actions/checkout@v4

- name: Setup rye
uses: eifinger/setup-rye@a64bd427414a77fd506d9a85a590ab36d71cf86a
- name: Setup uv
uses: astral-sh/setup-uv@v3
with:
enable-cache: true

- name: Install prerequisites
run: rye sync
run: uv sync

- name: Get Version
id: version
run: |
echo "VERSION=$(rye version)" >> $GITHUB_OUTPUT
echo "VERSION=$(uv tree -d0 | grep -oP 'v\K[0-9]+\.[0-9]+\.[0-9]+')" >> $GITHUB_OUTPUT
echo "TAG_VERSION=${GITHUB_REF#refs/tags/v}" >> $GITHUB_OUTPUT
echo "TAG_NAME=${GITHUB_REF#refs/tags/}" >> $GITHUB_OUTPUT
Expand All @@ -37,7 +37,7 @@ jobs:
run: exit 1

- name: Build
run: rye build
run: uv build

- name: Publish a Python distribution to PyPI
uses: pypa/gh-action-pypi-publish@release/v1
Expand Down
2 changes: 1 addition & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/lang/zh-CN/

- 可以使用的版本。

[unreleased]: https://github.com/he0119/nonebot-plugin-user/compare/v0.4.3...HEAD
[Unreleased]: https://github.com/he0119/nonebot-plugin-user/compare/v0.4.3...HEAD
[0.4.3]: https://github.com/he0119/nonebot-plugin-user/compare/v0.4.2...v0.4.3
[0.4.2]: https://github.com/he0119/nonebot-plugin-user/compare/v0.4.1...v0.4.2
[0.4.1]: https://github.com/he0119/nonebot-plugin-user/compare/v0.4.0...v0.4.1
Expand Down
260 changes: 131 additions & 129 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,129 +1,131 @@
[project]
name = "nonebot-plugin-user"
version = "0.4.3"
description = "适用于 Nonebot2 的用户插件"
authors = [{ name = "uy_sun", email = "hmy0119@gmail.com" }]
dependencies = [
"nonebot2>=2.2.0",
"nonebot-plugin-orm>=0.7.0",
"nonebot-plugin-alconna>=0.37.1",
"nonebot-plugin-session>=0.3.0",
"expiringdictx>=1.1.0",
]
readme = "README.md"
license = { file = "LICENSE" }
requires-python = ">= 3.9"

[project.urls]
Homepage = "https://github.com/he0119/nonebot-plugin-user"
Repository = "https://github.com/he0119/nonebot-plugin-user.git"
Issues = "https://github.com/he0119/nonebot-plugin-user/issues"
Changelog = "https://github.com/he0119/nonebot-plugin-user/blob/main/CHANGELOG.md"

[build-system]
requires = ["hatchling"]
build-backend = "hatchling.build"

[tool.hatch.metadata]
allow-direct-references = true

[tool.hatch.build.targets.wheel]
packages = ["nonebot_plugin_user"]

[tool.hatch.build.targets.sdist]
only-include = ["nonebot_plugin_user"]

[tool.rye]
managed = true
universal = true
dev-dependencies = [
"nonebug>=0.3.7",
"pytest-cov>=5.0.0",
"pytest-xdist>=3.6.1",
"pytest-mock>=3.14.0",
"pytest-asyncio>=0.23.7",
"freezegun>=1.5.1",
"nonebot2[fastapi,httpx,websockets]>=2.3.2",
"nonebot-plugin-orm[default]>=0.7.4",
"nonebot-adapter-onebot>=2.4.4",
"nonebot-adapter-qq>=1.4.4",
"nonebot-adapter-satori>=0.12.3",
"bump-my-version==0.24.3",
]

[tool.rye.scripts]
test = "pytest --cov=nonebot_plugin_user --cov-report xml -n auto"
bump = "bump-my-version bump"
show-bump = "bump-my-version show-bump"

[tool.pyright]
pythonVersion = "3.9"
pythonPlatform = "All"
typeCheckingMode = "standard"
defineConstant = { PYDANTIC_V2 = true }

[tool.ruff]
line-length = 88
target-version = "py39"

[tool.ruff.lint]
select = [
"W", # pycodestyle warnings
"E", # pycodestyle errors
"F", # pyflakes
"UP", # pyupgrade
"C4", # flake8-comprehensions
"T10", # flake8-debugger
"T20", # flake8-print
"PYI", # flake8-pyi
"PT", # flake8-pytest-style
"Q", # flake8-quotes
]
ignore = [
"E402", # module-import-not-at-top-of-file
]

[tool.nonebot]
adapters = [
{ name = "OneBot V11", module_name = "nonebot.adapters.onebot.v11" },
{ name = "OneBot V12", module_name = "nonebot.adapters.onebot.v12" },
{ name = "QQ", module_name = "nonebot.adapters.qq" },
{ name = "Satori", module_name = "nonebot.adapters.satori" },
]
plugins = ["nonebot_plugin_user"]

[tool.coverage.report]
exclude_lines = [
"pragma: no cover",
"raise NotImplementedError",
"if __name__ == .__main__.:",
"if TYPE_CHECKING:",
"@overload",
"except ImportError:",
]
omit = ["*/migrations/*"]

[tool.pytest.ini_options]
addopts = ["--import-mode=importlib"]
asyncio_mode = "auto"

[tool.bumpversion]
current_version = "0.4.3"
commit = true
message = "chore(release): {new_version}"

[[tool.bumpversion.files]]
filename = "pyproject.toml"
search = "version = \"{current_version}\""
replace = "version = \"{new_version}\""

[[tool.bumpversion.files]]
filename = "CHANGELOG.md"
search = "[Unreleased]"
replace = "[Unreleased]\n\n## [{new_version}] - {now:%Y-%m-%d}"

[[tool.bumpversion.files]]
filename = "CHANGELOG.md"
regex = true
search = "\\[unreleased\\]: (https://.+?)v{current_version}\\.\\.\\.HEAD"
replace = "[unreleased]: \\1v{new_version}...HEAD\n[{new_version}]: \\1v{current_version}...v{new_version}"
[project]
name = "nonebot-plugin-user"
version = "0.4.3"
description = "适用于 Nonebot2 的用户插件"
authors = [{ name = "uy_sun", email = "hmy0119@gmail.com" }]
readme = "README.md"
license = { file = "LICENSE" }
requires-python = ">= 3.9"
dependencies = [
"nonebot2>=2.2.0",
"nonebot-plugin-orm>=0.7.0",
"nonebot-plugin-alconna>=0.37.1",
"nonebot-plugin-session>=0.3.0",
"expiringdictx>=1.1.0",
]

[project.urls]
Homepage = "https://github.com/he0119/nonebot-plugin-user"
Repository = "https://github.com/he0119/nonebot-plugin-user.git"
Issues = "https://github.com/he0119/nonebot-plugin-user/issues"
Changelog = "https://github.com/he0119/nonebot-plugin-user/blob/main/CHANGELOG.md"

[build-system]
requires = ["hatchling"]
build-backend = "hatchling.build"

[tool.hatch.metadata]
allow-direct-references = true

[tool.hatch.build.targets.wheel]
packages = ["nonebot_plugin_user"]

[tool.hatch.build.targets.sdist]
only-include = ["nonebot_plugin_user"]

[tool.uv]
dev-dependencies = [
"nonebug>=0.3.7",
"pytest-cov>=5.0.0",
"pytest-xdist>=3.6.1",
"pytest-mock>=3.14.0",
"pytest-asyncio>=0.23.7",
"freezegun>=1.5.1",
"nonebot2[fastapi,httpx,websockets]>=2.3.2",
"nonebot-plugin-orm[default]>=0.7.4",
"nonebot-adapter-onebot>=2.4.4",
"nonebot-adapter-qq>=1.4.4",
"nonebot-adapter-satori>=0.12.3",
"bump-my-version==0.24.3",
"poethepoet>=0.29.0",
]

[tool.uv.pip]
universal = true

[tool.poe.tasks]
test = "pytest --cov=nonebot_plugin_user --cov-report xml -n auto"
bump = "bump-my-version bump"
show-bump = "bump-my-version show-bump"

[tool.pyright]
pythonVersion = "3.9"
pythonPlatform = "All"
typeCheckingMode = "standard"
defineConstant = { PYDANTIC_V2 = true }

[tool.ruff]
line-length = 88
target-version = "py39"

[tool.ruff.lint]
select = [
"W", # pycodestyle warnings
"E", # pycodestyle errors
"F", # pyflakes
"UP", # pyupgrade
"C4", # flake8-comprehensions
"T10", # flake8-debugger
"T20", # flake8-print
"PYI", # flake8-pyi
"PT", # flake8-pytest-style
"Q", # flake8-quotes
]
ignore = [
"E402", # module-import-not-at-top-of-file
]

[tool.nonebot]
adapters = [
{ name = "OneBot V11", module_name = "nonebot.adapters.onebot.v11" },
{ name = "OneBot V12", module_name = "nonebot.adapters.onebot.v12" },
{ name = "QQ", module_name = "nonebot.adapters.qq" },
{ name = "Satori", module_name = "nonebot.adapters.satori" },
]
plugins = ["nonebot_plugin_user"]

[tool.coverage.report]
exclude_lines = [
"pragma: no cover",
"raise NotImplementedError",
"if __name__ == .__main__.:",
"if TYPE_CHECKING:",
"@overload",
"except ImportError:",
]
omit = ["*/migrations/*"]

[tool.pytest.ini_options]
addopts = ["--import-mode=importlib"]
asyncio_mode = "auto"

[tool.bumpversion]
current_version = "0.4.3"
commit = true
message = "chore(release): {new_version}"

[[tool.bumpversion.files]]
filename = "pyproject.toml"
search = "version = \"{current_version}\""
replace = "version = \"{new_version}\""

[[tool.bumpversion.files]]
filename = "CHANGELOG.md"
search = "## [Unreleased]"
replace = "## [Unreleased]\n\n## [{new_version}] - {now:%Y-%m-%d}"

[[tool.bumpversion.files]]
filename = "CHANGELOG.md"
regex = true
search = "\\[Unreleased\\]: (https://.+?)v{current_version}\\.\\.\\.HEAD"
replace = "[Unreleased]: \\1v{new_version}...HEAD\n[{new_version}]: \\1v{current_version}...v{new_version}"
Loading

0 comments on commit cfb3610

Please sign in to comment.