Python bindings for the Takumi Rust renderer
Project description
takumi-py
takumi-py provides Python 3.10+ bindings for the Takumi Rust renderer.
[!IMPORTANT]
takumi-pyis currently in a testing stage. APIs, wheel build targets, release automation, and exception types may still change while the Takumi core binding surface is completed; do not treat it as a stable production dependency yet.
The binding focuses on exposing practical Takumi core capabilities instead of copying the WASM/JS convenience layer. It currently supports:
- Node Tree, HTML string, and Jinja template rendering into image bytes.
RenderOptions, including auto viewport, DPR, debug border, dithering, andtime_ms.- Custom fonts, a persistent image store, and per-render fetched resources.
- Layout measurement with a typed measured node tree result.
- CSS animation time sampling, sequence animation, and WebP/APNG/GIF animated encoders.
- PEP 561 typing, with
_core.pyicovering the public native binding surface.
It intentionally does not include Playwright fallback, remote fetch, abort signal support, data URL convenience APIs, a Node.js sidecar, or Takumi internal layout/cache/glyph types.
Development
uv sync --all-groups --all-extras
uv run maturin develop
make check
make check runs Ruff formatting and linting, ty, pytest with coverage, and
the Rust formatting/build checks.
Install From Source
uv sync --all-groups --all-extras
uv run maturin develop
Node Tree
from pathlib import Path
from takumi_py import Renderer
renderer = Renderer()
png = renderer.render_node(
{"type": "text", "text": "Hello from Python"},
stylesheets=["span { font-size: 72px; color: black; }"],
width=1200,
height=630,
)
Path("out.png").write_bytes(png)
Render Options
from takumi_py import RenderOptions, Renderer
raw = Renderer().render_node(
{
"type": "container",
"style": {
"width": "240px",
"height": "120px",
"backgroundColor": "white",
},
},
options=RenderOptions(
width=None,
height=None,
format="raw",
device_pixel_ratio=2.0,
dithering="ordered-bayer",
),
)
HTML
from takumi_py import Renderer
html = """
<div class="card">
<h1>Hello</h1>
</div>
<style>
.card {
width: 1200px;
height: 630px;
display: flex;
align-items: center;
justify-content: center;
color: white;
background: #111827;
}
</style>
"""
png = Renderer().render_html(html, width=1200, height=630)
Measure
from takumi_py import Renderer
measured = Renderer().measure_node(
{
"type": "container",
"style": {"width": "240px", "height": "120px"},
"children": [{"type": "text", "text": "Hello"}],
},
width=240,
height=120,
)
print(measured.width, measured.height)
Resources
from pathlib import Path
from takumi_py import FontResource, ImageResource, Renderer
renderer = Renderer(load_default_fonts=False)
renderer.load_font(FontResource(Path("Inter-Regular.woff2").read_bytes()))
renderer.put_persistent_image(
ImageResource("memory://logo", Path("logo.svg").read_bytes())
)
png = renderer.render_node(
{"type": "image", "src": "memory://logo", "width": 128, "height": 128},
width=128,
height=128,
)
Animation
from takumi_py import AnimationScene, Renderer
renderer = Renderer()
frame = renderer.render_html(
"""
<div class="box"></div>
<style>
@keyframes fade {
from { opacity: 0; }
to { opacity: 1; }
}
.box {
width: 64px;
height: 64px;
background: black;
animation: fade 1000ms both;
}
</style>
""",
width=64,
height=64,
time_ms=500,
)
webp = renderer.render_animation(
[
AnimationScene(
{
"type": "container",
"style": {
"width": "100%",
"height": "100%",
"backgroundColor": "black",
},
},
duration_ms=100,
),
AnimationScene(
{
"type": "container",
"style": {
"width": "100%",
"height": "100%",
"backgroundColor": "white",
},
},
duration_ms=100,
),
],
width=64,
height=64,
fps=20,
)
Jinja
from takumi_py import TemplateRenderer
renderer = TemplateRenderer("examples/templates")
png = renderer.render(
"card.html.jinja",
{
"title": "takumi-py",
"subtitle": "HTML / Jinja to image",
},
width=1200,
height=630,
)
Release
Releases are handled by GitHub Actions. After the release commit is on main, tag that commit with vX.Y.Z and push the tag to build wheels/sdist, publish to PyPI, and create a GitHub Release.
git tag v0.1.0 <commit-on-main>
git push origin main v0.1.0
The tag must match project.version in pyproject.toml; for example, version 0.1.0 must be released as v0.1.0.
Test Coverage
The Python test suite covers static rendering, the HTML adapter, templates, core fixtures, options, measurement, resources, animation, typing artifacts, and generated HTML fixtures from the upstream Takumi core test suite.
License
takumi-py is licensed under GPL-3.0-or-later. See LICENSE.
This repository includes takumi as a git submodule. takumi is licensed
separately under MIT OR Apache-2.0; see
THIRD_PARTY_NOTICES.md.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distributions
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file takumi_py-0.1.0.tar.gz.
File metadata
- Download URL: takumi_py-0.1.0.tar.gz
- Upload date:
- Size: 6.2 MB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.13
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
0d3d7264c856a9ec28b1550b90fd887ccfbf25fdb2bbfab81650465fe74cfbef
|
|
| MD5 |
5ed29fddbe70b848b5d792b722b418a9
|
|
| BLAKE2b-256 |
d2cabb695c22e3854330a08e2ff0a242c5a53fd3bf3cbe918687a8831a4e8d4d
|
Provenance
The following attestation bundles were made for takumi_py-0.1.0.tar.gz:
Publisher:
publish.yml on BalconyJH/takumi-py
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
takumi_py-0.1.0.tar.gz -
Subject digest:
0d3d7264c856a9ec28b1550b90fd887ccfbf25fdb2bbfab81650465fe74cfbef - Sigstore transparency entry: 1780684803
- Sigstore integration time:
-
Permalink:
BalconyJH/takumi-py@cbd2624affdd86327ebb555d2a05fa2e09794a5e -
Branch / Tag:
refs/heads/main - Owner: https://github.com/BalconyJH
-
Access:
private
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@cbd2624affdd86327ebb555d2a05fa2e09794a5e -
Trigger Event:
workflow_dispatch
-
Statement type:
File details
Details for the file takumi_py-0.1.0-cp310-abi3-win_amd64.whl.
File metadata
- Download URL: takumi_py-0.1.0-cp310-abi3-win_amd64.whl
- Upload date:
- Size: 3.7 MB
- Tags: CPython 3.10+, Windows x86-64
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.13
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
8a6a6a4aa417afcbd39c75a522440a156fe522e8de19cc104631913e1f06ca7f
|
|
| MD5 |
d9fd4ec235b337cc4083085f2e711d0a
|
|
| BLAKE2b-256 |
b56ce218630d5d301a7e252604f4c8b930384b50db38a6ae54acf614acfb3d81
|
Provenance
The following attestation bundles were made for takumi_py-0.1.0-cp310-abi3-win_amd64.whl:
Publisher:
publish.yml on BalconyJH/takumi-py
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
takumi_py-0.1.0-cp310-abi3-win_amd64.whl -
Subject digest:
8a6a6a4aa417afcbd39c75a522440a156fe522e8de19cc104631913e1f06ca7f - Sigstore transparency entry: 1780685572
- Sigstore integration time:
-
Permalink:
BalconyJH/takumi-py@cbd2624affdd86327ebb555d2a05fa2e09794a5e -
Branch / Tag:
refs/heads/main - Owner: https://github.com/BalconyJH
-
Access:
private
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@cbd2624affdd86327ebb555d2a05fa2e09794a5e -
Trigger Event:
workflow_dispatch
-
Statement type:
File details
Details for the file takumi_py-0.1.0-cp310-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.
File metadata
- Download URL: takumi_py-0.1.0-cp310-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
- Upload date:
- Size: 4.2 MB
- Tags: CPython 3.10+, manylinux: glibc 2.17+ x86-64
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.13
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
ed6f9ca834c7e61d4c00ea9751a39b81ee587a4de3765889b327ba89f4dea6c4
|
|
| MD5 |
3c4ebf0fc51ad4435ecb554ac5fd186e
|
|
| BLAKE2b-256 |
3975c5a552ed19834fa79367ebc317ff0ddd18187673ef370c9a7ee2ea328cb2
|
Provenance
The following attestation bundles were made for takumi_py-0.1.0-cp310-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl:
Publisher:
publish.yml on BalconyJH/takumi-py
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
takumi_py-0.1.0-cp310-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl -
Subject digest:
ed6f9ca834c7e61d4c00ea9751a39b81ee587a4de3765889b327ba89f4dea6c4 - Sigstore transparency entry: 1780686747
- Sigstore integration time:
-
Permalink:
BalconyJH/takumi-py@cbd2624affdd86327ebb555d2a05fa2e09794a5e -
Branch / Tag:
refs/heads/main - Owner: https://github.com/BalconyJH
-
Access:
private
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@cbd2624affdd86327ebb555d2a05fa2e09794a5e -
Trigger Event:
workflow_dispatch
-
Statement type:
File details
Details for the file takumi_py-0.1.0-cp310-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl.
File metadata
- Download URL: takumi_py-0.1.0-cp310-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
- Upload date:
- Size: 4.1 MB
- Tags: CPython 3.10+, manylinux: glibc 2.17+ ARM64
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.13
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
339e0665767e5a74c90b680d17d3179acc44a02c405297394fcd3cf8c044a479
|
|
| MD5 |
ca05c6140e621a42d9c9f8aef66f0820
|
|
| BLAKE2b-256 |
71bb0f83c582c07c63715be92e9faf48e57e414f53ecede07055a346f453b51b
|
Provenance
The following attestation bundles were made for takumi_py-0.1.0-cp310-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl:
Publisher:
publish.yml on BalconyJH/takumi-py
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
takumi_py-0.1.0-cp310-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl -
Subject digest:
339e0665767e5a74c90b680d17d3179acc44a02c405297394fcd3cf8c044a479 - Sigstore transparency entry: 1780685647
- Sigstore integration time:
-
Permalink:
BalconyJH/takumi-py@cbd2624affdd86327ebb555d2a05fa2e09794a5e -
Branch / Tag:
refs/heads/main - Owner: https://github.com/BalconyJH
-
Access:
private
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@cbd2624affdd86327ebb555d2a05fa2e09794a5e -
Trigger Event:
workflow_dispatch
-
Statement type:
File details
Details for the file takumi_py-0.1.0-cp310-abi3-macosx_11_0_arm64.whl.
File metadata
- Download URL: takumi_py-0.1.0-cp310-abi3-macosx_11_0_arm64.whl
- Upload date:
- Size: 3.8 MB
- Tags: CPython 3.10+, macOS 11.0+ ARM64
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.13
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
be3cbf23a7556844ae43f7dadce4950fd0bbab37378ab72fc0adfdb3c2954318
|
|
| MD5 |
ca9c8eb925f2cffed84fc8c031546497
|
|
| BLAKE2b-256 |
49f4491e04079f385f78349ba9cc8770c34a35407e634f7ce1e34e13655f77e2
|
Provenance
The following attestation bundles were made for takumi_py-0.1.0-cp310-abi3-macosx_11_0_arm64.whl:
Publisher:
publish.yml on BalconyJH/takumi-py
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
takumi_py-0.1.0-cp310-abi3-macosx_11_0_arm64.whl -
Subject digest:
be3cbf23a7556844ae43f7dadce4950fd0bbab37378ab72fc0adfdb3c2954318 - Sigstore transparency entry: 1780685771
- Sigstore integration time:
-
Permalink:
BalconyJH/takumi-py@cbd2624affdd86327ebb555d2a05fa2e09794a5e -
Branch / Tag:
refs/heads/main - Owner: https://github.com/BalconyJH
-
Access:
private
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@cbd2624affdd86327ebb555d2a05fa2e09794a5e -
Trigger Event:
workflow_dispatch
-
Statement type:
File details
Details for the file takumi_py-0.1.0-cp310-abi3-macosx_10_12_x86_64.whl.
File metadata
- Download URL: takumi_py-0.1.0-cp310-abi3-macosx_10_12_x86_64.whl
- Upload date:
- Size: 4.0 MB
- Tags: CPython 3.10+, macOS 10.12+ x86-64
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.13
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
aa892317db46caab029960f23124bc99d303328c520c56c5b467c1dc4ddbd86e
|
|
| MD5 |
a6fa8c0da68e9793e9328daf192bf7fb
|
|
| BLAKE2b-256 |
b8a7c0d2dd1d9f3017c61659731d4dec46eab256f11e8a3757c68096bd9ae64b
|
Provenance
The following attestation bundles were made for takumi_py-0.1.0-cp310-abi3-macosx_10_12_x86_64.whl:
Publisher:
publish.yml on BalconyJH/takumi-py
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
takumi_py-0.1.0-cp310-abi3-macosx_10_12_x86_64.whl -
Subject digest:
aa892317db46caab029960f23124bc99d303328c520c56c5b467c1dc4ddbd86e - Sigstore transparency entry: 1780685486
- Sigstore integration time:
-
Permalink:
BalconyJH/takumi-py@cbd2624affdd86327ebb555d2a05fa2e09794a5e -
Branch / Tag:
refs/heads/main - Owner: https://github.com/BalconyJH
-
Access:
private
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@cbd2624affdd86327ebb555d2a05fa2e09794a5e -
Trigger Event:
workflow_dispatch
-
Statement type: