实用指南:使用pdm+uv替换poetry

news/2025/10/22 15:31:10/文章来源:https://www.cnblogs.com/tlnshuju/p/19158142

实用指南:使用pdm+uv替换poetry

2025-10-22 15:28  tlnshuju  阅读(0)  评论(0)    收藏  举报

用了好几年poetry了,各方面都还挺满意,就是lock实在太慢;

已经试用pdm+uv一段时间了,确实是快,也基本能覆盖poetry的功能。

至于为什么用pdm+uv,而不是只用uv,原因很多,有兴趣的可以去看这个https://github.com/pdm-project/pdm/discussions/3388

1. 安装pdm、uv并换源

pip install --user --upgrade pipxpipx install pdm uvpdm config pypi.url https://mirrors.cloud.tencent.com/pypi/simple/mkdir -p ~/.config/uv && echo -e '[[index]]\nurl="https://pypi.tuna.tsinghua.edu.cn/simple/"\ndefault = true' > ~/.config/uv/uv.toml

 2. 配置pdm全局使用uv

pdm config use_uv true

注:对于个别不想使用uv加速的项目,可以单独这样配置:pdm config --local use_uv true

3. 迁移poetry的pyproject.toml到pdm

- Old

[project]name = "asynctor"description = "Async functions to compare with anyio and asyncio, and toolkit to read excel with async/await."authors = [{ name = "Waket Zheng", email = "waketzheng@gmail.com" }]readme = "README.md"license = { text = "MIT" }requires-python = ">=3.9"dynamic = [ "version" ]dependencies = [    "anyio>=3.7.1",    "eval-type-backport (>=0.2.2,= 1.0.2; python_version = 4.1; python_version =2.2.0", "openpyxl>=3.1.0"]fastapi = ["redis", "fastapi>=0.115.0", "httpx>=0.28.1", "asgi-lifespan>=2.1.0"]redis = ["redis>=5.0.0"] [project.urls]homepage = "https://github.com/waketzheng/asynctor"repository = "https://github.com/waketzheng/asynctor.git""Bug Tracker" = "https://github.com/waketzheng/asynctor/issues" [tool.poetry]version = "0"  # Managed by poetry-plugin-version [tool.poetry.group.dev.dependencies]fast-dev-cli = "^0.15.1"types-redis = "^4.6.0.20241004"pandas-stubs = {version=">=2.2.0", python="^3.10"}bandit = "^1.8.3"pytest-mock = "^3.14.1"fastapi-cdn-host = "^0.9.1"uvicorn = "^0.34.3" [tool.poetry.group.ci.dependencies]coveralls = {git = "https://github.com/waketzheng/coveralls-python", rev = "4.1.1", python="^3.9"} [tool.ruff]line-length = 100 [tool.ruff.lint]extend-select = [    "E",  # pycodestyle errors    "W",  # pycodestyle warnings    "F",  # pyflakes    "I",  # isort    "B",  # flake8-bugbear    "C4", # flake8-comprehensions    "UP", # https://docs.astral.sh/ruff/rules/#pyupgrade-up] [tool.ruff.lint.per-file-ignores]"test_*.py" = ["E501"]"scripts/test.py" = ["E501"]"scripts/*.py" = ["UP009","UP032"] [tool.mypy]pretty = truepython_version = "3.9"ignore_missing_imports = truecheck_untyped_defs = true [tool.coverage.report]omit = ["*/tests/*", "test_*"]exclude_lines = [    "pragma: no cover",    "@overload",    'if __name__ == "__main__":',    "if TYPE_CHECKING:",] [build-system]requires = ["poetry-plugin-version"]build-backend = "poetry_plugin_version.api"

- Diff

-[tool.poetry]-version = "0"  # Managed by poetry-plugin-version+[tool.pdm]+version = {source="file", path="asynctor/__init__.py"} -[tool.poetry.group.dev.dependencies]-fast-dev-cli = "^0.15.0"-types-redis = "^4.6.0.20241004"-pandas-stubs = {version=">=2.2.0", python="^3.10"}-bandit = "^1.8.3"-pytest-mock = "^3.14.0"-fastapi-cdn-host = "^0.9.1"-uvicorn = "^0.34.2"--[tool.poetry.group.ci.dependencies]-coveralls = {git = "https://github.com/waketzheng/coveralls-python", rev = "4.1.1", python="^3.9"}+[dependency-groups]+dev = [+    "fast-dev-cli>=0.15.1",+    "types-redis>=4.6.0.20241004",+    "pandas-stubs",+    "bandit>=1.8.3",+    "pytest-mock>=3.14.1",+    "fastapi-cdn-host>=0.9.1",+    "uvicorn>=0.34.3",+]+ci = ["coveralls @ git+https://github.com/waketzheng/coveralls-python@4.1.1"]  [build-system]-requires = ["poetry-plugin-version"]-build-backend = "poetry_plugin_version.api"+requires = ["pdm-backend"]+build-backend = "pdm.backend"

- New

[project]name = "asynctor"description = "Async functions to compare with anyio and asyncio, and toolkit to read excel with async/await."authors = [{ name = "Waket Zheng", email = "waketzheng@gmail.com" }]readme = "README.md"license = { text = "MIT" }requires-python = ">=3.9"dynamic = [ "version" ]dependencies = [    "anyio>=3.7.1",    "eval-type-backport (>=0.2.2,= 1.0.2; python_version = 4.1; python_version =2.2.0", "openpyxl>=3.1.0"]fastapi = ["redis", "fastapi>=0.115.0", "httpx>=0.28.1", "asgi-lifespan>=2.1.0"]redis = ["redis>=5.0.0"] [project.urls]homepage = "https://github.com/waketzheng/asynctor"repository = "https://github.com/waketzheng/asynctor.git""Bug Tracker" = "https://github.com/waketzheng/asynctor/issues" [tool.pdm]version = {source="file", path="asynctor/__init__.py"} [dependency-groups]dev = [    "fast-dev-cli>=0.15.1",    "types-redis>=4.6.0.20241004",    "pandas-stubs",    "bandit>=1.8.3",    "pytest-mock>=3.14.1",    "fastapi-cdn-host>=0.9.1",    "uvicorn>=0.34.3",]ci = ["coveralls @ git+https://github.com/waketzheng/coveralls-python@4.1.1"] [tool.ruff]line-length = 100 [tool.ruff.lint]extend-select = [    "E",  # pycodestyle errors    "W",  # pycodestyle warnings    "F",  # pyflakes    "I",  # isort    "B",  # flake8-bugbear    "C4", # flake8-comprehensions    "UP", # https://docs.astral.sh/ruff/rules/#pyupgrade-up] [tool.ruff.lint.per-file-ignores]"test_*.py" = ["E501"]"scripts/test.py" = ["E501"]"scripts/*.py" = ["UP009","UP032"] [tool.mypy]pretty = truepython_version = "3.9"ignore_missing_imports = truecheck_untyped_defs = true [tool.coverage.report]omit = ["*/tests/*", "test_*"]exclude_lines = [    "pragma: no cover",    "@overload",    'if __name__ == "__main__":',    "if TYPE_CHECKING:",] [build-system]requires = ["pdm-backend"]build-backend = "pdm.backend"

4. 修改Makefile为使用pdm

- diff

--- a/Makefile+++ b/Makefile@@ -11,17 +11,17 @@ help:        @echo  "    lint    Auto-formats the code and check type hints"  up:-       poetry run fast upgrade+       pdm run fast upgrade  deps:-       poetry install --all-extras+       pdm install --verbose --group :all --without=ci --frozen  _check:        ./scripts/check.py check: deps _build _check  _lint:-       poetry run fast lint+       pdm run fast lintlint: deps _build _lint  _test:@@ -33,7 +33,8 @@ _style: style: deps _style  _build:-       poetry build --clean+       rm -fR dist/+       pdm build build: deps _build  ci: check _build _test

5. 更新CI文件

--- a/.github/workflows/ci.yml+++ b/.github/workflows/ci.yml@@ -38,49 +38,26 @@ jobs:         with:           python-version: ${{ matrix.python-version }}           allow-prereleases: true-      - name: Load cached Poetry installation-        id: cached-poetry-        uses: actions/cache@v4+      - uses: actions/cache@v4+        id: cache         with:-          path: ~/.local  # the path depends on the OS-          key: poetry-0  # increment to reset cache-      - name: Install Poetry-        uses: snok/install-poetry@v1+          path: ~/.cache/pip+          key: ${{ runner.os }}-python-${{ env.pythonLocation }}-${{ hashFiles('**/pdm.lock') }}+      - name: Set up PDM+        uses: pdm-project/setup-pdm@v4         with:-          virtualenvs-in-project: true-          plugins: poetry-plugin-version-      - name: Load cached venv-        id: cached-poetry-dependencies-        uses: actions/cache@v4-        with:-          path: .venv-          key: venv-${{ runner.os }}-${{ steps.setup-python.outputs.python-version }}-${{ hashFiles('**/poetry.lock') }}-      #-----------------------------------------------      # install dependencies if cache does not exist-      #-----------------------------------------------      - name: Install dependencies-        if: steps.cached-poetry-dependencies.outputs.cache-hit != 'true'-        run: poetry install --no-interaction --no-root --all-extras --all-groups-        env:-          PYO3_USE_ABI3_FORWARD_COMPATIBILITY: 1-      #-----------------------------------------------      # install your root project, if package-mode is true-      #-----------------------------------------------      - name: Install library-        run: poetry install --no-interaction+          python-version: ${{ matrix.python-version }}       - uses: astral-sh/ruff-action@v3-      - name: Check code style and Type Hint-        run: ./scripts/check.py-      - name: build-        run: poetry build-      - name: Test with pytest-        run: poetry run fast test+      - name: Check code style and Type Hint then Test with pytest+        run: make ci         env:           # The hostname used to communicate with the Redis service container           REDIS_HOST: localhost+      - name: Install library+        run: pdm sync -d -G :all       - name: Upload Coverage         run: |-          poetry run coveralls --service=github+          pdm run coveralls --service=github         env:           GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处:http://www.mzph.cn/news/943419.shtml

如若内容造成侵权/违法违规/事实不符,请联系多彩编程网进行投诉反馈email:809451989@qq.com,一经查实,立即删除!

相关文章

2025 年 PPT 生成工具品牌最新推荐榜单:AI 备案技术加持 + 千万用户信赖,优质工具全方位测评ppt一键生成/自动生成ppt/ppt制作ai工具推荐

引言 在数字化办公深度渗透的当下,PPT 已成为职场汇报、企业宣传、学术展示等场景的核心载体,但其制作过程中的痛点却愈发凸显。传统制作方式不仅耗时久、设计门槛高,非专业人士难以产出高质量文稿,还常因素材版权…

04-I2C-铁头山羊STM32标准库新版笔记

一、基本电路结构二、通信协议三、I2C模块的使用方法main.c点击查看代码 #include "stm32f10x.h"void My_I2C_Init(void);int main(void) {My_I2C_Init();while(1){} }void My_I2C_Init(void) {// #1. IO引脚…

ALV 按钮置灰

当我们要将ALV的按钮置灰,而不是隐藏的时候需要在STATUS里面调整 代码: 效果:

2025 年二手中央空调公司最新推荐口碑排行榜:覆盖多场景需求,14000㎡厂房实力企业领衔,助您精准选靠谱商家多联机/柜机二手空调/二手新风/暖通设备公司推荐

引言 当下,商用与家用制冷需求持续攀升,二手中央空调因高性价比,成为餐馆、酒楼、宾馆、网吧及部分家庭的优选。但行业乱象频发,商家资质良莠不齐,不少商家缺乏专业技术团队,无法提供可靠的安装与维护服务;产品…

微算法科技(NASDAQ MLGO)创建企业级区块链双层共识算法:融合优化DPoS与动态BFT的协同机制设计

在企业级区块链应用场景中,传统共识机制面临效率与安全的双重瓶颈。公链场景下的DPoS机制虽通过节点选举提升了交易处理速度,但在许可链环境中易出现节点权力集中化问题;而BFT类算法虽能保证强一致性,却因复杂的通…

ubuntu24.04 server 版本安装xfce 使用web novnc 远程桌面

前提需要保证你的网络通畅,不然其中有git clone 过程你无法pull到代码,user改成你得user #!/bin/bash # ========================================================== # Auto deploy TigerVNC + noVNC on Ubuntu 24…

2025 国内西服定制品牌口碑榜:私人/西服/婚礼/高级/高端/高档/男士/女士/轻奢/企业团体职业/企业高管/商务/手工/休闲西服定制厂家推荐

在商务往来与重要场合中,一套合身的定制西服既是形象名片,也是品质生活的体现。随着定制需求从 “高端专属” 走向 “大众刚需”,市场上品牌良莠不齐,“不合身”“交付慢” 等问题频发。结合工艺精度、服务体验、口…

深入解析:大模型微调必学教程:从LOSS观测到模型合并导出与部署全流程

pre { white-space: pre !important; word-wrap: normal !important; overflow-x: auto !important; display: block !important; font-family: "Consolas", "Monaco", "Courier New", …

CKS-CN 考试知识点分享(14) Istio网络策略 - 实践

CKS-CN 考试知识点分享(14) Istio网络策略 - 实践pre { white-space: pre !important; word-wrap: normal !important; overflow-x: auto !important; display: block !important; font-family: "Consolas",…

题解:P14023 [ICPC 2024 Nanjing R] 社交媒体

简化题意 给你 \(k\) 个点以及 \(m\) 条边,其中有 \(n\) 个点已经被选择,问至多再选两个点后最多有多少条边的端点都被选了。 思路 我们可以把边分为 \(3\) 类:两个端点都被选择了,这时直接加入答案。 有一个端点被…

2025 全合成润滑油厂家企业推荐榜:进口润滑油/国产润滑油/国内润滑油/半合成润滑油厂家,技术与服务双驱发展

润滑油作为机械设备运行的核心辅助材料,渗透于工业生产与日常出行的各个角落。它不仅能减少部件摩擦、延缓磨损,更承担着冷却、密封、防锈等多重关键功能。从基础油的分类迭代到添加剂的精准配比,从传统矿物油到环保…

2025年10月叛逆青少年改造机构全景解析报告,基于专业测评的技术、性能及市场优势深度分析

随着社会对青少年心理健康关注度的不断提升,专业心理辅导机构在帮助青少年健康成长方面发挥着日益重要的作用。本文基于实地调研数据,从机构资质、师资配置、教育体系及服务成效等维度,对青少年心理辅导机构进行综合…

docker安装iotdb

1、运行命令docker run -d --name iotdb-2.0.5 --hostname=iotdb --restart always -p 6667:6667 --shm-size="1g" --privileged=true -e cn_internal_address=iotdb -e cn_internal_port=10710 -e cn_conse…

第一个 AI 应用

第一个 AI 应用 https://cloud.tencent.com/developer/article/1348205

《无垠的太空(8).提亚玛特之怒》电子书(1-9章)

《无垠的太空(8).提亚玛特之怒》电子书(1-9章)提亚玛特之怒(1-9章) 文件名:无垠的太空(8).提亚玛特之怒(1-9章) 地址:https://www.alipan.com/s/vEXVSnizQf2 提取码:vlc1 2025.10.22扩展阅读 《无垠的太空(1)…

2025年10月微高压氧舱厂家全景解析报告,基于专业测评的技术、性能及市场优势深度分析

随着健康管理意识的提升,微高压氧舱作为新兴健康设备,其技术性能与安全标准日益受到关注。根据行业调研数据显示,2024年国内微高压氧舱市场规模预计达到12.8亿元,年增长率保持在18.5% 左右。本文基于产品技术参数、…

Kubernetes应用微服务 - 指南

Kubernetes应用微服务 - 指南pre { white-space: pre !important; word-wrap: normal !important; overflow-x: auto !important; display: block !important; font-family: "Consolas", "Monaco"…

看板(Kanban)的使用

看板(Kanban)的使用场景主要包括项目管理和生产管理领域。看板是一种可视化管理工具,它可以用于以下场景:软件开发:在敏捷开发中,看板用于管理任务和进度。通过看板,团队成员可以清晰地看到项目的当前状态、待办…

161行的华容道程序

比吕震宇的慢多了,我的Intel N100上0.624s,他的兆芯KX-6640MA上0.314秒。写都写了,贴出来吧:#include <stdio.h> #include <stdint.h> #include <stdlib.h> #include <string.h> #include…

调用ack集群 api 接口删除Terminating状态的资源

调用ack集群 api 接口删除Terminating状态的资源背景:在特殊情况,会出现删除不掉资源的情况 1、导出json 文件资源 kubectl get namespace arms-prom -o json > temp.json 2、去掉finallizers 3、开启代理到api服务…