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

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

Built distribution (wheel)

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

Total release size: 4.7 MB

Release files / wh40kdc-1.5.2.tar.gz

Download URL wh40kdc-1.5.2.tar.gz
Size 2.3 MB
Tags Source
SHA-256 checksum
How to use checksums
c3a12e0f6b8bb9fae84ccf07bbc50d6c316279a7508625517b818370ef523465
BLAKE2b-256 checksum
How to use checksums
54947eb2f6cb18f9c775963499aae63a75f12889cb2cf029c2a8dbcab7e06656
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.2-py3-none-any.whl

Download URL wh40kdc-1.5.2-py3-none-any.whl
Size 2.4 MB
Tags Python 3
SHA-256 checksum
How to use checksums
39f676909503fcec22f12871e75e7bdff1398f3afe18b942a390cb459fffb4a5
BLAKE2b-256 checksum
How to use checksums
4296ce6237d5333759f2b36a048de790ba73f33d76a90e28f48686281cf6a561
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.2

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