初始提交:algpkg-sdk(算法包开发 SDK)—— 从 sophon-edge 仓库拆分独立建库

本仓库原先内嵌在 sophon-edge 的 `algpkg-sdk/`(该仓库历史上的三次相关提交:
e8101ba「算法开发能力独立成项目」、090c406「契约名落地为真实模块 + 多模型 ctx」、
b666161「sail 存根 + 编写风格修正」)。现拆出独立建库,便于算法作者单独 clone/迭代、
也便于单独发版(打成 wheel 分发给第三方或进 worker 交付包的 vendor/)。

- 内容:`src/algpkg_sdk/`(api/manifest/loader/builder/testkit/cli)+ 契约名模块
  `src/video_algpkg_api/`、`examples/person-count`(完整示例)、`tests/`(pytest,无设备自动跳过)、
  `README.md`(已改成独立仓库口径:命令在项目根执行,配套 worker 用路径依赖/`ALGPKG_SDK_DIR`)、
  `pyproject.toml`(console script `algpkg`)、`uv.lock`;
- 不含 `.venv/`(`.gitignore` 已覆盖,clone 后 `uv sync` 重建)。

配套 worker 仓库(sophon-edge):
`workers/video/pyproject.toml` 以路径依赖指向本仓库(`path = "../../../algpkg-sdk"`,可用
`ALGPKG_SDK_DIR` 覆盖);交付打包 `deploy/pack_worker.py` 会把本仓库打成 wheel 放进 worker 包 `vendor/`。
This commit is contained in:
linaro
2026-10-16 16:15:59 +08:00
commit 170e4a10a4
18 changed files with 3792 additions and 0 deletions
+50
View File
@@ -0,0 +1,50 @@
# 算法包开发 SDK —— 独立项目(可单独 clone / 分发 / 出包)
#
# 定位:算法作者只需要这一个项目 + 一台设备(或没有设备也能做静态校验),
# 即可完成「写算法 → 本地跑通 → 打包 → 自检 → 交付 .mbank」的全流程,
# 不需要 worker 仓库、也不需要了解 worker 内部结构。
[project]
name = "algpkg-sdk"
version = "0.1.0"
description = "算法包(.mbank)开发、测试与打包工具链"
readme = "README.md"
requires-python = ">=3.10"
dependencies = [
# .mbank 读写(svfs 虚拟文件系统 + 模块银行打包器)
"module-bank>=0.4.2",
"orjson>=3.10",
"numpy>=1.26",
# 注:设备侧推理(sophon-arm / sail)**不是必需依赖** —— 没有 NPU 的机器照样能做
# manifest 校验、打包、挂载试加载(不实跑模型);只有 `algpkg run` 需要设备。
]
[project.optional-dependencies]
# 设备上跑推理/本地测试台时需要(BM1684X / BM1688 / CV186X 等 Sophon 设备)
device = ["sophon-arm>=3.11.1"]
# 开发本项目自身(单测 + 类型)
dev = ["pytest>=8", "sophon-arm>=3.11.1"]
[project.scripts]
algpkg = "algpkg_sdk.cli:main"
[build-system]
requires = ["hatchling"]
build-backend = "hatchling.build"
[tool.hatch.build.targets.wheel]
# 两个顶层包同属本发行:algpkg_sdk(工具链)+ video_algpkg_api(接口契约名的真实模块,
# 算法包代码只导入它;重导出 algpkg_sdk.api,见 src/video_algpkg_api/__init__.py)
packages = ["src/algpkg_sdk", "src/video_algpkg_api"]
[tool.pytest.ini_options]
testpaths = ["tests"]
markers = [
"device: 需要 Sophon 设备(NPU)才能跑;无设备时自动跳过",
]
# 索引:内部源(含 sophon-arm 等设备包)优先,公共源兜底 —— 与 workers/video 同口径
[[tool.uv.index]]
url = "http://124.71.68.6:3000/api/packages/chongming/pypi/simple/"
[[tool.uv.index]]
url = "https://mirrors.tuna.tsinghua.edu.cn/pypi/web/simple"