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

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

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

1. 安装pdm、uv并换源

pip install --user --upgrade pipx
pipx install pdm uv
pdm 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.0); python_version < '3.10'",
]
# requires by anyio:
#    "exceptiongroup >= 1.0.2; python_version < '3.11'",
#    "typing_extensions >= 4.1; python_version < '3.11'",[project.optional-dependencies]
xls = ["pandas>=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 = true
python_version = "3.9"
ignore_missing_imports = true
check_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.0); python_version < '3.10'",
]
# requires by anyio:
#    "exceptiongroup >= 1.0.2; python_version < '3.11'",
#    "typing_extensions >= 4.1; python_version < '3.11'",[project.optional-dependencies]
xls = ["pandas>=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 = true
python_version = "3.9"
ignore_missing_imports = true
check_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 upgradedeps:
-       poetry install --all-extras
+       pdm install --verbose --group :all --without=ci --frozen_check:./scripts/check.pycheck: deps _build _check_lint:
-       poetry run fast lint
+       pdm run fast lint
lint: deps _build _lint_test:
@@ -33,7 +33,8 @@ _style:style: deps _style_build:
-       poetry build --clean
+       rm -fR dist/
+       pdm buildbuild: deps _buildci: 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: cachewith:
-          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@v4with:
-          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 cienv:# The hostname used to communicate with the Redis service containerREDIS_HOST: localhost
+      - name: Install library
+        run: pdm sync -d -G :all- name: Upload Coveragerun: |
-          poetry run coveralls --service=github
+          pdm run coveralls --service=githubenv:GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

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

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

相关文章

java后端生成心电图-jfreechart

用jfreechart生成心电图 先上成功的图片 上代码 1.导入包 implementation org.jfree:jfreechart:1.5.4implementation org.jfree:jcommon:1.0.242.实现代码 对数据进行滤波 转换单位 package com.shinrun.infrastructure.util;import java.util.ArrayList; import java.ut…

微软Build 2025:Copilot Studio升级,解锁多智能体协作未来

微软Build 2025大会圆满落幕&#xff0c;作为年度科技盛会&#xff0c;它一直是开发与AI技术突破性创新的重要展示平台。对于工程师、创作者和领域专家来说&#xff0c;这是了解微软生态未来动向的关键时刻。今年&#xff0c;Microsoft Copilot Studio推出了一系列新功能&#…

LabVIEW杂草识别与精准喷洒

基于LabVIEW构建了一套集成机器视觉、智能决策与精准控制的农业杂草识别系统。通过高分辨率视觉传感器采集作物图像&#xff0c;利用 LabVIEW 的 NI Vision 模块实现图像颜色匹配与特征分析&#xff0c;结合 Arduino 兼容的工业级控制硬件&#xff0c;实现杂草定位与除草剂精准…

使用 Akamai 分布式云与 CDN 保障视频供稿传输安全

作者简介&#xff1a;David Eisenbacher 是 EZDRM 公司的首席执行官兼联合创始人&#xff0c;该公司是首家提供 "DRM 即服务" 的企业。作为 CEO&#xff0c;David 始终秉持为企业确立的使命&#xff1a;为视频服务商提供简洁有效的数字版权管理方案&#xff0c;助力其…

javascript 实战案例 二级联动下拉选框

本案例完全使用原生javascript实现&#xff0c;使用时只需填充platform_list二维数组即可&#xff0c;platform_list填充规则如下&#xff1a; [‘一级选项1’,‘二级选项11’,‘二级选项12’,‘二级选项13’,‘二级选项14’,…], [‘一级选项2’,‘二级选项21’,‘二级选项22’…

Elasticsearch集群最大分片数设置详解:从问题到解决方案

目录 前言 1 问题背景&#xff1a;重启后设置失效 2 核心概念解析 2.1 什么是分片(Shard)&#xff1f; 2.2 cluster.max_shards_per_node的作用 2.3 默认值是多少&#xff1f; 3 参数设置的两种方式 3.2 持久性设置(persistent) 3.2 临时设置(transient) 4 问题解决方…

Redis Sorted Set 深度解析:从原理到实战应用

Redis Sorted Set 深度解析&#xff1a;从原理到实战应用 在 Redis 丰富的数据结构家族中&#xff0c;Sorted Set&#xff08;有序集合&#xff09;凭借独特的设计和强大的功能&#xff0c;成为处理有序数据场景的得力工具。无论是构建实时排行榜&#xff0c;还是实现基于时间的…

Java并发编程:读写锁与普通互斥锁的深度对比

在Java并发编程中&#xff0c;锁是实现线程安全的重要工具。其中&#xff0c;普通互斥锁&#xff08;如synchronized和ReentrantLock&#xff09;和读写锁&#xff08;ReentrantReadWriteLock&#xff09;是两种常用的同步机制。本文将从多个维度深入分析它们的区别、适用场景及…

《云原生安全攻防》-- K8s网络策略:通过NetworkPolicy实现微隔离

默认情况下&#xff0c;K8s集群的网络是没有任何限制的&#xff0c;所有的Pod之间都可以相互访问。这就意味着&#xff0c;一旦攻击者入侵了某个Pod&#xff0c;就能够访问到集群中任意Pod&#xff0c;存在比较大的安全风险。 在本节课程中&#xff0c;我们将详细介绍如何通过N…

Log4j2、Fastjson特征流量分析

文章目录 一、Log4j2流量特征分析1. 漏洞原理简述2. 核心流量特征&#xff08;1&#xff09;请求特征&#xff08;2&#xff09;响应特征&#xff08;3&#xff09;日志特征 3.检测与防御建议 二、fastjson流量特征分析1.漏洞原理简述2.核心流量特征&#xff08;1&#xff09;请…

Java编程之建造者模式

建造者模式&#xff08;Builder Pattern&#xff09;是一种创建型设计模式&#xff0c;它将一个复杂对象的构建与表示分离&#xff0c;使得同样的构建过程可以创建不同的表示。这种模式允许你分步骤构建一个复杂对象&#xff0c;并且可以在构建过程中进行不同的配置。 模式的核…

Spring AI之RAG入门

目录 1. 什么是RAG 2. RAG典型应用场景 3. RAG核心流程 3.1. 检索阶段 3.2. 生成阶段 4. 使用Spring AI实现RAG 4.1. 创建项目 4.2. 配置application.yml 4.3. 安装ElasticSearch和Kibana 4.3.1. 安装并启动ElasticSearch 4.3.2. 验证ElasticSearch是否启动成功 …

mysql数据库实现分库分表,读写分离中间件sharding-sphere

一 概述 1.1 sharding-sphere 作用&#xff1a; 定位关系型数据库的中间件&#xff0c;合理在分布式环境下使用关系型数据库操作&#xff0c;目前有三个产品 1.sharding-jdbc&#xff0c;sharding-proxy 1.2 sharding-proxy实现读写分离的api版本 4.x版本 5.x版本 1.3 说明…

运维视角下的广告系统之理解广告索引级联

广告索引中为什么要级联 这里的“级联”一般指的是多层索引结构&#xff0c;也叫级联索引&#xff08;Cascade Index 或 Multi-level Index&#xff09;。 在广告系统的索引中&#xff0c;级联设计有重要作用&#xff0c;主要原因如下&#xff1a; 1. 多维特征筛选的需求 广…

2025年5月24日系统架构设计师考试题目回顾

当前仅仅是个人用于记录&#xff0c;还未做详细分析&#xff0c;待更新… 综合知识 设 x,y 满足约束条件&#xff1a;x-1>0, x-y<0, x-y-x<0, 则 y/x 的最大值是()。 A. 3 B. 2 C. 4 D. 1 申请软件著作权登记时应当向中国版本保护中心提交软件的鉴别材料&#xff…

3D-激光SLAM笔记

目录 定位方案 编译tbb ros2humble安装 命令 colcon commond not found 栅格地图生成&#xff1a; evo画轨迹曲线 安装gtsam4.0.2 安装ceres-solver1.14.0 定位方案 1 方案一&#xff1a;改动最多 fasterlio 建图&#xff0c;加闭环优化&#xff0c;参考fast-lio增加关…

贪心算法应用:分数背包问题详解

贪心算法与分数背包问题 贪心算法&#xff08;Greedy Algorithm&#xff09;是算法设计中一种重要的思想&#xff0c;它在许多经典问题中展现出独特的优势。本文将用2万字篇幅&#xff0c;深入剖析贪心算法在分数背包问题中的应用&#xff0c;从基础原理到Java实现细节&#x…

PyTorch——非线性激活(5)

非线性激活函数的作用是让神经网络能够理解更复杂的模式和规律。如果没有非线性激活函数&#xff0c;神经网络就只能进行简单的加法和乘法运算&#xff0c;没法处理复杂的问题。 非线性变化的目的就是给我们的网络当中引入一些非线性特征 Relu 激活函数 Relu处理图像 # 导入必…

iOS 电子书听书功能的实现

在 iOS 应用中实现电子书听书&#xff08;文本转语音&#xff09;功能&#xff0c;可以通过系统提供的 AVFoundation 框架实现。以下是详细实现步骤和代码示例&#xff1a; 核心步骤&#xff1a; 导入框架创建语音合成器配置语音参数实现播放控制处理后台播放添加进度跟踪 完整…

ES中must与filter的区别

在 Elasticsearch 的布尔查询&#xff08;bool query&#xff09;中&#xff0c;must 和 filter 是两个核心子句&#xff0c;它们的核心区别在于 是否影响相关性评分&#xff0c;这直接决定了它们在查询性能、使用场景和结果排序上的差异。以下是详细对比&#xff1a; 一、核心…