Development¶
Prepare the environment¶
The Rust toolchain is pinned by rust-toolchain.toml. Project lock files manage
Python, Rust, and documentation dependencies; do not patch the repository environment
with ad hoc pip install commands.
Common checks¶
make check runs Ruff, ty, mypy.stubtest for the native extension, pytest,
Rustfmt, and Clippy. The documentation build runs separately because it uses the docs
dependency group: it checks that the Chinese pages mirror the English source, then
builds both languages strictly, treating warnings as failures. The manual Actionlint
stage validates embedded workflow shell scripts in addition to the normal repository
hooks.
The checkers are pinned so that results only change when the repository does: the
Prek hooks by rev in prek.toml, and ty, which is still at 0.0.x, to one exact
version in the dev dependency group. Upgrade ty by raising its pin and fixing what
make typecheck reports in the same commit; keep the Ruff hook rev and the locked
Ruff version in step.
Tests¶
The pytest suite lives in tests/ and runs in parallel through make test:
| Module | Covers |
|---|---|
test_render_node.py, test_render_html.py, test_render_template.py |
The node, HTML, and template entry points |
test_html_adapter.py, test_inline_style.py |
HTML parsing and inline styles |
test_core_binding_features.py |
Options, fonts, images, caches, measurement, SVG, and animation |
test_takumi_core_fixtures.py |
Every upstream HTML fixture under takumilib/takumi/tests/fixtures-html renders |
test_examples.py |
Every script in examples/ runs and writes its output |
test_typing_surface.py |
The documented public Renderer surface and native typing artifacts |
test_repository_scripts.py |
The release, changelog, docs deployment, and docs translation scripts in .github/scripts/ |
Distribution contract¶
Build the current platform wheel and sdist through the same local contract used by CI:
The target checks metadata and archive contents, installs the wheel in a temporary
environment outside the checkout, rebuilds a wheel from the sdist, and runs the native
rendering smoke against both paths. Use make verify-artifacts DIST_DIR=/path/to/dist
to validate an existing local pair.
Native extension¶
The Python package loads from python/, and the native module is named
takumi_py._core. Rebuild it after changing Rust binding code:
Rebuild before testing binding changes
Running Python tests without rebuilding can accidentally exercise a stale native artifact from the previous compilation.
Takumi submodule¶
Takumi is an explicit source dependency of this repository. Pin takumilib to the
upstream release commit that a takumi@X.Y.Z tag points to, never to a branch tip or
a local merge:
git -C takumilib fetch origin --tags
git -C takumilib checkout --detach 'takumi@2.17.1^{commit}'
cargo update -w
An upgrade must check:
- The submodule revision and
Cargo.lock - Version constraints for
takumiandtakumi-core - Deprecations in the upstream API: Clippy runs with
-D warnings, so a deprecated call fails the build. Adopt the replacement that the Node binding intakumilib/takumi-napiuses, and surface the change as a PythonDeprecationWarning - New upstream capabilities worth exposing, by comparing the Node binding's surface
with
Renderer - That the build stays within the toolchain in
rust-toolchain.toml:rust-versionkeeps the resolver on compatible crates, and runningcargo +1.91.0 clippy --locked --all-targetsthrough rustup confirms it - That the HTML fixtures read by
tests/test_takumi_core_fixtures.pystill exist undertakumilib/takumi/tests/fixtures-html - Whether the source distribution can still rebuild a wheel in isolation
- Whether assets referenced by the binding under
takumilib/assetschanged
Upstream's [patch.crates-io] forks of fontations and harfrust apply only inside the
Takumi workspace. This crate builds against the crates.io releases, so a patch upstream
adds is not inherited.
The repository checkout is not an sdist dependency
Never hide missing distribution files by reading them from the surrounding checkout. The CI sdist smoke test must build and run entirely from the isolated source archive.