Skip to main content

wh40kdc

Python library for the 40kdc-data Warhammer 40,000 dataset. It mirrors the TypeScript (@alpaca-software/40kdc-data), Rust (wh40kdc), and Go implementations, held in behavioral parity by the shared conformance corpus.

Installation

pip install wh40kdc

The only runtime dependency is jsonschema.

Quick Start

from wh40kdc import Dataset

ds = Dataset.embedded()
unit = ds.units.find("Khârn the Betrayer")
for weapon in unit.weapons:
    print(weapon.name)

Records are plain dicts behind linked view objects, with generated TypedDict definitions in wh40kdc._types for static type checking.

Features

  • Linked dataset API: Dataset provides exact ID lookups, diacritic- and punctuation-insensitive name searches (find, find_all), reverse indexes, and joins across units, weapons, abilities, phases, and factions. Dataset.embedded() opens the matched-play view (skipping Combat Patrol-only records in listings and searches while resolving every ID); call ds.for_game_mode("combat-patrol") or ds.for_game_mode("all") for other views.
  • Roster importers: ListForge, NewRecruit (JSON, wtc-compact, wtc-full, simple), GW app export, Rosterizer, and canonical Roster JSON, all normalizing to one Roster structure.
  • Roster exporters: NewRecruit (JSON, wtc-compact, wtc-full, simple), canonical Roster JSON, Rosterizer, ATC 2026, and Yellowscribe — byte-identical to TypeScript, Rust, and Go.
  • Damage cruncher and attribution: Deterministic expected-value pipeline (attacks -> hits -> wounds -> unsaved -> damage -> after-fnp -> models-killed) with buff resolution and leave-one-out attribution. Undecided leaf conditions are returned as needs with stable keys and answered via conditionFacts on the engine context. Dataset.mortal_wound_sources_for lists mortal wounds inflicted outside the attack sequence.
  • Scoring, terrain, and translation: Mission scoring engine, terrain layout geometry and keystone measurements, and Ability-DSL / scoring-card English describers.
  • Schema validator: validate(target, value) validates records against the canonical JSON Schemas and emits the shared closed-enum error codes.

The conformance runner used by the cross-implementation parity differ is invoked as python -m wh40kdc.runner (see conformance/RUNNER_PROTOCOL.md).

Development

cd python
uv venv && uv pip install -e ".[dev]"
pytest          # unit tests + conformance suite when run inside the repo
ruff check .
mypy src

Generated artifacts (_bundle.json, _spec.py, _types.py, src/wh40kdc/schemas/) are checked in and verified for drift in CI. Regenerate them after schema or data changes:

python3 codegen/sync_bundle.py && python3 codegen/sync_spec.py && python3 codegen/gen_typeddicts.py

License

  • Package code: MIT.
  • Schemas: CC0 (public domain).
  • Enrichment data: CC BY 4.0 — see the repository's licensing table.

Metadata

Release files for wh40kdc 1.5.4

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

Source distribution (sdist)

Source distribution for wh40kdc 1.5.4
File Size Uploaded Provenance Actions
wh40kdc-1.5.4.tar.gz 2.4 MB With provenance Details for wh40kdc-1.5.4.tar.gz

Built distribution (wheel)

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

Total release size: 4.8 MB

Release files / wh40kdc-1.5.4.tar.gz

Download URL wh40kdc-1.5.4.tar.gz
Size 2.4 MB
Tags Source
SHA-256 checksum
How to use checksums
78feb194d38721779381a53d9fecc1af6a004adf1abdc9d8561a54f60eb6789f
BLAKE2b-256 checksum
How to use checksums
7b2b58a060133bc7b8ff8ce6f8a5e73fad7ea12fea458c2def7b190d347b0263
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 Dec 1, 2026.

Transparency log

Release files / wh40kdc-1.5.4-py3-none-any.whl

Download URL wh40kdc-1.5.4-py3-none-any.whl
Size 2.5 MB
Tags Python 3
SHA-256 checksum
How to use checksums
ba7361193eb16b9df1394159c000ef2d52d44207cf72a101dbdacbf292b71d49
BLAKE2b-256 checksum
How to use checksums
4c38b04e17c328af1f52010394871af6640a900498a8d40e7d40bb6eccc55e83
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 Dec 1, 2026.

Transparency log

Security for wh40kdc 1.5.4

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 wh40kdc-1.5.4.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 Dec 1, 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.

Release history Release notifications | RSS feed

This release

1.5.4 This release

2 release files Full provenance

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