Skip to main content

🐍 Anpyra · Python to Native Android

Write small Android apps in a typed Python subset, compile them directly to DEX, and build signed APKs. Anpyra is a Python-written compiler and build framework based on the PyAndroid experiments 001–008.

Status: v0.1.4 alpha. Android is the only implemented target. This release adds native Column/Row/ScrollView, masked TextInput and a scoped ChatSession with background HTTPS requests and in-memory history. Existing Screen styling, TextView typography and Button design remain available. API 33 checks include 25 Screen cases, 30 typography cases, 20 Button cases and 13 controlled chat cases. Other Android versions, broader lifecycle behavior and independent binary verification still need recorded coverage.

🐍 Python-based builds

Build with Python 3.11+ and Python dependencies. No Java/JDK, Kotlin, Android SDK build kit, Android NDK, Android Studio, Gradle, D8, R8, AAPT2 or apksigner is required. cryptography and Pillow are installed automatically for signing and Screen image/color handling. Optional adb provides device installation.

⚡ Install the published package

Install from PyPI using uv (recommended):

uv venv --python 3.12
uv pip install "anpyra==0.1.4"

Or use pip inside a virtual environment:

python -m pip install "anpyra==0.1.4"

Activate your environment, then:

anpyra doctor
anpyra init myapp --package dev.example.myapp --label "My App"
anpyra check myapp
anpyra build myapp
anpyra verify myapp/build/dev.example.myapp.apk

For checkout installation and host-specific commands, see the installation guide.

🔄 Upgrade from an earlier release

Use the same environment where you installed Anpyra. With that environment activated, choose uv (recommended) or pip:

uv pip install --upgrade "anpyra==0.1.4"
# Or:
python -m pip install --upgrade "anpyra==0.1.4"
python -m anpyra --version

The version should print Anpyra 0.1.4. To upgrade to the latest compatible release, use --upgrade anpyra without the version pin. Keep your app's .anpyra/ signing identity and rebuild its APK after upgrading. See the upgrade guide for explicit environment paths.

🧩 Application example

from anpyra import Activity
from anpyra.components import Font, TextView


class MainActivity(Activity):
    def on_create(self, state):
        title = TextView(self, text="Hello from Anpyra!")
        title.style.color = "#663399"
        title.style.size = 28
        title.style.font = Font(family="sans-serif", bold=True)
        title.style.padding = (16, 24)
        title.style.width = "match_parent"
        title.style.alignment = "center"
        self.set_content_view(title)

Anpyra parses application source on the host. Android runs the generated bytecode. The authoring classes provide editor support; they do not preview a UI on the host.

🟦 Native Button example

from anpyra import Activity
from anpyra.components import Button, Border


class MainActivity(Activity):
    def on_create(self, state):
        button = Button(self, text="Continue")
        button.style.bg.color = "#2563eb"
        button.style.color = "white"
        button.style.all_caps = False
        button.style.corner_radius = 16
        button.style.border = Border("#93c5fd", width=2)
        button.style.width = 260
        button.style.height = 64
        button.style.placement = "center"
        button.style.pressed.bg.color = "#1e40af"
        button.style.ripple_color = "#50ffffff"
        self.set_content_view(button)

This example demonstrates native design and press feedback. Python click-action callbacks are not compiled in this version.

💬 Standalone chatbot

Use native layouts, TextInput, TextView and Button with ChatSession to call OpenAI directly from the phone. Enter a temporary key at runtime; it is not compiled into the APK. Successful turns retain all response output items, New chat resets history, and request controls recover after errors. No Python server or embedded OpenAI Python SDK is needed. See the chatbot guide and full example.

The 13 phone checks used controlled responses. A live AI answer was not verified because the supplied temporary key returned exhausted quota. Streaming, cancellation, durable history and arbitrary Python callbacks remain unsupported.

📦 Supported features and limits

  • One Activity and TextView with Font/Shadow/TextStyle declarations, constructor text, typography, dp dimensions/padding, sp size and native selection.
  • Native Button design with shared typography, state colors, rounded shapes, stroke, ripple, layout/margins and signed raster icons.
  • Column/Row weighted layouts, single-child ScrollView and TextInput with placeholder/password configuration.
  • Scoped ChatSession listener, worker/delivery classes, HTTPS/JSON requests, response rendering and successful history.
  • Validated standalone local TTF/OTF fonts preserved in signed digest-named APK assets.
  • Screen colors, local raster images with seven fit modes, linear/radial/sweep gradients and transparency.
  • Initialized str, int and bool locals, simple integer arithmetic and comparisons.
  • Nested conditions and typed integer helper functions.
  • DEX, binary manifest, signed APK and JSON report generation.
  • Retained project debug identity and local APK/DEX integrity checks.

This is a restricted compiler, not general Python on Android. Screen accepts one widget or layout root; Column/Row arrange multiple children. Generic Python callbacks, arbitrary imports, collections, reassignment, multi-module apps and release/store signing remain unsupported. Layout/input/chat apps permit 48 symbols with at most 14 scalar int/bool locals; older apps retain their 14-symbol budget. See the Screen guide, TextView guide, Button guide, chatbot guide and language guide.

📚 Documentation and contribution

User guide · Developer guide · Roadmap · Issues · Contributing

Anpyra is licensed under Apache-2.0.

Metadata

Release files for anpyra 0.1.4

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for anpyra 0.1.4
File Size Uploaded
anpyra-0.1.4.tar.gz 234.5 kB Details

Built distribution (wheel)

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

Total release size: 329.0 kB

Release files / anpyra-0.1.4.tar.gz

Download URL anpyra-0.1.4.tar.gz
Size 234.5 kB
Tags Source
SHA-256 checksum
How to use checksums
7fa253211dfb3f21078fb656a7c6e39b961de2d547c32d33571fd24dec3f08a1
BLAKE2b-256 checksum
How to use checksums
83faa6c35299dfd74c0215bb96ca81bcc433b6380ad142cdf3f485d96e511eb5
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

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 Oct 7, 2026.

Transparency log

Release files / anpyra-0.1.4-py3-none-any.whl

Download URL anpyra-0.1.4-py3-none-any.whl
Size 94.5 kB
Tags Python 3
SHA-256 checksum
How to use checksums
e85bda713d5e5ccda55a8592359a86d0ab05e5c5d593bf3d4eebeee07ba15ffa
BLAKE2b-256 checksum
How to use checksums
43eedc9c5871535e6f7640487dcb69fb038869249b82c7b4efa5cc4eb827a9ca
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

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 Oct 7, 2026.

Transparency log

Release history Release notifications | RSS feed

0.1.5

2 release files

This release

0.1.4 This release

2 release files

0.1.3

2 release files

0.1.2

2 release files

0.1.1

2 release files

0.1.0

2 release 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