Skip to content

Commit ece1b39

Browse files
committed
fix: 版本号从包元数据读取,消除双份来源
_version.py 里硬编码的版本与 pyproject.toml 相互独立,0.0.1.dev1 发布时漏改,导致所有请求的 User-Agent 报成 qca-python/0.1.0, 服务端日志里的客户端版本不可信。改为读 importlib.metadata, 今后版本只在 pyproject.toml 一处维护。
1 parent 1cceeda commit ece1b39

2 files changed

Lines changed: 8 additions & 2 deletions

File tree

pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[project]
22
name = "qca"
3-
version = "0.0.1.dev1"
3+
version = "0.0.1.dev2"
44
description = "Typed synchronous and asynchronous clients for Qoder Cloud Agents"
55
authors = [{name = "Qoder"}]
66
license = "MIT"

src/qca/_version.py

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1,7 @@
1-
__version__ = "0.1.0"
1+
from importlib.metadata import PackageNotFoundError, version
2+
3+
try:
4+
__version__ = version("qca")
5+
except PackageNotFoundError:
6+
# 直接从源码树导入(未安装)时没有包元数据可读。
7+
__version__ = "0.0.0.dev0"

0 commit comments

Comments
 (0)