Repository navigation
chore: 依赖与构建管理从 Poetry 迁移到 uv - #237
Open
Mono2023-PRC wants to merge 3 commits into
Open
Mono2023-PRC wants to merge 3 commits into
Mono2023-PRC wants to merge 3 commits into
Conversation
- pyproject.toml 改为 PEP 621 [project],^ 约束转为等价的 PEP 440 区间 - 依赖下限同步上游 dependabot 上浮(aiohttp/flask/brotli/requests/protobuf/grpcio/msgpack) - 镜像源 [[tool.poetry.source]] -> [[tool.uv.index]](default = true) - 构建后端 poetry-core -> hatchling,wheel/sdist 内容与原产物一致 - 删除 poetry.lock,新增 uv.lock - CI: setup-uv + uv sync/build/publish/version 替代 poetry 命令 - pyinstaller 改用 uv run --with pyinstaller(原先未在依赖中声明)
合入上游 5 个提交(版本 1.3.8、CommandOutput DataSet 修复、CI 修复): - c3ac456 fix: CommandOutput 数据包 DataSet 丢失 - 4d41194 / da282c7 版本 1.3.8 - 19404de fix(ci): 阿里云镜像推送关闭 provenance - e7fc199 fix(ci): 打包前安装 PyInstaller 冲突解决(.github/workflows/build_and_release.yml): 保留本地 uv 迁移(uv sync --frozen 替代 poetry install), 并按上游意图将 PyInstaller 固定为 6.22.3(uv run --with pyinstaller==6.22.3), 不再保留 poetry 命令。
迁移到 hatchling 后 wheel 与 sdist 的文件列表和 Poetry 产物一致, 但 METADATA 少了两项由 poetry-core 自动派生的内容: - 自动生成的 Python 版本 classifiers(3 / 3.10 / 3.11 / 3.12) 会在 PyPI 页面和 requires-python 过滤中丢失,显式声明 - 其余差异仅为 PURL 规范化的书写顺序(>=x,<y 写法),语义等价 已在本地对比 poetry-core 与 hatchling 两份构建产物验证。
Contributor
|
|
Overall Grade |
Security Reliability Complexity Hygiene |
Code Review Summary
| Analyzer | Status | Updated (UTC) | Details |
|---|---|---|---|
| Python | Nov 17, 2026 7:51a.m. | Review ↗ | |
| Shell | Nov 17, 2026 7:51a.m. | Review ↗ | |
| Docker | Nov 17, 2026 7:51a.m. | Review ↗ |
Important
AI Review is run only on demand for your team. We're only showing results of static analysis review right now. To trigger AI Review, comment @deepsourcebot review on this thread.
Member
|
好像没见显式添加pip,因为uv的Python不带pip,可能会导致pip相关库无法使用 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
动机
当前依赖管理依赖 Poetry:CI 每个 job 都要先装 Poetry、再用 poetry 命令跑 sync/install/build/publish,且
[tool.poetry]是历史 schema,正在与 PEP 621 收敛。改用 uv 后:
astral-sh/setup-uv),job 更短、缓存更可靠;pyproject.toml回到标准的[project]表,任何 PEP 621 工具(pip / hatchling / dependabot / pyright)都能直接读;uv.lock是跨平台的通用锁文件,uv sync --frozen的解析结果与uv lock一致。变更内容
依赖声明
[tool.poetry]→ PEP 621[project];^x.y.z逐一转换为等价的>=x.y.z,<x+1.0.0区间(websockets保持^12.0→>=12.0,<13.0的语义,pyspeedtest/pyyaml仍是精确 pin)。[[tool.poetry.source]](priority = "primary")→[[tool.uv.index]](default = true),仍指向阿里云 mirrors。构建后端
poetry-core→hatchling。tooldelta包;sdist 只含tooldelta、README.md、LICENSE。锁文件
poetry.lock,新增uv.lock(44 个包,含平台条件标记)。CI
.github/workflows/build_and_release.yml、publish_python_package.yml、check_pyproject_and_lock_file.yml:poetry install/poetry build/poetry publish/poetry version全部替换为uv sync --frozen/uv build/uv publish/uv version --no-sync。uv run --with pyinstaller==6.22.3(版本与上游 e7fc199 的固定值一致)。.gitlab-ci.yml:依赖扫描目标从poetry.lock改为uv.lock,镜像源变量注释改为UV_INDEX_URL。产物兼容性验证(本地实测)
在同一份代码上分别用 poetry-core(当前 main) 和 hatchling(本 PR) 构建,逐项对比:
Requires-Dist>=x,<yvs<y,>=x).gitignore(2.6 KB,hatchling 强制包含,不影响安装)py3-none-any,均无 console entry point另外:
uv lock --check通过(锁文件与pyproject.toml一致)。sync_version.yml只sed改tooldelta/version.py,未使用 Poetry;publish_python_package.yml用uv version --no-sync $(cat version)写入version文件的值,与原poetry version行为等价。Dockerfile用的是pip install .,在 hatchling 后端下行为不变。需要留意
setup-uv覆盖,本地开发者需要uv sync代替poetry install。这属于迁移的必然成本,PR 里没有额外文档,如果希望我补一段README/贡献说明可以再提。upstream/main(含1.3.8版本号与e7fc199),所以本 PR 的 diff 只包含迁移本身,不含那些上游提交。pipecosystem:它能读 PEP 621 的pyproject.toml,但不会维护uv.lock;若要连锁文件一起升级,建议改用uvecosystem。