Skip to main content

ziwei

Python 紫微斗数排盘与知识库。历法与时间由 celestial-calendar 提供;本仓记录紫微斗数的安星规则、 四化口径、流派变体与出处,并组织可复现的命盘结果。

本页对应ziwei 0.2.0源码与用法。在线文档随main更新, 不固定于某次发行。版本变化见发行说明,公开发行记录以 PyPI和GitHub Releases为准。

目前提供出生记录、显式口径配置、民用时刻消歧、干支基础、celestial 历法适配、解析层 (公历/农历记录到计算输入)、命宫身宫与十二宫、五行局、28星安星、具名生年四化与大限, 以及完整命盘组合、只读按宫查询与宫位关系、文本十二宫格、静态SVG盘面和独立知识目录。 用法见出生输入、历法与时间、 解析层、命宫身宫与十二宫、 五行局、安星、 四化与大限、完整命盘与盘面 和知识查询。开发检查与协作约定见 参与开发,发布状态与失败处理见 发布指南。

0.2.0不再提供命盘JSON保存/恢复与旧盘重算接口,也不读取旧JSON命盘。 这项变化不改动已发布的v0.1.0及其制品。

安装

先确认下方安装要求中的平台限制,再在已激活的独立虚拟环境中从正式PyPI安装:

python -m pip install "ziwei==0.2.0"
python -m pip check

源码安装与检查见参与开发。 从main安装的源码不等同于PyPI发行制品;上传前的候选状态见发布指南。

安装要求

支持Python 3.11–3.14。运行时精确依赖celestial-calendar==0.8.0与tzdata==2026.5。 celestial-calendar 0.8.0在PyPI只提供下列原生wheel,没有源码分发包;ziwei自身的纯Python wheel不扩大这个范围:

平台 架构与最低系统要求
macOS arm64,macOS 14或更新
Linux x86_64,glibc 2.26或更新;aarch64,glibc 2.24或更新
Windows amd64

Intel macOS、Windows ARM64、较旧macOS和musl Linux不在上述制品覆盖范围内,不能依靠pip自动回退源码构建。 请使用独立虚拟环境;与不同精确版本的celestial-calendar或tzdata显式共装会冲突。 安装ziwei时,pip也可能将环境中已有的较新celestial-calendar或tzdata降到上述精确版本。 允许的依赖版本与复查条件见依赖兼容策略。

最小排盘

下面用合成的2024年农历正月初一子时女命演示最小排盘。 “口径”指闰月归属、子时换日和换年界线这三项计算选择;本例逐项指定,并选择一张具名生年四化表。

>>> from ziwei.birth import Gender, LunarBirthRecord
>>> from ziwei.chart import create_chart
>>> from ziwei.config import ChartConfig, DayRollover, LeapMonthPolicy, YearBoundary
>>> from ziwei.ganzhi import Dizhi
>>> from ziwei.render import render_text
>>> from ziwei.sihua import SihuaVariant
>>> record = LunarBirthRecord(
...   year=2024, month=1, day=1, is_leap_month=False, shichen=Dizhi.子, gender=Gender.女,
... )
>>> choices = ChartConfig(
...   leap_month_policy=LeapMonthPolicy.全月归本月,
...   day_rollover=DayRollover.早晚子时同日,
...   year_boundary=YearBoundary.农历正月初一,
... )
>>> chart = create_chart(record, choices, sihua_variant=SihuaVariant.排命盘口诀转录)
>>> text = render_text(chart)
>>> print(text.splitlines()[0])
火六局 · 大限逆行 · 虚岁首尾包含

这里仅显示盘面摘要。用print(text, end="")查看十二宫、28星、四化与大限; 同一输入的完整盘面及其计算与验证边界见指南。 未知时辰或性别可以保存在出生记录中,但完整命盘入口会拒绝,不代填。

功能范围

已知出生时刻与性别,排出可复现的本命盘:

  • 保存出生原始记录,显式处理时区与可选的真太阳时,保留解析后的农历年月日时与所用历法算法。
  • 闰月归属、子时换日、换年三个口径作为具名配置,不设静默默认。
  • 安命宫、身宫与十二宫宫干,定五行局,安紫微、天府两系十四主星。
  • 安六吉、六煞、禄存与天马;按所选具名四化表取生年四化。
  • 起大限:顺逆由年干阴阳与性别定,首限起始虚岁由五行局数定。
  • 命盘结果不可变,保留输入、口径、历法版本与派生结果;另提供文本与静态SVG盘面用于显示。

首版交付记录见v0.1.0 milestone, 当前改进由v0.2.0 milestone追踪。

设计边界

也可独立查知识:无需出生资料或先排盘,就能查到星曜、宫位、四化等概念, 以及安星规则的流派变体与出处。来源核验状态、适用前提与展示资格分别记录。

通用概念用惯用英语,术数专有词用拼音,枚举另有中文别名;文档、issue 与 PR 使用中文。

后续方向

  • 杂曜、运限与展示:杂曜、庙旺利陷、小限与流年流月、 飞星四化、格局识别、盘面展示。
  • 解释知识与研究:有出处的解释知识与前提判别、 1972 年前的历史时刻、多源排盘比对、与八字的联合入口。

这些 milestone 记录方向,不设发布日期。每项技术在实现前须明确定义、出处与参考盘例。

许可证

MIT。

Metadata

Release files for ziwei 0.2.0

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

Source distribution (sdist)

Source distribution for ziwei 0.2.0
File Size Uploaded Provenance Actions
ziwei-0.2.0.tar.gz 322.8 kB With provenance Details for ziwei-0.2.0.tar.gz

Built distribution (wheel)

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

Total release size: 401.7 kB

Release files / ziwei-0.2.0.tar.gz

Download URL ziwei-0.2.0.tar.gz
Size 322.8 kB
Tags Source
SHA-256 checksum
How to use checksums
b6c9c43c3b1b70e4e4d1c102bd7e4484e99ea6de4a751aa718ba1628442a7270
BLAKE2b-256 checksum
How to use checksums
5bae01431b583d31c8172dd4858d4912aade007de083809a242bc9201eb22425
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

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.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Oct 27, 2026.

Transparency log

Release files / ziwei-0.2.0-py3-none-any.whl

Download URL ziwei-0.2.0-py3-none-any.whl
Size 78.8 kB
Tags Python 3
SHA-256 checksum
How to use checksums
6512d781c35b1a225dcee1ba3dab63593503a96a592a907316c456cee1484502
BLAKE2b-256 checksum
How to use checksums
b3e00d8a29cce9cf5780246a52f84d27852cb4edbe6ebc2549f916fe10d876de
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

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.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Oct 27, 2026.

Transparency log

Security for ziwei 0.2.0

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.

Full provenance

Both files in this release have been uploaded with provenance metadata.

Select from 2 files

Attestation for ziwei-0.2.0.tar.gz

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Oct 27, 2026.

Transparency log

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.

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