Skip to main content

pyghostty

Unofficial (but complete) python bindings for libghostty-vt. libghostty is Ghostty's embeddable terminal emulation core, a headless, high-fidelity VT emulator for Python. 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.

Usage

from pyghostty 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, pyghostty._cdef/_ffi, exposes the complete generated C API as raw ffi/lib (regenerate with gen_cdef.py after moving the pinned ghostty rev).

pyghostty.core.Terminal provides an ergonomic wrapper for commonly used parts.

Building the library

Source installs, including editable installs, build the shared library automatically. The build fetches the pinned Ghostty revision into build/ghostty/<revision>/ and uses the Zig toolchain supplied by the package's build dependencies. Git and network access are needed for the first build; later builds reuse the checkout and Zig's compilation cache. A sibling Ghostty checkout is not needed.

To build from an existing checkout instead:

GHOSTTY_SRC=/path/to/ghostty python build_lib.py

The checkout must be at the revision pinned in pyproject.toml; the build never changes it. Running build_lib.py directly requires the pinned ziglang version in your Python environment. This runs zig build -Demit-lib-vt=true and copies the resulting shared library into pyghostty/_lib/.

Development

pip install -e .[dev]
pytest -q

After changing the Ghostty pin, reinstall the editable package (ws-sync does this in a uv workspace). After changing a checkout supplied with GHOSTTY_SRC, rerun build_lib.py. Regenerate _cdef.py with gen_cdef.py when updating the pinned revision.

Versioning

Version lives in pyghostty/__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 pyghostty 0.1.4

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

Built distributions (wheels)

Table of built distributions (wheels) for pyghostty 0.1.4
File Actions
pyghostty-0.1.4-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 pyghostty-0.1.4-py3-none-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl
pyghostty-0.1.4-py3-none-manylinux_2_27_aarch64.manylinux_2_28_aarch64.whl Python 3 none Linux glibc 2.27+ ARM64, Linux glibc 2.28+ ARM64 Details for pyghostty-0.1.4-py3-none-manylinux_2_27_aarch64.manylinux_2_28_aarch64.whl
pyghostty-0.1.4-py3-none-macosx_13_0_x86_64.whl Python 3 none macOS 13.0+ x86-64 Details for pyghostty-0.1.4-py3-none-macosx_13_0_x86_64.whl
pyghostty-0.1.4-py3-none-macosx_13_0_arm64.whl Python 3 none macOS 13.0+ ARM64 Details for pyghostty-0.1.4-py3-none-macosx_13_0_arm64.whl

Total release size: 7.3 MB

Release files / pyghostty-0.1.4-py3-none-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl

Download URL pyghostty-0.1.4-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
ea203580d8424a79bbad75e159494591ef3d7d3dfa43675a80f72271b72329d0
BLAKE2b-256 checksum
How to use checksums
4b5b4f23dd7d7c53950067c57514b083f0e70ed413a098b7964ad121439e88be
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 log

Release files / pyghostty-0.1.4-py3-none-manylinux_2_27_aarch64.manylinux_2_28_aarch64.whl

Download URL pyghostty-0.1.4-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
ea4d6366bbfb00dc445ac40c684b7a5154897dc9219ef949a490a9565eae2eba
BLAKE2b-256 checksum
How to use checksums
d47fd724d1c5dadc5ce8e029c22a42028bf1161b418e2dcb9e66460b23f32d37
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 log

Release files / pyghostty-0.1.4-py3-none-macosx_13_0_x86_64.whl

Download URL pyghostty-0.1.4-py3-none-macosx_13_0_x86_64.whl
Size 771.4 kB
Tags Python 3 macOS 13.0+ x86-64
SHA-256 checksum
How to use checksums
7b00aa8ead35fba7b4335c9cc33bd81066cccbeef6e5c694768cb5bcbef11161
BLAKE2b-256 checksum
How to use checksums
53ee5e3b514e3d7f2d12905ed7fac30142f7848ca2498872b30f79ca4e91278f
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 log

Release files / pyghostty-0.1.4-py3-none-macosx_13_0_arm64.whl

Download URL pyghostty-0.1.4-py3-none-macosx_13_0_arm64.whl
Size 745.9 kB
Tags Python 3 macOS 13.0+ ARM64
SHA-256 checksum
How to use checksums
36ab741c3906ca4d09e5f5bde0cf31aaf27fd1a3126a42b34786421cdd606ef8
BLAKE2b-256 checksum
How to use checksums
b9939001ec0fc6b2708064c6c6ab8c840ff82619c6b16d45665e26c1c2eea9c0
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 log

Security for pyghostty 0.1.4

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 4 files in this release have been uploaded with provenance metadata.

Select from 4 files

Attestation for pyghostty-0.1.4-py3-none-manylinux_2_27_x86_64.manylinux_2_28_x86_64.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 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.

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