Cython bindings for the ThorVG vector graphics library
Project description
thorvg-cython
Cython bindings for the ThorVG vector graphics library.
Overview
This package provides direct C-level bindings to ThorVG via Cython — no ctypes overhead.
It mirrors the thorvg-python API surface while delivering native-extension performance.
Platform Support
| Platform | Linking Strategy |
|---|---|
iOS (sys.platform == "ios") |
Links against thorvg.xcframework static slice |
macOS (sys.platform == "darwin") |
Links against libthorvg.a or libthorvg-1.dylib |
| Linux | Links against libthorvg.so |
| Windows | Links against thorvg.lib / thorvg-1.dll |
| Android | Links against libthorvg.so |
Building
Prerequisites
- Python ≥ 3.9
- Cython ≥ 3.0
- ThorVG built with C API bindings (
-Dbindings=capi)
Quick Build (macOS)
# 1. Build ThorVG
cd /path/to/thorvg
export SDKROOT=$(xcrun --show-sdk-path)
meson setup builddir --buildtype=release --default-library=static -Dbindings=capi -Dloaders=svg,lottie,ttf
ninja -C builddir
# 2. Build the wheel
cd thorvg-cython
THORVG_ROOT=.. THORVG_LIB_DIR=../builddir/src pip install -e .
Environment Variables
| Variable | Description | Default |
|---|---|---|
THORVG_ROOT |
Path to thorvg source root | Parent of this package |
THORVG_INCLUDE |
Path to thorvg.h |
$THORVG_ROOT/inc |
THORVG_LIB_DIR |
Path to built libraries | $THORVG_ROOT/output |
THORVG_XCFRAMEWORK |
Path to .xcframework |
$THORVG_ROOT/output/thorvg.xcframework |
THORVG_CAPI_INCLUDE |
Path to thorvg_capi.h |
$THORVG_ROOT/src/bindings/capi |
cibuildwheel
pip install cibuildwheel
cibuildwheel --platform macos
Usage
import thorvg_cython as tvg
with tvg.Engine(threads=2) as engine:
canvas = tvg.SwCanvas(800, 600)
shape = tvg.Shape()
shape.append_rect(0, 0, 100, 100, rx=10, ry=10)
shape.set_fill_color(255, 0, 0)
canvas.add(shape)
canvas.draw()
canvas.sync()
Zero-Copy Buffer Protocol (PEP 3118)
SwCanvas implements the Python buffer protocol directly — no intermediate
copies needed when passing pixel data to other frameworks.
Snapshot as bytes:
import thorvg_cython as tvg
with tvg.Engine(threads=2):
canvas = tvg.SwCanvas(800, 600)
# Draw a red rounded rectangle
shape = tvg.Shape()
shape.append_rect(50, 50, 200, 150, rx=20, ry=20)
shape.set_fill_color(255, 0, 0)
canvas.add(shape)
# Load and render an SVG
pic = tvg.Picture()
pic.load("icon.svg")
pic.set_size(100, 100)
canvas.add(pic)
canvas.draw()
canvas.sync()
raw = bytes(canvas) # flat RGBA, 800×600×4 = 1_920_000 bytes
Kivy texture (zero-copy blit):
from kivy.graphics.texture import Texture
import thorvg_cython as tvg
with tvg.Engine():
texture = Texture.create(size=(800, 600), colorfmt='rgba')
canvas = tvg.SwCanvas(800, 600)
# Load a Lottie animation
pic = tvg.Picture()
pic.load("animation.json")
pic.set_size(800, 600)
canvas.add(pic)
# Initial render
canvas.draw()
canvas.sync()
texture.blit_buffer(canvas, colorfmt='rgba', bufferfmt='ubyte')
# Move the animation and re-render — same canvas, same texture
pic.translate(100, 50)
pic.set_opacity(180)
canvas.update()
canvas.draw()
canvas.sync()
texture.blit_buffer(canvas, colorfmt='rgba', bufferfmt='ubyte')
NumPy array (zero-copy view):
import numpy as np
import thorvg_cython as tvg
with tvg.Engine():
canvas = tvg.SwCanvas(400, 300)
shape = tvg.Shape()
shape.append_circle(200, 150, 100, 100)
shape.set_fill_color(0, 120, 255)
canvas.add(shape)
canvas.draw()
canvas.sync()
# Live view into the canvas pixel buffer — no copy
arr = np.frombuffer(canvas, dtype=np.uint8).reshape(300, 400, 4)
arr[:, :, 3] = 128 # set alpha to 50% — modifies canvas directly
memoryview (stdlib, zero-copy):
import thorvg_cython as tvg
with tvg.Engine():
canvas = tvg.SwCanvas(256, 256)
shape = tvg.Shape()
shape.append_rect(0, 0, 256, 256)
shape.set_fill_color(0, 0, 0)
canvas.add(shape)
canvas.draw()
canvas.sync()
mv = memoryview(canvas)
print(len(mv)) # 262_144
mv[0:4] # first pixel RGBA bytes
License
MIT — same as ThorVG.
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 thorvg_cython-0.0.1.tar.gz.
File metadata
- Download URL: thorvg_cython-0.0.1.tar.gz
- Upload date:
- Size: 235.7 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
4f1ad19189b569cdd89ad3aa801ee4147b7d554cdff71c09440b88c1d6986143
|
|
| MD5 |
2f7d2a40291457579dbed1c048f9415f
|
|
| BLAKE2b-256 |
058508af66a6e27e1f1140fb766fb59cb68ac3cebd728b7308e18263554e7608
|
Provenance
The following attestation bundles were made for thorvg_cython-0.0.1.tar.gz:
Publisher:
pypi-publish.yml on Py-Swift/thorvg-cython
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
thorvg_cython-0.0.1.tar.gz -
Subject digest:
4f1ad19189b569cdd89ad3aa801ee4147b7d554cdff71c09440b88c1d6986143 - Sigstore transparency entry: 1069297423
- Sigstore integration time:
-
Permalink:
Py-Swift/thorvg-cython@1d8367bcf4ca7019ca80f921018d0a815e143646 -
Branch / Tag:
refs/tags/v0.0.1 - Owner: https://github.com/Py-Swift
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
pypi-publish.yml@1d8367bcf4ca7019ca80f921018d0a815e143646 -
Trigger Event:
release
-
Statement type:
File details
Details for the file thorvg_cython-0.0.1-cp313-cp313-win_amd64.whl.
File metadata
- Download URL: thorvg_cython-0.0.1-cp313-cp313-win_amd64.whl
- Upload date:
- Size: 565.7 kB
- Tags: CPython 3.13, Windows x86-64
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
482981425c82c4731b13900a13aba580dcf4147417c2f2753d5a2cf5a8e059b5
|
|
| MD5 |
22bf5495c8d2a4839dc593801d7bfed6
|
|
| BLAKE2b-256 |
eb8effa27abaa458c8e587d469e783dbe78ae3c34080b2637ef23b48ca13ec38
|
Provenance
The following attestation bundles were made for thorvg_cython-0.0.1-cp313-cp313-win_amd64.whl:
Publisher:
pypi-publish.yml on Py-Swift/thorvg-cython
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
thorvg_cython-0.0.1-cp313-cp313-win_amd64.whl -
Subject digest:
482981425c82c4731b13900a13aba580dcf4147417c2f2753d5a2cf5a8e059b5 - Sigstore transparency entry: 1069297433
- Sigstore integration time:
-
Permalink:
Py-Swift/thorvg-cython@1d8367bcf4ca7019ca80f921018d0a815e143646 -
Branch / Tag:
refs/tags/v0.0.1 - Owner: https://github.com/Py-Swift
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
pypi-publish.yml@1d8367bcf4ca7019ca80f921018d0a815e143646 -
Trigger Event:
release
-
Statement type:
File details
Details for the file thorvg_cython-0.0.1-cp313-cp313-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl.
File metadata
- Download URL: thorvg_cython-0.0.1-cp313-cp313-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl
- Upload date:
- Size: 1.7 MB
- Tags: CPython 3.13, manylinux: glibc 2.27+ x86-64, manylinux: glibc 2.28+ x86-64
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
85785abac12abcd7f3c27aba761921ba3e24622a199a8d004947ad5d1465a90c
|
|
| MD5 |
d8b15284f0b400c48fdfea7ebed481dc
|
|
| BLAKE2b-256 |
753cc8f112aa4197a95f8faf5d25cd2831d89cbdc36abe755a81d79c60aceec0
|
Provenance
The following attestation bundles were made for thorvg_cython-0.0.1-cp313-cp313-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl:
Publisher:
pypi-publish.yml on Py-Swift/thorvg-cython
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
thorvg_cython-0.0.1-cp313-cp313-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl -
Subject digest:
85785abac12abcd7f3c27aba761921ba3e24622a199a8d004947ad5d1465a90c - Sigstore transparency entry: 1069297445
- Sigstore integration time:
-
Permalink:
Py-Swift/thorvg-cython@1d8367bcf4ca7019ca80f921018d0a815e143646 -
Branch / Tag:
refs/tags/v0.0.1 - Owner: https://github.com/Py-Swift
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
pypi-publish.yml@1d8367bcf4ca7019ca80f921018d0a815e143646 -
Trigger Event:
release
-
Statement type:
File details
Details for the file thorvg_cython-0.0.1-cp313-cp313-macosx_11_0_arm64.whl.
File metadata
- Download URL: thorvg_cython-0.0.1-cp313-cp313-macosx_11_0_arm64.whl
- Upload date:
- Size: 572.4 kB
- Tags: CPython 3.13, macOS 11.0+ ARM64
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
87d441a016e3de77986904f5cfcf9880ab8e61ce998eb400e9e88e44bf52af2b
|
|
| MD5 |
857e1e6f06351ff047b541431018773c
|
|
| BLAKE2b-256 |
1ffa69e3c745cb385fe9e611504eb055c5abbca2a813229b8dbb1ccaa311c63e
|
Provenance
The following attestation bundles were made for thorvg_cython-0.0.1-cp313-cp313-macosx_11_0_arm64.whl:
Publisher:
pypi-publish.yml on Py-Swift/thorvg-cython
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
thorvg_cython-0.0.1-cp313-cp313-macosx_11_0_arm64.whl -
Subject digest:
87d441a016e3de77986904f5cfcf9880ab8e61ce998eb400e9e88e44bf52af2b - Sigstore transparency entry: 1069297448
- Sigstore integration time:
-
Permalink:
Py-Swift/thorvg-cython@1d8367bcf4ca7019ca80f921018d0a815e143646 -
Branch / Tag:
refs/tags/v0.0.1 - Owner: https://github.com/Py-Swift
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
pypi-publish.yml@1d8367bcf4ca7019ca80f921018d0a815e143646 -
Trigger Event:
release
-
Statement type:
File details
Details for the file thorvg_cython-0.0.1-cp313-cp313-ios_13_0_x86_64_iphonesimulator.whl.
File metadata
- Download URL: thorvg_cython-0.0.1-cp313-cp313-ios_13_0_x86_64_iphonesimulator.whl
- Upload date:
- Size: 2.4 MB
- Tags: CPython 3.13, iOS 13.0+ x86-64 Simulator
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
0983951324072565d3999967dce5ef924ffc35105598fb8559ec23c14694eafb
|
|
| MD5 |
70c13dc6abfcb00401c08aa880ef3242
|
|
| BLAKE2b-256 |
115397ac00280e7b603dee59613cac8ea69032b81347ffd94035bd7a89837fbb
|
Provenance
The following attestation bundles were made for thorvg_cython-0.0.1-cp313-cp313-ios_13_0_x86_64_iphonesimulator.whl:
Publisher:
pypi-publish.yml on Py-Swift/thorvg-cython
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
thorvg_cython-0.0.1-cp313-cp313-ios_13_0_x86_64_iphonesimulator.whl -
Subject digest:
0983951324072565d3999967dce5ef924ffc35105598fb8559ec23c14694eafb - Sigstore transparency entry: 1069297436
- Sigstore integration time:
-
Permalink:
Py-Swift/thorvg-cython@1d8367bcf4ca7019ca80f921018d0a815e143646 -
Branch / Tag:
refs/tags/v0.0.1 - Owner: https://github.com/Py-Swift
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
pypi-publish.yml@1d8367bcf4ca7019ca80f921018d0a815e143646 -
Trigger Event:
release
-
Statement type:
File details
Details for the file thorvg_cython-0.0.1-cp313-cp313-ios_13_0_arm64_iphonesimulator.whl.
File metadata
- Download URL: thorvg_cython-0.0.1-cp313-cp313-ios_13_0_arm64_iphonesimulator.whl
- Upload date:
- Size: 2.4 MB
- Tags: CPython 3.13, iOS 13.0+ ARM64 Simulator
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
f1083c0d3ea1af2cbcec9654219f07c6c0fb8c8f1824d763b1305900055238de
|
|
| MD5 |
63407a8ffaf95c556f8b1c90cf90b36f
|
|
| BLAKE2b-256 |
b0d16d1432554e17a96d3220793208adae443d00161d1e3a70075ec71ffb52d9
|
Provenance
The following attestation bundles were made for thorvg_cython-0.0.1-cp313-cp313-ios_13_0_arm64_iphonesimulator.whl:
Publisher:
pypi-publish.yml on Py-Swift/thorvg-cython
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
thorvg_cython-0.0.1-cp313-cp313-ios_13_0_arm64_iphonesimulator.whl -
Subject digest:
f1083c0d3ea1af2cbcec9654219f07c6c0fb8c8f1824d763b1305900055238de - Sigstore transparency entry: 1069297442
- Sigstore integration time:
-
Permalink:
Py-Swift/thorvg-cython@1d8367bcf4ca7019ca80f921018d0a815e143646 -
Branch / Tag:
refs/tags/v0.0.1 - Owner: https://github.com/Py-Swift
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
pypi-publish.yml@1d8367bcf4ca7019ca80f921018d0a815e143646 -
Trigger Event:
release
-
Statement type:
File details
Details for the file thorvg_cython-0.0.1-cp313-cp313-ios_13_0_arm64_iphoneos.whl.
File metadata
- Download URL: thorvg_cython-0.0.1-cp313-cp313-ios_13_0_arm64_iphoneos.whl
- Upload date:
- Size: 2.4 MB
- Tags: CPython 3.13, iOS 13.0+ ARM64 Device
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
a542fee409b840beec45e6e7bc617f29a9c3d9e58c90b72c398d4705ad8e0926
|
|
| MD5 |
2939938790de6ad08c415d80c29ff3f0
|
|
| BLAKE2b-256 |
32e30cc0df55c8fe6e88c9fb1498e185f9d97985dc33127248db820bd9bac89c
|
Provenance
The following attestation bundles were made for thorvg_cython-0.0.1-cp313-cp313-ios_13_0_arm64_iphoneos.whl:
Publisher:
pypi-publish.yml on Py-Swift/thorvg-cython
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
thorvg_cython-0.0.1-cp313-cp313-ios_13_0_arm64_iphoneos.whl -
Subject digest:
a542fee409b840beec45e6e7bc617f29a9c3d9e58c90b72c398d4705ad8e0926 - Sigstore transparency entry: 1069297441
- Sigstore integration time:
-
Permalink:
Py-Swift/thorvg-cython@1d8367bcf4ca7019ca80f921018d0a815e143646 -
Branch / Tag:
refs/tags/v0.0.1 - Owner: https://github.com/Py-Swift
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
pypi-publish.yml@1d8367bcf4ca7019ca80f921018d0a815e143646 -
Trigger Event:
release
-
Statement type:
File details
Details for the file thorvg_cython-0.0.1-cp313-cp313-android_24_x86_64.whl.
File metadata
- Download URL: thorvg_cython-0.0.1-cp313-cp313-android_24_x86_64.whl
- Upload date:
- Size: 1.1 MB
- Tags: Android API level 24+ x86-64, CPython 3.13
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
aaa69cab4a96a7f07a11a96f826df4bc2a584da07d71d9f1890ef8ad3fb9532a
|
|
| MD5 |
0272ad7fd73b157aa6afde470f3004b2
|
|
| BLAKE2b-256 |
0e24d22a806c0aecd7c5db91a2bf122e9de869de531e076bc2b6b2e8981e8373
|
Provenance
The following attestation bundles were made for thorvg_cython-0.0.1-cp313-cp313-android_24_x86_64.whl:
Publisher:
pypi-publish.yml on Py-Swift/thorvg-cython
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
thorvg_cython-0.0.1-cp313-cp313-android_24_x86_64.whl -
Subject digest:
aaa69cab4a96a7f07a11a96f826df4bc2a584da07d71d9f1890ef8ad3fb9532a - Sigstore transparency entry: 1069297429
- Sigstore integration time:
-
Permalink:
Py-Swift/thorvg-cython@1d8367bcf4ca7019ca80f921018d0a815e143646 -
Branch / Tag:
refs/tags/v0.0.1 - Owner: https://github.com/Py-Swift
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
pypi-publish.yml@1d8367bcf4ca7019ca80f921018d0a815e143646 -
Trigger Event:
release
-
Statement type: