Skip to main content

Luvatrix

Luvatrix is a Python app protocol and rendering runtime for building custom apps that can run headless, on macOS, as static browser-side web apps, and through scaffolded native Android/iOS projects.

Install

Base install:

pip install luvatrix

Optional platform/runtime extras:

pip install "luvatrix[macos]"
pip install "luvatrix[vulkan]"
pip install "luvatrix[macos,vulkan]"
pip install "luvatrix[web]"
pip install "luvatrix[android]"
pip install "luvatrix[ios]"

The base package intentionally includes common raster/data dependencies (numpy and Pillow). Platform-specific renderers still live behind extras. Extras are target-scoped: installing luvatrix[ios] does not install macOS PyObjC bindings, Vulkan bindings, web socket runtimes, or Android-only helpers. iOS ABI-specific packages are prepared by the native scaffold's ios/scripts/setup_ios.sh and copied into the app-owned PyPackages bundle.

Create An External App

Create a standalone app outside this repository:

luvatrix init-app my_app
cd my_app
luvatrix validate-app . --render headless
luvatrix run-app . --render headless --ticks 1

For an Android-only app, validate against the Android runtime from your development machine:

luvatrix init-app my_android_app --template camera
cd my_android_app
luvatrix validate-app . --render android-emulator
luvatrix run-app . --render headless --ticks 1

Build and serve a browser-side app:

luvatrix build-web . --out dist/web
luvatrix serve-web .

Run with macOS rendering:

pip install "luvatrix[macos,vulkan]"
luvatrix validate-app . --render macos
luvatrix run-app . --render macos

Native Scaffolds

Native Android and iOS projects are app-owned. Scaffold them into your app repository when you need native targets:

luvatrix init-native . --target android --out android
luvatrix init-native . --target ios --out ios

Initialized native projects include per-file scaffold provenance. Upgrade untouched template files while preserving app customizations with:

luvatrix upgrade-native . --target android --out android

For native projects created before provenance tracking, run once with --adopt. Customized files are preserved and current-template candidates are written under .luvatrix-scaffold-updates/ for review.

Measured release improvements and their raw trial data are indexed in docs/performance/.

Then run with the app-owned native project:

luvatrix run-app . --render android-emulator --native-project android
luvatrix run-app . --render ios-simulator --native-project ios

Native prerequisites:

  • Android: Android SDK, ADB, Gradle/Android Gradle Plugin support, and a configured emulator or device.
  • iOS: Xcode, xcodegen, signing for physical devices, and the iOS Python support assets prepared by the scaffold's ios/scripts/setup_ios.sh.
  • Vulkan on macOS: the Python vulkan binding plus a native Vulkan SDK/loader such as Vulkan SDK or MoltenVK.

Native package sync also prunes unrelated platform runtimes from app bundles. Android bundles keep the Android runtime tree, iOS bundles keep the iOS runtime tree, and sibling macOS/web/native-template trees are left out unless that target is being packaged.

App Layout

A minimal Luvatrix app is just:

my_app/
├── app.toml
└── app_main.py

app.toml declares the app id, protocol version, entrypoint, capabilities, platform support, display metadata, and render preferences. The Python entrypoint returns an object compatible with init(ctx), loop(ctx, dt), and stop(ctx), or a subclass of luvatrix.app.App.

Public app-developer API:

from luvatrix.app import App, AppContext, validate_app_install

See docs/app_protocol.md in the repository for the detailed protocol contract.

Google Sign-In

Luvatrix provides an in-app sign-in control and an event-driven controller. The user starts inside the app, authenticates in Google's trusted system browser surface, and returns to the same app through its configured callback URL.

from luvatrix.app import App
from luvatrix.auth import (
    GoogleOAuthClient,
    GoogleOAuthConfig,
    GoogleSignInController,
    PlatformGoogleAuthSession,
    SecureTokenStore,
)
from luvatrix.auth.ui import GoogleSignInButton


class MyApp(App):
    def init(self, ctx):
        session = PlatformGoogleAuthSession(open_browser=my_native_bridge.open_google_auth)
        store = SecureTokenStore(
            read_secret=my_native_bridge.read_secret,
            write_secret=my_native_bridge.write_secret,
            delete_secret=my_native_bridge.delete_secret,
            key="google-account",
        )
        oauth = GoogleOAuthClient(
            GoogleOAuthConfig(
                client_id="YOUR_CLIENT_ID.apps.googleusercontent.com",
                redirect_uri="com.example.app:/oauth2redirect",
                scopes=("openid", "email", "profile"),
            ),
            token_store=store,
        )
        self.google = GoogleSignInController(
            oauth,
            session=session,
            invalidate=self.invalidate,
        )
        self.google_button = GoogleSignInButton(self.google)

    def loop(self, ctx, dt):
        state = self.input.snapshot()
        self.google_button.update(state, x=24, y=24, width=220, height=44)

    def render(self):
        with self.frame(clear=(14, 18, 26, 255)) as frame:
            self.google_button.render(frame, x=24, y=24, width=220, height=44)

The native callback handler calls session.deliver_callback(callback_url). Android bridges should open a Custom Tab and back SecureTokenStore with Android Keystore. iOS bridges should use ASWebAuthenticationSession and Keychain. InMemoryTokenStore remains available for tests, but production apps should not use it for long-lived refresh tokens. Mobile apps must not embed a Google client secret.

Prepared Text Wrapping

Luvatrix includes an optional, dependency-free prepared wrapping style inspired by the MIT-licensed Pretext architecture. Text is segmented and measured once; changing only the available width reuses those native measurements.

Scene/UI text uses TextWrapping on TextComponent:

from luvatrix.app import TextWrapping
from luvatrix_ui.text import TextComponent

body = TextComponent(
    component_id="body",
    text="A paragraph which should wrap across multiple lines.",
    max_width_px=320,
    wrapping=TextWrapping(white_space="normal"),
)

Matrix text uses the same layout engine and its matrix-font measurements:

from luvatrix.app import draw_text_to_matrix

draw_text_to_matrix(
    matrix,
    "A paragraph rendered into an RGBA matrix.",
    x=12,
    y=12,
    font_size_px=12,
    max_width_px=240,
    wrapping="pretext",
    line_height_multiplier=1.2,
)

white_space="pre-wrap" preserves repeated spaces and hard line breaks. Ordinary wrapping collapses whitespace and uses grapheme-safe emergency breaks for content wider than a complete line.

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

luvatrix-0.2.7.tar.gz (1.0 MB view details)

Uploaded Source

Built Distributions

If you're not sure about the file name format, learn more about wheel file names.

luvatrix-0.2.7-py3-none-any.whl (919.3 kB view details)

Uploaded Python 3

luvatrix-0.2.7-cp314-cp314-android_24_x86_64.whl (1.0 MB view details)

Uploaded Android API level 24+ x86-64CPython 3.14

luvatrix-0.2.7-cp314-cp314-android_24_arm64_v8a.whl (1.0 MB view details)

Uploaded Android API level 24+ ARM64 v8aCPython 3.14

File details

Details for the file luvatrix-0.2.7.tar.gz.

File metadata

  • Download URL: luvatrix-0.2.7.tar.gz
  • Upload date:
  • Size: 1.0 MB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.14

File hashes

Hashes for luvatrix-0.2.7.tar.gz
Algorithm Hash digest
SHA256 9a8e3e28f5b107ff9b840273c04da9c66b4a3e45916c0b19b28e4347ba930d98
MD5 28aedc854e0b73eb7f5a057abac0d816
BLAKE2b-256 e328ecaee764a6ff71b4dbd7fb2a4331f2f1f61b95f97983a74eddc815109300

See more details on using hashes here.

Provenance

The following attestation bundles were made for luvatrix-0.2.7.tar.gz:

Publisher: publish-pypi.yml on 0202alcc/luvatrix

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file luvatrix-0.2.7-py3-none-any.whl.

File metadata

  • Download URL: luvatrix-0.2.7-py3-none-any.whl
  • Upload date:
  • Size: 919.3 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.14

File hashes

Hashes for luvatrix-0.2.7-py3-none-any.whl
Algorithm Hash digest
SHA256 d530328b51ef5c417a07b9d53f3cab41c8bd579eb7c52ab80841798cf97f2bca
MD5 d24040dc0dbb1bb43d9fed3d1a6465d2
BLAKE2b-256 0df812844d1ead3a94ae06417db1657d2952fc6c34aff4b44fd9d2697a743b59

See more details on using hashes here.

Provenance

The following attestation bundles were made for luvatrix-0.2.7-py3-none-any.whl:

Publisher: publish-pypi.yml on 0202alcc/luvatrix

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file luvatrix-0.2.7-cp314-cp314-android_24_x86_64.whl.

File metadata

File hashes

Hashes for luvatrix-0.2.7-cp314-cp314-android_24_x86_64.whl
Algorithm Hash digest
SHA256 5ae2d665b5aaf083c2d3e5ce7cb5bd3548ec4a70bf34812d749cc76cb3c47e93
MD5 3da7fb452df27f30b75b6dc8a1c465b6
BLAKE2b-256 98a381790b385da6494b3a89b9a3ad602909a5b558e2fb14020d00f4116e2aef

See more details on using hashes here.

Provenance

The following attestation bundles were made for luvatrix-0.2.7-cp314-cp314-android_24_x86_64.whl:

Publisher: publish-pypi.yml on 0202alcc/luvatrix

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file luvatrix-0.2.7-cp314-cp314-android_24_arm64_v8a.whl.

File metadata

File hashes

Hashes for luvatrix-0.2.7-cp314-cp314-android_24_arm64_v8a.whl
Algorithm Hash digest
SHA256 03b49f8464274bf676e8f21821caaf594d06c58189004e90c987ae107103f34c
MD5 efd9c6015a506ba771ea6711bd4e0e76
BLAKE2b-256 177a632788bb09b495075bd56f6847b23334c304aac252e2aecee17f9fe1b538

See more details on using hashes here.

Provenance

The following attestation bundles were made for luvatrix-0.2.7-cp314-cp314-android_24_arm64_v8a.whl:

Publisher: publish-pypi.yml on 0202alcc/luvatrix

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Release history Release notifications | RSS feed

0.2.10

4 files

0.2.9

4 files

0.2.8

4 files

This release

0.2.7 This release

4 files

0.2.6

4 files

0.2.5

4 files

0.2.4

4 files

0.2.3

2 files

0.2.2

2 files

0.2.1

2 files

0.2.0

2 files

0.1.13

2 files

0.1.12

2 files

0.1.11

2 files

0.1.10

2 files

0.1.9

2 files

0.1.8

2 files

0.1.7

2 files

0.1.6

2 files

0.1.5

2 files

0.1.4

2 files

0.1.3

2 files

0.1.2

2 files

0.1.1

2 files

0.1.0

2 files

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