Skip to main content

python-libghostty-vt

Idiomatic, fully typed Python bindings for libghostty-vt — the C-ABI terminal (VT) library extracted from Ghostty.

  • Distribution name: python-libghostty-vt
  • Import name: ghostty_vt

Feed a terminal the bytes a program would print and read back the plain text a human would see; encode keyboard input to the exact bytes a PTY expects; parse OSC/SGR escape sequences into typed results. Useful for testing TUIs, recording and replaying sessions, cleaning subprocess output for an AI agent, and building terminal frontends — no running terminal or subprocess required.

Two-layer design

The package is built in two layers:

  • The raw layer is a private, generated 1:1 cffi binding over the C API, complete by construction and regenerated whenever the pinned upstream commit moves. It is unstable and not part of the public API.
  • The idiomatic layer — everything you import from ghostty_vt — is a hand-written, fully typed, Pythonic API organized into domain submodules (terminal, key, mouse, osc, sgr, color, …). It is the only surface with stability intent. You never need to touch the raw layer.

See ADR 0001 for the binding mechanism and ADR 0002 for the idiomatic conventions (snake_case, GhosttyVtError hierarchy, context managers, bytes in / str out).

Installation

pip install python-libghostty-vt   # or: uv add python-libghostty-vt

Prebuilt wheels ship for the supported platforms below — no zig, no C compiler (Windows is best-effort and unsupported: no wheel is published, so it installs from the source distribution). Requires Python 3.14 or newer; the API targets modern typing and idioms with no legacy shims.

Supported platforms

Platform Architectures Wheel
Linux (glibc) x86_64, aarch64 manylinux
Linux (musl) x86_64, aarch64 musllinux (e.g. Alpine)
macOS arm64, x86_64 native
Windows x86_64 none published (sdist)

Wheels are CPython 3.14 GIL builds (cp314) only: cffi's API mode targets a specific interpreter, so there is no abi3 wheel and no free-threaded (cp314t) wheel yet. On any other platform, pip builds from the source distribution: the bundled upstream source and prefetched zig deps keep that build off the network for Ghostty itself, needing only zig and a C compiler. (pip still resolves its own build backend — setuptools, cffi, ziglang — from PyPI as usual.)

Quickstart

Create a Terminal, feed it VT-encoded bytes, and read back the visible text. It is a context manager, so the native handle is released when the block exits:

>>> from ghostty_vt import Terminal
>>> with Terminal(80, 24) as term:
...     term.feed(b"hello, \x1b[1mworld\x1b[0m\r\n")
...     term.feed(b"goodbye")
...     print(term.visible_text())
hello, world
goodbye

Styling is resolved away, escape sequences are interpreted, and trailing whitespace is trimmed — the result is what a user would see, not the raw stream. Terminals resize and reflow, and their dimensions are queryable:

>>> term = Terminal(80, 24)
>>> term.cols, term.rows
(80, 24)
>>> term.resize(100, 40)
>>> term.cols, term.rows
(100, 40)
>>> term.close()

Encode keyboard input to the bytes a terminal expects. A KeyEncoder produces the classic (legacy) encoding by default; pass kitty_flags to switch to the Kitty keyboard protocol:

>>> from ghostty_vt import Key, KeyEncoder, KeyEvent, KittyFlags, Mods
>>> legacy = KeyEncoder()
>>> legacy.encode(KeyEvent(Key.C, Mods.CTRL))
b'\x03'
>>> legacy.encode(KeyEvent(Key.ARROW_UP))
b'\x1b[A'
>>> kitty = KeyEncoder(kitty_flags=KittyFlags.DISAMBIGUATE)
>>> kitty.encode(KeyEvent(Key.ESCAPE))
b'\x1b[27u'

Build metadata and the pinned upstream commit are available at runtime, so you can report upstream-specific bugs precisely:

>>> import ghostty_vt
>>> info = ghostty_vt.build_info()
>>> info.optimize.name
'RELEASE_FAST'
>>> len(ghostty_vt.GHOSTTY_COMMIT)   # the 40-char upstream commit hash
40
>>> isinstance(ghostty_vt.__version__, str)
True

Local development

Requires uv and just. The zig toolchain is pinned and provided automatically through the ziglang dev dependency — no separate zig install is needed.

A fresh clone reaches green tests with three documented commands:

just vendor    # vendor libghostty-vt at the pinned commit (network)
just build     # build the raw-layer cffi extension in place (offline)
just test      # run the test suite with 100% branch coverage enforced

just setup syncs the dev environment explicitly. You rarely need to call it directly: the uv run-based recipes (just build, just test, …) sync it implicitly on first use. The main recipes:

just setup     # sync the dev environment (Python 3.14+, pinned zig)
just vendor    # vendor libghostty-vt at the pinned commit (network)
just build     # build the raw-layer cffi extension in place (offline)
just build-lib # build only the static libghostty-vt from vendored source (offline)
just gen-cdef  # regenerate the raw-layer cdef from the vendored headers
just lint      # ruff lint
just fmt       # ruff format
just test      # run the test suite with 100% branch coverage enforced
just typecheck # mypy + pyright (strict) over source and tests
just typesafety # run the typesafety suite (five checkers + verifytypes)

Run just with no arguments to list every recipe. After just vendor, just build compiles the extension (building the static library first if needed) so just test can import ghostty_vt.

The README's quickstart examples are executed as doctests by the test suite, so they cannot silently rot.

Vendoring

The single pinned upstream commit lives in ghostty-commit.txt — exactly one place. just vendor checks out Ghostty at that commit, runs upstream's own zig build dist -Demit-lib-vt=true to produce the libghostty-vt-only source tarball (upstream maintains the list of app-only paths it excludes), and unpacks that tarball into vendor/ghostty/ (gitignored) — the full Ghostty tree is never kept. It then builds the static lib for the host, which both populates the zig package cache in vendor/zig-cache/ and proves the vendored tree builds; just build afterwards runs hermetically (zig build --system, no network). Upstream's MIT license notice is retained alongside the vendored source.

The sdist bundles the trimmed vendored source but not the zig package cache (the per-target union exceeds PyPI's file size limit), so building from a bare sdist lets zig fetch its build.zig.zon-pinned, hash-verified dependencies over the network. Wheels are unaffected: they are prebuilt, and wheel CI builds hermetically from the populated cache.

Bumping upstream is a one-hash edit to ghostty-commit.txt followed by just vendor. The pinned zig version tracks upstream's minimum and is bumped via the ziglang pin in pyproject.toml.

Versioning

The package uses 0.x semver: a minor bump signals an API or upstream change, a patch bump a fix. Each release is built from exactly one upstream commit, recorded in ghostty-commit.txt and exposed at runtime as ghostty_vt.GHOSTTY_COMMIT. Release notes state the pinned commit per release, so a downstream maintainer can map any behavior to a precise upstream revision. Because upstream's API is unstable, expect the raw layer to regenerate and the idiomatic layer to need hand-updates whenever the pinned commit moves.

The package version is single-sourced from pyproject.toml and read back from the installed metadata as ghostty_vt.__version__.

Releasing

Releases are token-free: publishing a GitHub release runs the whole pipeline. The Wheels workflow builds the sdist and every blocking wheel (manylinux/musllinux x86_64 + aarch64, macOS arm64 + x86_64), verifies each by running the test suite against it, then uploads the sdist and all blocking wheels to PyPI via Trusted Publishing (OIDC — no API tokens are stored). The best-effort Windows wheel is never published.

To cut a release:

  1. Bump version in pyproject.toml to the next 0.x value (minor = API/upstream change, patch = fix). This is the single source of truth: ghostty_vt.__version__ is read back from the installed metadata, so there is nothing else to edit.
  2. Create a GitHub release whose tag equals that version (a leading v is allowed, e.g. v0.1.0). Draft the notes from .github/release-notes-template.md; the workflow also appends the pinned commit automatically.
  3. Publishing the release builds, verifies, and uploads to PyPI. The publish job fails before uploading if the built version doesn't match the tag.

Dry run: trigger the Wheels workflow manually (workflow_dispatch) to build and verify without publishing. Set the publish_testpypi input to additionally upload to TestPyPI, rehearsing the full publish path.

Both PyPI and TestPyPI must be configured with this repository and workflow as a trusted publisher, and the pypi / testpypi GitHub environments must exist.

License

MIT — see LICENSE. libghostty-vt is likewise MIT-licensed; its notice is retained alongside the vendored source (vendor/ghostty/LICENSE).

Metadata

Release files for python-libghostty-vt 0.1.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 python-libghostty-vt 0.1.0
File Size Uploaded Provenance Actions
python_libghostty_vt-0.1.0.tar.gz 3.4 MB With provenance Details for python_libghostty_vt-0.1.0.tar.gz

Built distributions (wheels)

Table of built distributions (wheels) for python-libghostty-vt 0.1.0
File Actions
python_libghostty_vt-0.1.0-cp314-cp314-musllinux_1_2_x86_64.whl CPython 3.14 CPython 3.14 Linux musl 1.2+ x86-64 Details for python_libghostty_vt-0.1.0-cp314-cp314-musllinux_1_2_x86_64.whl
python_libghostty_vt-0.1.0-cp314-cp314-musllinux_1_2_aarch64.whl CPython 3.14 CPython 3.14 Linux musl 1.2+ ARM64 Details for python_libghostty_vt-0.1.0-cp314-cp314-musllinux_1_2_aarch64.whl
python_libghostty_vt-0.1.0-cp314-cp314-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl CPython 3.14 CPython 3.14 Linux glibc 2.28+ x86-64, Linux glibc 2.27+ x86-64 Details for python_libghostty_vt-0.1.0-cp314-cp314-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl
python_libghostty_vt-0.1.0-cp314-cp314-manylinux_2_27_aarch64.manylinux_2_28_aarch64.whl CPython 3.14 CPython 3.14 Linux glibc 2.28+ ARM64, Linux glibc 2.27+ ARM64 Details for python_libghostty_vt-0.1.0-cp314-cp314-manylinux_2_27_aarch64.manylinux_2_28_aarch64.whl
python_libghostty_vt-0.1.0-cp314-cp314-macosx_11_0_arm64.whl CPython 3.14 CPython 3.14 macOS 11.0+ ARM64 Details for python_libghostty_vt-0.1.0-cp314-cp314-macosx_11_0_arm64.whl
python_libghostty_vt-0.1.0-cp314-cp314-macosx_10_15_x86_64.whl CPython 3.14 CPython 3.14 macOS 10.15+ x86-64 Details for python_libghostty_vt-0.1.0-cp314-cp314-macosx_10_15_x86_64.whl

Total release size: 16.4 MB

Release files / python_libghostty_vt-0.1.0.tar.gz

Download URL python_libghostty_vt-0.1.0.tar.gz
Size 3.4 MB
Tags Source
SHA-256 checksum
How to use checksums
7408a4c5cb4411cba106357603bf4fbb3b48606710dae1605d8e9fabcf094db5
BLAKE2b-256 checksum
How to use checksums
aeb1d9c9876023252782cdc64ce5c9bfeb8f0f76bd72483b5d3463d75338d7b4
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/6.1.0 CPython/3.12.8

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 Jul 25, 2026.

Transparency log

Release files / python_libghostty_vt-0.1.0-cp314-cp314-musllinux_1_2_x86_64.whl

Download URL python_libghostty_vt-0.1.0-cp314-cp314-musllinux_1_2_x86_64.whl
Size 2.9 MB
Tags CPython 3.14 Linux musl 1.2+ x86-64
SHA-256 checksum
How to use checksums
3b3a151fa0a5a1ea72caa6eac492ba735f177d47c17c844ad0c5fd38d9d4a035
BLAKE2b-256 checksum
How to use checksums
5054ec766b7f46cafcd984b3bc6f5831299942c837dc93bb4769cb7be53808d2
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/6.1.0 CPython/3.12.8

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 Jul 25, 2026.

Transparency log

Release files / python_libghostty_vt-0.1.0-cp314-cp314-musllinux_1_2_aarch64.whl

Download URL python_libghostty_vt-0.1.0-cp314-cp314-musllinux_1_2_aarch64.whl
Size 2.7 MB
Tags CPython 3.14 Linux musl 1.2+ ARM64
SHA-256 checksum
How to use checksums
66efaaf4359fb4cda59ffde87521463fcf82399dbdf5266b213b2555cdeafc8e
BLAKE2b-256 checksum
How to use checksums
d26ac3f7d8651e3d18e24970c8cc745eb6851e48f689b19ea6146c230307526d
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/6.1.0 CPython/3.12.8

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 Jul 25, 2026.

Transparency log

Release files / python_libghostty_vt-0.1.0-cp314-cp314-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl

Download URL python_libghostty_vt-0.1.0-cp314-cp314-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl
Size 2.9 MB
Tags CPython 3.14 Linux glibc 2.27+ x86-64 Linux glibc 2.28+ x86-64
SHA-256 checksum
How to use checksums
5d17a7dd35465a02e5f1011e1530a082d532cce4dd0c371b67c692d45eb7899d
BLAKE2b-256 checksum
How to use checksums
fcb2185995b98591dbb7f752e28cf56fa8e7d843258393833138f8b1fc0fdb4c
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/6.1.0 CPython/3.12.8

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 Jul 25, 2026.

Transparency log

Release files / python_libghostty_vt-0.1.0-cp314-cp314-manylinux_2_27_aarch64.manylinux_2_28_aarch64.whl

Download URL python_libghostty_vt-0.1.0-cp314-cp314-manylinux_2_27_aarch64.manylinux_2_28_aarch64.whl
Size 2.7 MB
Tags CPython 3.14 Linux glibc 2.27+ ARM64 Linux glibc 2.28+ ARM64
SHA-256 checksum
How to use checksums
2e3a4a1a98faf659d48f8a9ea2f9ac1d4a9b33a2b24f18797719e01035361950
BLAKE2b-256 checksum
How to use checksums
b3b102de6bc1150537ef46ba45c3154b3aa124a48a65750e931e92a2685c5172
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/6.1.0 CPython/3.12.8

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 Jul 25, 2026.

Transparency log

Release files / python_libghostty_vt-0.1.0-cp314-cp314-macosx_11_0_arm64.whl

Download URL python_libghostty_vt-0.1.0-cp314-cp314-macosx_11_0_arm64.whl
Size 819.4 kB
Tags CPython 3.14 macOS 11.0+ ARM64
SHA-256 checksum
How to use checksums
20892ec8616fa8ad45e5edfc0a7f7af73deab693bcacb8a5133161788c54c415
BLAKE2b-256 checksum
How to use checksums
e7b2b55d3759a15f048527f13d5a9249c7aaccd3f62722cc35d38a205d319262
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/6.1.0 CPython/3.12.8

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 Jul 25, 2026.

Transparency log

Release files / python_libghostty_vt-0.1.0-cp314-cp314-macosx_10_15_x86_64.whl

Download URL python_libghostty_vt-0.1.0-cp314-cp314-macosx_10_15_x86_64.whl
Size 876.1 kB
Tags CPython 3.14 macOS 10.15+ x86-64
SHA-256 checksum
How to use checksums
7b2e8fce220fb856362af7d9e3066e1f26bdc16b2d519a20db8be54f8f0e55c4
BLAKE2b-256 checksum
How to use checksums
b4a8ff290ddc7fcb6bd02d4260a6afc0dc0f7283987b5593ba58bd6d9b66da6b
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/6.1.0 CPython/3.12.8

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 Jul 25, 2026.

Transparency log

Security for python-libghostty-vt 0.1.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

All 7 files in this release have been uploaded with provenance metadata.

Select from 7 files

Attestation for python_libghostty_vt-0.1.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 Jul 25, 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.1.0 This release

7 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