Skip to main content

wh40kdc

The 40kdc Warhammer 40K dataset behind a linked, typed API — find units, follow them to their weapons, abilities, phases, and factions. The Python counterpart to @alpaca-software/40kdc-data (npm) and wh40kdc (crates.io), held in behavioral lockstep with both, and with the Go module, by the shared conformance corpus in the 40kdc-data repository.

pip install wh40kdc
from wh40kdc import Dataset

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

What ships:

  • Linked dataset API — Dataset with id/name lookups (diacritic- and punctuation-insensitive), reverse indexes, and join queries across units, weapons, abilities, phases, and factions. Dataset.embedded() is the matched-play view: listings and name searches skip Combat Patrol-only records, and id lookups resolve every record. ds.for_game_mode("combat-patrol") or ds.for_game_mode("all") opens another view.
  • Importers — ListForge, NewRecruit (JSON / WTC-compact / WTC-full / simple), GW app export, Rosterizer, and canonical Roster JSON, all resolving to one Roster shape.
  • Exporters — NewRecruit (JSON / WTC-compact / WTC-full / simple), canonical Roster JSON, Rosterizer, ATC 2026, and Yellowscribe, byte-identical to the TypeScript, Rust, and Go implementations.
  • Cruncher — the damage-projection engine (attacks → hits → wounds → unsaved → damage → after-FNP → models-killed) with buff resolution and per-buff attribution. Undecided leaf conditions are reported as needs with stable keys and answered through the engine context's conditionFacts dict; Dataset.mortal_wound_sources_for lists mortal wounds inflicted outside the attack.
  • Scoring, terrain, translation — secondary-mission scoring, terrain layout resolution and keystone measurements, and the ability-DSL / scoring-card describers.
  • Validator — validate(target, value) against the canonical JSON Schemas, emitting the closed error-code enum shared by all implementations.

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

Development

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

Generated artifacts (_bundle.json, _spec.py, _types.py, src/wh40kdc/schemas/) are produced by the scripts in codegen/ and checked for drift in CI — regenerate with:

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

License

MIT. The schema content the dataset describes is CC0; enrichment data is CC BY 4.0 — see the repository's licensing table.

Metadata

Release files for wh40kdc 1.5.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 wh40kdc 1.5.0
File Size Uploaded Provenance Actions
wh40kdc-1.5.0.tar.gz 2.1 MB With provenance Details for wh40kdc-1.5.0.tar.gz

Built distribution (wheel)

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

Total release size: 4.3 MB

Release files / wh40kdc-1.5.0.tar.gz

Download URL wh40kdc-1.5.0.tar.gz
Size 2.1 MB
Tags Source
SHA-256 checksum
How to use checksums
0dab683d0cf6dadca030cb3dfafbdd6dedbee6bd70977db31a8eba1898588588
BLAKE2b-256 checksum
How to use checksums
53f6f731595f9c9a364956007f91a0976b13d375ebe238c78f20f41061aabae3
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 8, 2026.

Transparency log

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

Download URL wh40kdc-1.5.0-py3-none-any.whl
Size 2.2 MB
Tags Python 3
SHA-256 checksum
How to use checksums
bd17c96f75cf2906c3f7a0f2ad31e3087869cb765e7dec81646a452b89bdad2e
BLAKE2b-256 checksum
How to use checksums
c67427f77ea87f393f5281914b4b5c5b33702f37a17c1c06ca5e2437be0f488e
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 8, 2026.

Transparency log

Security for wh40kdc 1.5.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 wh40kdc-1.5.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 Nov 8, 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.0 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