Files
hunjing/tianmu/pyproject.toml
T
2026-08-21 16:00:13 +08:00

110 lines
4.0 KiB
TOML
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
[project]
name = "tianmu"
version = "0.2.0"
description = "天目 · 魂镜本地 OCR 引擎 — PP-OCRv6(via RapidOCR)+ PaddleOCR-VL-1.6"
authors = [{ name = "chenxin", email = "2685475410@qq.com" }]
license = "MIT"
requires-python = ">=3.12"
dependencies = [
"fastapi>=0.139.0",
"httpx[http2]>=0.28.1",
"loguru>=0.7.3",
"pillow>=10.0.0",
"pydantic>=2.13.4",
"pydantic-settings>=2.14.2",
"python-multipart>=0.0.32",
"uvicorn[standard]>=0.51.0",
]
[project.optional-dependencies]
# ═══════════════════════════════════════════════════════════
# PP-OCRv6 引擎(RapidOCR + ONNX Runtime)
# ═══════════════════════════════════════════════════════════
# CPU 推理(所有平台通用,包括 M4 的 CoreML 实验性支持)
rapidocr = [
"rapidocr>=3.9.0",
"onnxruntime>=1.20.0",
]
# GPU 推理(NVIDIA CUDA,仅 Linux/Windows)
rapidocr-gpu = [
"onnxruntime-gpu>=1.20.0",
]
# ═══════════════════════════════════════════════════════════
# PaddleOCR-VL 引擎(HuggingFace Transformers)
# ═══════════════════════════════════════════════════════════
# CPU/MPS(macOS 自动获取 CPU/MPS 版本,Linux/Windows 自动走 CPU 版本)
vl = [
"torch>=2.0.0",
"torchvision>=0.15.0",
"transformers>=5.0.0",
]
# GPU(通过 [tool.uv.sources] 自动选择 CUDA 版本,无需重复声明)
# 见下方 pytorch-cu128 源映射:Linux/Windows 自动使用 CUDA 12.8 版本
# ═══════════════════════════════════════════════════════════
all = ["tianmu[rapidocr,rapidocr-gpu,vl]"]
dev = [
"pre-commit>=4.6.0",
"pytest>=9.1.1",
"pytest-asyncio>=1.4.0",
"ruff>=0.15.21",
]
lint = ["black>=26.5.1", "mypy>=2.3.0", "ruff>=0.15.21"]
test = ["pytest>=9.1.1", "pytest-asyncio>=1.4.0", "pytest-cov>=7.1.0"]
dev-all = ["tianmu[dev,lint,test]"]
[project.scripts]
tianmu = "src.main:main_cli"
# =============================================
# uv 配置 - 跨平台 PyTorch 自动适配
# =============================================
# 默认使用中科大镜像(所有平台通用)
[[tool.uv.index]]
name = "ustc"
url = "https://pypi.mirrors.ustc.edu.cn/simple/"
default = true
# PyTorch CUDA 12.8 专用源(仅 Linux/Windows 使用)
[[tool.uv.index]]
name = "pytorch-cu128"
url = "https://mirrors.nju.edu.cn/pytorch/whl/cu128/"
explicit = true
# === 包来源映射:根据操作系统自动选择 ===
[tool.uv.sources]
# Linux/Windows:使用 CUDA 12.8 版本
torch = { index = "pytorch-cu128", marker = "sys_platform == 'linux' or sys_platform == 'win32'" }
torchvision = { index = "pytorch-cu128", marker = "sys_platform == 'linux' or sys_platform == 'win32'" }
torchaudio = { index = "pytorch-cu128", marker = "sys_platform == 'linux' or sys_platform == 'win32'" }
tianmu = { workspace = true }
# macOS:从默认源(中科大)自动获取 CPU/MPS 版本
# 不需要额外配置,会自动回退到 default = true 的源
# 验证命令:
# macOS: python -c "import torch; print(f'PyTorch: {torch.__version__}'); print(f'MPS available: {torch.backends.mps.is_available()}')"
# Linux: python -c "import torch; print(f'PyTorch: {torch.__version__}'); print(f'CUDA available: {torch.cuda.is_available()}')"
[build-system]
requires = ["hatchling>=1.25.0"]
build-backend = "hatchling.build"
[tool.hatch.build.targets.wheel]
packages = ["src"]
[tool.ruff]
line-length = 100
target-version = "py312"
[tool.ruff.lint]
select = ["E", "F", "I", "N", "W"]
[tool.pytest.ini_options]
asyncio_mode = "auto"
testpaths = ["tests"]