使用pdm+uv替換poetry

用了好幾年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; 一、核心…