Skip to main content

abt

一个自己也能读懂、自己也能维护的 Python 底层工具包。

这是什么

abt 是对既有工具包 apiboot 的从零重写。

apiboot 的功能是 OK 的,但它几乎全部由 AI 生成:代码量涨得很快,却没有一个字是「自己先想清楚再落笔」的。结果是大量冗余封装、过度抽象,作者本人也读不懂——下游项目一旦出问题,除了「再问一次 AI」没有第二条路。

abt 重写它,验收标准不是功能跑通,而是作者本人能在不询问任何 AI 的情况下,读懂并定位任意一个函数的实现与问题。

两条硬规则

  1. 不包装 stdlib。pathlib / datetime / json 能直接用就直接用,只在语义上做了收敛或增强时才封装。
  2. 一次只做一个模块。每个函数要能一句话说清,docstring 写「为什么」和「不变量」,不写「做了什么」。

特色:第三方依赖全部懒加载

abt 的运行时第三方依赖为零。

pip install abt   # 不会顺带装 requests / sqlalchemy / redis
  • import abt 和 import abt.<任意子模块> 绝不会因为环境里缺某个第三方包而报错。
  • 只有真正调用到用到它的那个函数时才会失败,报错信息里会写清楚缺哪个包、为什么要装它、pip install 命令是什么。

换句话说,装了不炸;缺依赖在调用点才暴露,而不是在 import 阶段就让整个服务起不来。

运行环境

  • Python 3.7+(最低 3.7;开发环境 3.11)
  • 3.7 的语法下限由 vermin 把关:uv run vermin --target=3.7- --violations abt/ 必须始终通过

设计文档

完整的出发点、验收标准、apiboot 模块构成、已知坑位清单、重写路线图,都在 CLAUDE.md 里。

安装

uv add abtbb
from abt import logger

发布名 ≠ import 名。 PyPI 上的 abt 已被他人占用,所以发布名用 abtbb;但 import 名仍是 abt——它由包目录名决定,跟发布名无关。 (pip install pillow → import PIL 同理。)

本地开发:

uv sync          # 装依赖(含 dev group:pytest / mypy / ruff / vermin)
uv run pytest    # 跑测试
uv run mypy abt  # 静态检查
uv run ruff check .
uv run vermin --target=3.7- --violations abt/   # Python 3.7 语法下限闸门

命令行

abtrun --help

命令名用 abtrun 而非 abt——abt 已被 apiboot 的 CLI 占用,两个包共存时会互相覆盖 PATH。

发布到 PyPI

uv sync                                          # 装齐工具链(含 twine)
python scripts/upload_pypi.py                    # 构建 + 输入 token + 确认上传
python scripts/upload_pypi.py --dry-run          # 只构建, 不上传, 不用输 token
python scripts/upload_pypi.py --repository testpypi   # 先发测试仓库试水

流程:清理旧 dist/ → 重新构建 sdist + wheel → 预检版本号是否已存在 → 提示输入 PyPI API Token(输入不回显,不落盘不进 shell history)→ 询问 y/n 确认 → 上传。

Token 申请:https://pypi.org/manage/account/token/,用户名固定 __token__。

同一版本号不能重复发布,报错前请把 pyproject.toml 里的 version 改大一位。

License

MIT

Metadata

Release files for abtbb 0.0.1

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for abtbb 0.0.1
File Size Uploaded Provenance Actions
abtbb-0.0.1.tar.gz 6.6 kB Without provenance Details for abtbb-0.0.1.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for abtbb 0.0.1
File Interpreter ABI Platform Actions
abtbb-0.0.1-py3-none-any.whl Python 3 none any Details for abtbb-0.0.1-py3-none-any.whl

Total release size: 11.2 kB

Release files / abtbb-0.0.1.tar.gz

Download URL abtbb-0.0.1.tar.gz
Size 6.6 kB
Tags Source
SHA-256 checksum
How to use checksums
374d4a6ce15ad74a3c91d7cf59069c6a5c23004eca81d96bf925f3582585f5c5
BLAKE2b-256 checksum
How to use checksums
b1da862bd78f894d447dc11c2d0b00d218e9dfa441c1ce70315f25fc73d792c2
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.13.14

Release files / abtbb-0.0.1-py3-none-any.whl

Download URL abtbb-0.0.1-py3-none-any.whl
Size 4.6 kB
Tags Python 3
SHA-256 checksum
How to use checksums
cb3644d81f65edb6cdde3407a61577767d4476e2445372d03994ed661a6eb1ae
BLAKE2b-256 checksum
How to use checksums
539b68e6ac1aa2bb0223ca8e031ca002aa7bfee0d2277c6b30f477d122f90892
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.13.14

Security for abtbb 0.0.1

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page