Skip to main content

BaiBao (百宝)

方便好用的 Python 常用功能库。把日常开发中反复用到的能力(日志、包管理、数据库、邮件、OCR)封装成简洁的 API,开箱即用。

优势

  • 依赖自动安装 — import_module() 首次导入时自动下载安装缺失的包,无需手动 pip install
  • 镜像自动切换 — 内置清华、阿里云、中科大等多个 PyPI 镜像,按优先级自动 fallback,国内网络畅通无阻
  • 配置即代码 — 所有配置类均为 dataclass,支持从 JSON 文件一键加载,自动校验必填字段
  • 数据库开箱即用 — 连接池基于 DBUtils,驱动包首次连接时自动安装,支持 MySQL / PostgreSQL
  • OCR 统一接口 — EasyOCR 和 PaddleOCR 共享同一抽象基类,运行时随时切换引擎

模块概览

分类 模块 说明
基础设施 baibao.base.log 带颜色和级别的日志输出
baibao.base.pip 多镜像源自动切换的包安装工具
baibao.base.util 动态导入模块、加载 JSON 配置等通用工具
数据存储 baibao.db 数据库连接池(MySQL / PostgreSQL)
消息通知 baibao.message.email 邮件发送(纯文本、HTML、附件)
文字识别 baibao.ai.ocr OCR 文字识别(EasyOCR / PaddleOCR)

安装

# 基础安装(安装后 import baibao 即可使用)
python -m pip install . -i https://pypi.tuna.tsinghua.edu.cn/simple/

# 开发模式(修改源码立刻生效,无需重新安装)
python -m pip install -e . -i https://pypi.tuna.tsinghua.edu.cn/simple/

# 可选:安装 OCR 引擎依赖
python -m pip install ".[easyocr]"    # EasyOCR
python -m pip install ".[paddleocr]"  # PaddleOCR
python -m pip install ".[all]"        # 全部

快速上手

pip install baibao -i https://pypi.tuna.tsinghua.edu.cn/simple/

from baibao.base import util

# 自动下载并导入 numpy(如果本机没装的话)
numpy = util.import_module("numpy")

更多用法请查看 使用示例。

开发环境

# 安装开发依赖
python -m pip install ".[dev]"

# 代码风格检查
python -m ruff check src/

# 类型检查
python -m mypy src/

# 运行测试
python -m pytest tests/

许可证

GPL-3.0-or-later

Metadata

Release files for baibao 0.0.2

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

Source distribution (sdist)

Source distribution for baibao 0.0.2
File Size Uploaded
baibao-0.0.2.tar.gz 37.3 kB Details

Built distribution (wheel)

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

Total release size: 86.4 kB

Release files / baibao-0.0.2.tar.gz

Download URL baibao-0.0.2.tar.gz
Size 37.3 kB
Tags Source
SHA-256 checksum
How to use checksums
b499c183bf7a832c1496cac91173a5ba25ebb4e995b91cc8f547c97684fa4b38
BLAKE2b-256 checksum
How to use checksums
a78a0c3a642635028b75fa8d5e619065e1d84e54bb2b4858df7faac2db9cf0b6
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.13.2

Release files / baibao-0.0.2-py3-none-any.whl

Download URL baibao-0.0.2-py3-none-any.whl
Size 49.1 kB
Tags Python 3
SHA-256 checksum
How to use checksums
4671704ee81f68d8e05d46d9cd6483ff75deaf60642575974d01db30653f5636
BLAKE2b-256 checksum
How to use checksums
130d4b6e12b3dc9b3ce19feb8ee05ecfeda4c1542fb4a2af06f335207e8a1756
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.13.2

Release history Release notifications | RSS feed

0.0.10

2 release files

0.0.9

2 release files

0.0.8

2 release files

0.0.7

2 release files

0.0.6

2 release files

0.0.5

2 release files

0.0.4

2 release files

0.0.3

2 release files

This release

0.0.2 This release

2 release files

0.0.1

2 release files

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