This release is a pre-release and may not be stable for production use.
jiuzhang
九章光量子真机云接入软件包(Python SDK)。
本目录为 SDK 源码工程。设计文档位于仓库根的
doc/。
状态
当前阶段 v0.1.0-alpha.9(骨架阶段后期):
- ✅ 工程骨架、工具链、版本策略、CHANGELOG 就位
- ✅ L1 Domain:异常体系(
JiuzhangError+ 8 个子类)+make_result()+get_logger() - ✅ L2 Protocol:
EnvelopeJSON 编解码、14 种消息 payload dataclass、Correlator、HeartbeatThread - ✅ L3 Transport:
TransportABC +TcpTransport(同步阻塞 socket,长度前缀分帧,16 MiB 上限) - ⏳ L1 Domain 三核心类的业务方法体已实装(
TokenManager.validate_token、PhotonicMachine.connect/disconnect、GaussianBosonSampler.init_status/run)。SimulatorServer已可作为本地对端,端到端链路已跑通。剩余 PR-11 端到端冒烟测试 / RC - ⏳ 公开 API surface 尚未冻结,将在
v0.1.0release 时冻结
测试规模:233 用例 / 覆盖率 86%。
工程结构
code/
├── pyproject.toml # 项目元数据 + ruff/mypy/pytest 配置
├── .pre-commit-config.yaml # pre-commit 钩子(format/lint/typecheck/commitlint)
├── .python-version # Python 3.12
├── README.md # 本文件
├── src/
│ └── jiuzhang/ # SDK 包(src-layout)
│ ├── __init__.py # 公开 API: __all__
│ ├── version.py
│ ├── exceptions.py # 异常体系
│ ├── errors.py # 错误码 + 映射
│ ├── result.py # 统一返回结构
│ ├── logging_utils.py
│ ├── auth/ # L1 Domain — TokenManager
│ ├── hardware/ # L1 Domain — PhotonicMachine
│ ├── sampling/ # L1 Domain — GaussianBosonSampler
│ ├── protocol/ # L2 Protocol — Session/Codec/Correlator/Heartbeat
│ ├── transport/ # L3 Transport — Transport ABC + TcpTransport
│ └── testkit/ # SimulatorServer(本地模拟器)
└── tests/
├── conftest.py
└── unit/
├── test_smoke.py # 包导入 / 公开 API / 异常继承
├── test_exceptions.py # 异常体系 + to_result()
├── test_result.py # make_result()
├── test_logging_utils.py # get_logger()
├── test_envelope.py # Envelope JSON 编解码
├── test_messages.py # 14 种 payload dataclass
├── test_correlator.py # Correlator 请求-响应配对
├── test_heartbeat.py # HeartbeatThread 后台线程
├── test_tcp_transport.py # TcpTransport(含 _EchoServer loopback)
├── test_session.py # ProtocolSession 集成测试(含 _MockServer)
└── test_domain.py # Domain 三核心类单元测试
开发流程
1. 安装依赖
cd d:/PyProjects/jiuzhang_SDK/code
uv sync --extra dev
2. 安装 pre-commit 钩子
uv run pre-commit install
uv run pre-commit install --hook-type commit-msg
3. 本地质量四件套
uv run ruff format src tests # 格式化
uv run ruff check src tests # lint(含 docstring D 规则)
uv run mypy src # 严格类型检查
uv run pytest # 测试 + 覆盖率
四件套全绿才能提交。
4. 提交规范
Conventional Commits — pre-commit 强制校验。
常见前缀:
feat:新功能 → CHANGELOGAddedfix:Bug 修复 → CHANGELOGFixedrefactor:重构(不改外部行为)perf:性能优化docs:文档变更chore:构建/工具/杂项test:测试相关- 在 footer 加
BREAKING CHANGE:→ 触发 MAJOR/0.x MINOR 版本号变更
5. 构建 wheel
uv build
# 产出 dist/jiuzhang-<version>-py3-none-any.whl + dist/jiuzhang-<version>.tar.gz
6. 隔离环境验证
uv run --isolated --with dist/jiuzhang-*-py3-none-any.whl \
python -c "import jiuzhang; print(jiuzhang.__version__)"
公开 API(v0.1.0-alpha.9,仍可能微调)
from jiuzhang import (
TokenManager,
PhotonicMachine,
GaussianBosonSampler,
JiuzhangError,
)
完整列表见 src/jiuzhang/__init__.py 的 __all__。
版本与发布
- 版本策略:
../VERSIONING.md - 变更日志:
../CHANGELOG.md - 发布 SOP:
../RELEASING.md
设计参考
LICENSE
Proprietary — Copyright © 2026 九章量子. 详见仓库根的 LICENSE。
Metadata
Release files for jiuzhang 0.1.0a10
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| jiuzhang-0.1.0a10.tar.gz | 54.9 kB | Without provenance | Details for jiuzhang-0.1.0a10.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| jiuzhang-0.1.0a10-py3-none-any.whl | Python 3 | none | any | Details for jiuzhang-0.1.0a10-py3-none-any.whl |
Total release size: 102.7 kB
Release files / jiuzhang-0.1.0a10.tar.gz
| Download URL | jiuzhang-0.1.0a10.tar.gz |
|---|---|
| Size | 54.9 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
f2ba4141c5753936b0b338a0260627c2ccc8cf80b062ac1da72aa23347b03570
|
|
BLAKE2b-256 checksum How to use checksums |
c977f0b50a9d5117775f5026328e9b27738e2a4d941a18a52f5e1b382661e521
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.12.13
|
Release files / jiuzhang-0.1.0a10-py3-none-any.whl
| Download URL | jiuzhang-0.1.0a10-py3-none-any.whl |
|---|---|
| Size | 47.9 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
ecfe86f04766b0690787c335273d9fb9bab7a4efda3c7648c54dba7a08b24083
|
|
BLAKE2b-256 checksum How to use checksums |
d0c4e4737f7b0717e7bed009648d2fa2b20edadf52f65c978e6f6761d85b4d3a
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.12.13
|
Security for jiuzhang 0.1.0a10
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.