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.3

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.3
File Size Uploaded Provenance Actions
wh40kdc-1.5.3.tar.gz 2.3 MB With provenance Details for wh40kdc-1.5.3.tar.gz

Built distribution (wheel)

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

Total release size: 4.8 MB

Release files / wh40kdc-1.5.3.tar.gz

Download URL wh40kdc-1.5.3.tar.gz
Size 2.3 MB
Tags Source
SHA-256 checksum
How to use checksums
819a2cef7107454319d9da60bbc34d6310a8751ef2d00fa113a4db30805ae059
BLAKE2b-256 checksum
How to use checksums
a59c31e5a202ae33fc4f376fb46083de6750efe548dfc5776cf2b73069afdd7c
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 Nov 24, 2026.

Transparency log

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

Download URL wh40kdc-1.5.3-py3-none-any.whl
Size 2.5 MB
Tags Python 3
SHA-256 checksum
How to use checksums
25140801a4ed3a2167b6f1a0c7e97403a65b4dc23b3c44fec915042545647d3b
BLAKE2b-256 checksum
How to use checksums
a0c81230b9a129b939e780edd81e06e6fca403ff2d2a637f3a088cfdda581458
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 Nov 24, 2026.

Transparency log

Security for wh40kdc 1.5.3

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.3.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 Nov 24, 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.3 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