libghostty-py
This is a fork of pyghostty (from this commit).
Python bindings for libghostty-vt. libghostty is Ghostty's embeddable terminal emulation core, a headless, high-fidelity VT emulator. These bindings cover terminal state, screen and scrollback snapshots, kitty graphics, and everything else Ghostty's production terminal core handles.
The binding is Python-ABI-independent: pure Python (cffi ABI mode) over a bundled libghostty-vt shared library, so one wheel per platform covers every Python version. No compiler is needed at install time. Wheel builds cover Linux and macOS (x86-64 and ARM64) and Windows (x86-64).
Usage
from ghostty import Terminal
with Terminal(cols=80, rows=24) as t:
t.feed('hello\r\nworld')
t.cursor # (x, y), 0-indexed
t.text() # plain text of the visible screen only
t.contents() # everything: scrollback plus screen, soft-wraps unwrapped
t.resize(120, 24) # reflows the primary screen
The base layer, ghostty._cdef/_ffi, exposes the complete generated C API as raw ffi/lib (regenerate with gen_cdef.py after moving the pinned ghostty rev).
ghostty.core.Terminal provides an ergonomic wrapper for commonly used parts.
Restoring a terminal on reconnect
serialize() returns VT bytes, rather than plain text or Ghostty's binary
snapshot format. Feed the result to a terminal with the same columns, rows, and character-width rules,
then forward subsequent PTY bytes in order:
with Terminal(cols=80, rows=24) as t:
t.feed(b"hello\r\n\x1b[31mprompt> ")
initial_output = t.serialize()
# Send initial_output to the reconnecting terminal before live PTY output.
The snapshot resets the destination and restores screen content, scrollback,
styles, cursor, modes, and the active alternate screen with its underlying primary
screen. Use serialize(palette=True) to also export the palette.
Snapshots may end with incomplete UTF-8 or VT sequences: send bytes directly, or
use a streaming decoder across the snapshot and live output. Serialize between
feeds/resizes and send the snapshot before subsequent output. Unfinished input is
limited by continuation_limit (1 MiB by default); exceeding it raises
GhosttyError until the sequence completes.
Graphics, titles, default colors, inactive alternate screens, and arbitrary saved cursors are not exported. Rendering can differ between terminal emulators.
Building the library
The shared library is built from a ghostty checkout with the Zig toolchain (installed via pip as ziglang):
GHOSTTY_SRC=/path/to/ghostty python build_lib.py
Without GHOSTTY_SRC, the build looks for a checkout in ghostty-src/ inside this project.
The checkout must be at the revision pinned in pyproject.toml. This runs zig build -Demit-lib-vt=true and copies the resulting shared library into ghostty/_lib/, where the package loader and wheel builds pick it up.
Development
pip install -e .[dev]
GHOSTTY_SRC=/path/to/ghostty python build_lib.py
pytest -q
To test against headless xterm.js:
npm install --prefix /tmp/libghostty-xterm @xterm/headless@6.0.0
LIBGHOSTTY_XTERM_MODULE=/tmp/libghostty-xterm/node_modules/@xterm/headless pytest -q
Versioning
Version lives in ghostty/__init__.py as __version__.
Releases
Pushing a v* tag runs .github/workflows/release.yml, which builds and tests one Python-ABI-independent wheel for each supported platform and publishes the wheels to GitHub and PyPI. Releases are wheel-only; source remains available from the corresponding GitHub tag.
Metadata
Release files for libghostty-py 0.1.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Built distributions (wheels)
| File | Actions Reset | |||
|---|---|---|---|---|
| libghostty_py-0.1.0-py3-none-win_amd64.whl | Python 3 | none | Windows x86-64 | Details for libghostty_py-0.1.0-py3-none-win_amd64.whl |
| libghostty_py-0.1.0-py3-none-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl | Python 3 | none | Linux glibc 2.27+ x86-64, Linux glibc 2.28+ x86-64 | Details for libghostty_py-0.1.0-py3-none-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl |
| libghostty_py-0.1.0-py3-none-manylinux_2_27_aarch64.manylinux_2_28_aarch64.whl | Python 3 | none | Linux glibc 2.28+ ARM64, Linux glibc 2.27+ ARM64 | Details for libghostty_py-0.1.0-py3-none-manylinux_2_27_aarch64.manylinux_2_28_aarch64.whl |
| libghostty_py-0.1.0-py3-none-macosx_13_0_x86_64.whl | Python 3 | none | macOS 13.0+ x86-64 | Details for libghostty_py-0.1.0-py3-none-macosx_13_0_x86_64.whl |
| libghostty_py-0.1.0-py3-none-macosx_13_0_arm64.whl | Python 3 | none | macOS 13.0+ ARM64 | Details for libghostty_py-0.1.0-py3-none-macosx_13_0_arm64.whl |
Total release size: 8.2 MB
Release files / libghostty_py-0.1.0-py3-none-win_amd64.whl
| Download URL | libghostty_py-0.1.0-py3-none-win_amd64.whl |
|---|---|
| Size | 925.4 kB |
| Tags | Python 3 Windows x86-64 |
|
SHA-256 checksum How to use checksums |
e55ccd8914130ab898201db71047e387152a5de7beef80d04b3b906c941315a0
|
|
BLAKE2b-256 checksum How to use checksums |
24a4af4e45371bb70ba9efd3c63c71cef719089a85ca52317b0e4efbf105185e
|
| 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 28, 2026.
Transparency logRelease files / libghostty_py-0.1.0-py3-none-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl
| Download URL | libghostty_py-0.1.0-py3-none-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl |
|---|---|
| Size | 3.0 MB |
| Tags | Linux glibc 2.27+ x86-64 Linux glibc 2.28+ x86-64 Python 3 |
|
SHA-256 checksum How to use checksums |
e1ca6c805ba34abab9163d5453a3fb03c20e40abdb79ddc21ed73dc5ecdfa18a
|
|
BLAKE2b-256 checksum How to use checksums |
0b0a2c8fb1109b31298029c707dedeb926ace632c3e24e3ab90b2a5f1ff6d39e
|
| 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 28, 2026.
Transparency logRelease files / libghostty_py-0.1.0-py3-none-manylinux_2_27_aarch64.manylinux_2_28_aarch64.whl
| Download URL | libghostty_py-0.1.0-py3-none-manylinux_2_27_aarch64.manylinux_2_28_aarch64.whl |
|---|---|
| Size | 2.8 MB |
| Tags | Linux glibc 2.27+ ARM64 Linux glibc 2.28+ ARM64 Python 3 |
|
SHA-256 checksum How to use checksums |
2cbf3549824e8f1f37f553d540203e1ae57977860a8bea6799cea5fa1902abc2
|
|
BLAKE2b-256 checksum How to use checksums |
0d90c1847c470891337010e9967a85371e75b437e270adfc1daf0cae8ff22ea3
|
| 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 28, 2026.
Transparency logRelease files / libghostty_py-0.1.0-py3-none-macosx_13_0_x86_64.whl
| Download URL | libghostty_py-0.1.0-py3-none-macosx_13_0_x86_64.whl |
|---|---|
| Size | 775.1 kB |
| Tags | Python 3 macOS 13.0+ x86-64 |
|
SHA-256 checksum How to use checksums |
ae67462d74b5086a4d35cf13dcd1b3fe3aca5f6b4d6c83d5b5c28bfa28ff0788
|
|
BLAKE2b-256 checksum How to use checksums |
961e357dac2c3ab20617f656dc6e9b10739228be2643c81471af7b0007d106e7
|
| 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 28, 2026.
Transparency logRelease files / libghostty_py-0.1.0-py3-none-macosx_13_0_arm64.whl
| Download URL | libghostty_py-0.1.0-py3-none-macosx_13_0_arm64.whl |
|---|---|
| Size | 749.5 kB |
| Tags | Python 3 macOS 13.0+ ARM64 |
|
SHA-256 checksum How to use checksums |
5353daaa6a2eda59e81953e9c4944f35bc2e48b8ca7444655767b98c2a57b8a6
|
|
BLAKE2b-256 checksum How to use checksums |
858315b93e7c8ba8c30c1a5b3b2dd837ccc728a9e56cb0126264f04498d6f338
|
| 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 28, 2026.
Transparency logSecurity for libghostty-py 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 5 files in this release have been uploaded with provenance metadata.
Attestation for libghostty_py-0.1.0-py3-none-win_amd64.whl
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 28, 2026.
Transparency logA 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.