qimen-rs Python 绑定
Python 3.10+;使用 PyO3 和 maturin,计算期间释放 GIL。calculate 返回 Python 字典,
calculate_json 提供与 Rust 完全一致的 JSON 接口。CPython 常规 GIL 构建使用 abi3 wheel。
安装
python -m pip install qimen-rs
扩展到公元 1–9999 年的时间范围要求 0.2.0+;安装命令获取当前正式版。平台要求见安装指南。
快速开始
from qimen_rs import calculate
chart = calculate({
"year": 2024,
"month": 2,
"day": 10,
"hour": 12,
"utc_offset_minutes": 480,
"day_boundary": "zi_start",
})
print(chart["palaces"])
输入是指定 UTC 偏移下的民用时间;不会读取机器时区。默认 UTC+08:00,23:00 换日。
midnight 可显式选择 00:00 换日。无效日期、未知参数等由核心统一拒绝为 ValueError;
非字典输入或不能编码为 JSON 的 Python 对象抛出 TypeError。返回字段见结果 Schema,时间与历法口径见使用指南。
可选扩展
可选标注默认关闭,通过 extensions 参数选择明确的计算规则:
from qimen_rs import ExtensionOptions, calculate
options: ExtensionOptions = {
"hidden_stems": "duty_door_hour_stem_with_center_fallback",
"strength": "classical_stars_and_five_elements",
"growth_stages": "yang_forward_yin_reverse_fire_earth",
"punishments": "six_instrument_branches",
"tombs": "growth_stage_fire_earth",
"day_horse": "day_branch_three_harmony",
"door_pressure": "door_controls_palace",
}
chart = calculate({"year": 2026, "month": 9, "day": 18, "hour": 18}, extensions=options)
print(chart["extensions"]["day_horse"]["horse"])
只填写需要的项目即可;也可将 extensions 放入请求字典,与 JSON 接口完全一致。
同时使用两种位置会报 ValueError,避免静默覆盖。空配置不生成 extensions 输出字段。
每项结果记录实际 rule,寄干保留来源和盘层,日马与基础盘的时马分别返回。
tombs 也可选择 traditional_three_wonders;该规则只判断三奇,不适用的六仪结果为
None,与“未入墓”的 False 有区别。两种入墓约定不能混用。
公共类型在 qimen_rs.types 中;JSON Schema 与软件包版本分别编号。
全部 key、规则 value 及含义见扩展参数表;返回字段与枚举见结果速查,计算口径与适用范围见同页规则说明。
从源码安装
在所需版本的仓库根目录执行,需 Rust 1.94+:
python -m venv .venv
激活虚拟环境,Linux / macOS 使用 source .venv/bin/activate,Windows PowerShell 使用 .venv/Scripts/Activate.ps1,然后运行:
python -m pip install ./bindings/python
安装后仍使用相同的 from qimen_rs import calculate 接口。0.2.0+ 支持公元 1–9999 年的前推格里高利历;历史日期与边界输出见时间说明。
Metadata
Release files for qimen-rs 0.2.1
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 |
|---|---|---|---|---|
| qimen_rs-0.2.1.tar.gz | 70.0 kB | Without provenance | Details for qimen_rs-0.2.1.tar.gz |
Built distributions (wheels)
| File | Actions Reset | |||
|---|---|---|---|---|
| qimen_rs-0.2.1-cp310-abi3-win_amd64.whl | CPython 3.10 | abi3 | Windows x86-64 | Details for qimen_rs-0.2.1-cp310-abi3-win_amd64.whl |
| qimen_rs-0.2.1-cp310-abi3-manylinux_2_28_x86_64.whl | CPython 3.10 | abi3 | Linux glibc 2.28+ x86-64 | Details for qimen_rs-0.2.1-cp310-abi3-manylinux_2_28_x86_64.whl |
| qimen_rs-0.2.1-cp310-abi3-manylinux_2_28_aarch64.whl | CPython 3.10 | abi3 | Linux glibc 2.28+ ARM64 | Details for qimen_rs-0.2.1-cp310-abi3-manylinux_2_28_aarch64.whl |
| qimen_rs-0.2.1-cp310-abi3-macosx_11_0_arm64.whl | CPython 3.10 | abi3 | macOS 11.0+ ARM64 | Details for qimen_rs-0.2.1-cp310-abi3-macosx_11_0_arm64.whl |
| qimen_rs-0.2.1-cp310-abi3-macosx_10_12_x86_64.whl | CPython 3.10 | abi3 | macOS 10.12+ x86-64 | Details for qimen_rs-0.2.1-cp310-abi3-macosx_10_12_x86_64.whl |
Total release size: 1.7 MB
Release files / qimen_rs-0.2.1.tar.gz
| Download URL | qimen_rs-0.2.1.tar.gz |
|---|---|
| Size | 70.0 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
96c707a80639e9c627d2bb0569ec457d85e8566172435d681c9dd8aaa64ac154
|
|
BLAKE2b-256 checksum How to use checksums |
ac0b0acf91bf67d100118f3420bbae99461bb611377894e32c24f2f57aa28d10
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/7.0.0 CPython/3.13.14
|
Release files / qimen_rs-0.2.1-cp310-abi3-win_amd64.whl
| Download URL | qimen_rs-0.2.1-cp310-abi3-win_amd64.whl |
|---|---|
| Size | 248.6 kB |
| Tags | CPython 3.10 Windows x86-64 abi3 |
|
SHA-256 checksum How to use checksums |
1a95ba7e086e46c7b8fb6c4f0726f390547853cc409ad900bef0489d443bf920
|
|
BLAKE2b-256 checksum How to use checksums |
8d839996ea385a38f1e35c6a2d2faafae999e00b592172ab1a6f21bdbc1e20df
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/7.0.0 CPython/3.13.14
|
Release files / qimen_rs-0.2.1-cp310-abi3-manylinux_2_28_x86_64.whl
| Download URL | qimen_rs-0.2.1-cp310-abi3-manylinux_2_28_x86_64.whl |
|---|---|
| Size | 374.6 kB |
| Tags | CPython 3.10 Linux glibc 2.28+ x86-64 abi3 |
|
SHA-256 checksum How to use checksums |
58e5817227ff0653725d677fd2128777581571f3331c71b64384be01cb12442b
|
|
BLAKE2b-256 checksum How to use checksums |
101e63a9e14e2ef9948fd899db74a3e6382eeae4f38b7c2321345d5f8b3d35f2
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/7.0.0 CPython/3.13.14
|
Release files / qimen_rs-0.2.1-cp310-abi3-manylinux_2_28_aarch64.whl
| Download URL | qimen_rs-0.2.1-cp310-abi3-manylinux_2_28_aarch64.whl |
|---|---|
| Size | 368.2 kB |
| Tags | CPython 3.10 Linux glibc 2.28+ ARM64 abi3 |
|
SHA-256 checksum How to use checksums |
16b66f42aa9b781e717d8dfca23de4f0c32cbf4ba2b1bf164584a00ec182dfc3
|
|
BLAKE2b-256 checksum How to use checksums |
fbff5d5e0b7be32e91f7293cf48d1aa542efde2512c6c7dfb1a482afc173035a
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/7.0.0 CPython/3.13.14
|
Release files / qimen_rs-0.2.1-cp310-abi3-macosx_11_0_arm64.whl
| Download URL | qimen_rs-0.2.1-cp310-abi3-macosx_11_0_arm64.whl |
|---|---|
| Size | 340.0 kB |
| Tags | CPython 3.10 abi3 macOS 11.0+ ARM64 |
|
SHA-256 checksum How to use checksums |
db4579d04316bcbc797c26bdafe19e0fb41ebc5cc561f49a7961cfb77a511b8f
|
|
BLAKE2b-256 checksum How to use checksums |
e9e9c9c387cb0f485dcd1cd1a160d76f3ae684811418bbe9852ab3c2d47d8c69
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/7.0.0 CPython/3.13.14
|
Release files / qimen_rs-0.2.1-cp310-abi3-macosx_10_12_x86_64.whl
| Download URL | qimen_rs-0.2.1-cp310-abi3-macosx_10_12_x86_64.whl |
|---|---|
| Size | 346.9 kB |
| Tags | CPython 3.10 abi3 macOS 10.12+ x86-64 |
|
SHA-256 checksum How to use checksums |
3bef737ee32f9cd7c51159d5c949ec5cda3f1b11d80cb9a2f8e908fe8179d3e2
|
|
BLAKE2b-256 checksum How to use checksums |
2a0900e12a756b51dac027eee9db82418d0e76d312a54b9daeaebaf26d31f446
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/7.0.0 CPython/3.13.14
|
Security for qimen-rs 0.2.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.