Skip to main content

Pocket-python

Pocket-python builds offline browser applications from explicit verified client sources. The compiled profile runs emitted JavaScript and selected helpers in a module worker. The supplied MicroPython profile runs compatible Python through WebAssembly. Both use local assets and a service worker for cached reloads.

Requires Python 3.14+ to build artifacts and compatibility with the selected compiler/runtime profile. The tool has zero runtime dependencies and uses the MIT license. Version 0.2.0 is experimental.

python -m pip install pocket-python==0.2.0 shimify==0.3.0
pocket-python --help

Build a compiled application

Install the optional compiler explicitly when using this profile:

python -m pip install Python-JavaScript==0.2.0
pocket-python compiled-web CLIENT-SOURCES.json --output build/compiled-web

The compiled application guide defines the hashed client-source allowlist, named text-input UI, source-map policy, exact compiler identity and offline update lifecycle. Compiler installation is build tooling; the CLI never installs it automatically. Generated applications contain no Python interpreter and parse no new source after deployment.

See 0.2.0 release notes for the published scope.

Build a supplied MicroPython application

First create a portable source bundle with Shimify. Supply a MicroPython WebAssembly distribution containing micropython.mjs, micropython.wasm and its license text; use the official WebAssembly port or the official npm package described in PyScript’s offline guide.

shimify modules path/to/app.py --output build/source
pocket-python inspect build/source
pocket-python lock-runtime path/to/runtime --runtime-version VERSION \
  --source-url https://example.org/upstream-runtime-release \
  --file micropython.mjs --file micropython.wasm --license-file LICENSE \
  --output build/runtime-lock.json
pocket-python web build/source --runtime path/to/runtime \
  --runtime-lock build/runtime-lock.json --output build/web --title "My Python App"
python -m http.server 8000 --bind 127.0.0.1 --directory build/web

Replace VERSION and the source URL with the identity of the supplied upstream release. Open http://localhost:8000, let the app finish installing its cache, and wait for Offline ready on this device before disconnecting. Run starts a fresh worker; Stop terminates it, including an infinite computation. Python output is rendered as text. Deploy the generated directory to a static HTTPS server; relative URLs support deployment under a subdirectory. file:// execution is unsupported.

web writes to a new directory outside input roots. It preserves only recorded source/runtime files and notices and adds POCKET-PYTHON.json with hashes, runtime identity and separate source/runtime/total byte counts. Generation does not run application code. The published tool contains no interpreter binary and does not download one automatically.

Reproduce the pinned example

In a checkout, the build-only helper downloads and checks the official MicroPython 1.29.0-6 fixture and upstream license. The committed input is a real Shimify 0.2 bundle with a local helper import:

uv sync --locked
uv run python scripts/prepare_runtime.py
uv run pocket-python inspect tests/fixtures/hello
uv run pocket-python web tests/fixtures/hello --runtime build/runtime \
  --runtime-lock build/runtime/runtime-lock.json --output build/demo
python -m http.server 8000 --bind 127.0.0.1 --directory build/demo

The demonstrated PWA totals 578,168 uncompressed bytes, including 563,092 bytes of runtime assets/license and 102 bytes of application source. These measurements describe the tested fixture; source reduction, compressed transfer size, startup time and memory are separate quantities.

Development and verification

uv sync --locked --group browser-tests --group compiled-build
uv run python scripts/prepare_runtime.py
POCKET_PYTHON_RUNTIME=build/runtime uv run python -m unittest discover -s tests -v
uv run python -m playwright install chromium
uv run --group browser-tests python scripts/browser_smoke.py
uv build
uv run python scripts/check_distributions.py

On PowerShell set $env:POCKET_PYTHON_RUNTIME = "build/runtime" before tests. Without an explicit runtime fixture path, the real-WASM test is skipped. Use --channel chrome with the browser script to test an installed Chrome. Playwright is a pinned build-only group; it is not a package runtime dependency. CI runs real-runtime tests on Linux, macOS and Windows and offline Chromium tests on Linux. Distribution checks verify allowlists, metadata, source parity and both installed wheel/source artifacts outside the checkout.

Compatibility and roadmap

MicroPython provides a subset of Python and its standard library. Test every application against the actual selected runtime: a valid Shimify CPython source bundle does not establish browser compatibility. Native extensions, OS process APIs, resources and dynamic imports need explicit adapters or a different runtime profile. The initial console has no interactive stdin or DOM bridge. Browser cache persistence and PWA installation affordances vary by platform.

Version 0.2.0 delivers compiled JavaScript applications and supplied MicroPython WebAssembly applications. The separately staged independent interpreter will parse newly supplied Python in the browser. Its VM prototype remains in the repository and is excluded from this PyPI release. Shimify owns source reduction, Python-JavaScript owns compilation, and pocket-python owns assembly and the interpreter queue. Native CPython assembly/trimming, an upstream CPython WebAssembly build, Pyodide and PyScript remain optional profiles with separate compatibility/test gates.

See IMPLEMENTATION_PLAN.md, release notes, and the GitHub Project. Runtime and dependency licenses remain applicable; preserve and review their upstream notices before distributing generated applications.

The development independent VM value model executes our own versioned bytecode in Node and browser workers. It covers staged Python scalars, containers and iteration; browser-side parsing of new source remains a subsequent milestone. It is excluded from the 0.2.0 distributions.

Development sessions now have explicit roots, allocation limits and owned host handles, with shared Node/browser lifetime checks. New Python source still requires the planned independent parser.

The compiled JavaScript PWA builder now packages verified client modules and original helpers for browser-worker execution, offline reload and scoped updates. Build the text-metrics example with the optional pinned compiled-build tooling; the builder is included in 0.2.0.

The development shared server/browser example runs the same supported computation under CPython and in a compiled browser worker, with explicit network reference calls and offline failure checks.

Development version 3 functions and exception unwinding add argument binding, lexical closures, recursion and source-located handlers. The same bytecode runs in Node and browser workers; source parsing remains INT-08.

Development version 4 verified modules add explicit imports, session cache identity, relative packages and a supplied small library profile. The original text-metrics computation runs through this independent VM; newly entered source awaits the independent parser.

Metadata

Release files for pocket-python 0.2.0

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

Source distribution (sdist)

Source distribution for pocket-python 0.2.0
File Size Uploaded Provenance Actions
pocket_python-0.2.0.tar.gz 19.6 kB With provenance Details for pocket_python-0.2.0.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for pocket-python 0.2.0
File Interpreter ABI Platform Actions
pocket_python-0.2.0-py3-none-any.whl Python 3 none any Details for pocket_python-0.2.0-py3-none-any.whl

Total release size: 44.9 kB

Release files / pocket_python-0.2.0.tar.gz

Download URL pocket_python-0.2.0.tar.gz
Size 19.6 kB
Tags Source
SHA-256 checksum
How to use checksums
867d14e7143c53f088a1983a0e9b3eeee72b3f4deea9d5e9723446bdd82881ae
BLAKE2b-256 checksum
How to use checksums
7b641ed0a6776fb84355dbbd3c39c445d09228ecccd8a35336f96491bac977f4
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

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

Transparency log

Release files / pocket_python-0.2.0-py3-none-any.whl

Download URL pocket_python-0.2.0-py3-none-any.whl
Size 25.2 kB
Tags Python 3
SHA-256 checksum
How to use checksums
b6df50fa5d538a429b350db858fe4bf643d407e729482534056594e2e0748094
BLAKE2b-256 checksum
How to use checksums
8d1e774ae231561f7cfa4c6e6dfdf8609dfeb7911c612d0369cbbda933b5b48b
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

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

Transparency log

Security for pocket-python 0.2.0

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.

Full provenance

Both files in this release have been uploaded with provenance metadata.

Select from 2 files

Attestation for pocket_python-0.2.0.tar.gz

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

Transparency log

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Release history Release notifications | RSS feed

This release

0.2.0 This release

2 release files Full provenance

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