Goldy Python Bindings
Python bindings for the Goldy GPU library.
Installation
pip install goldy
Or build from source (development):
cd goldy/python
python -m venv .venv
source .venv/Scripts/activate # Windows Git Bash; use .venv\Scripts\activate on cmd/PowerShell
pip install -e ".[dev]"
That editable install compiles the Rust extension via maturin. Slang is embedded at
compile time by Goldy's build.rs and extracted on first use — no separate Slang
install or build-slang.py step is needed for local development.
After changing Rust bindings (python/src/*.rs), rebuild with:
maturin develop
Release wheels only (maintainers / CI): copy Slang into the package tree before
maturin build so wheels ship DLLs alongside the module — see PACKAGING.md.
Quick Start
import goldy
import numpy as np
# Create device
instance = goldy.Instance()
device = instance.request_adapter().request_device()
# Create vertex buffer with a triangle
vertices = np.array([
# x, y, r, g, b, a
0.0, -0.5, 1.0, 0.0, 0.0, 1.0, # red
-0.5, 0.5, 0.0, 1.0, 0.0, 1.0, # green
0.5, 0.5, 0.0, 0.0, 1.0, 1.0, # blue
], dtype=np.float32)
retained_pool = goldy.RetainedPool(device)
vertex_parcel = retained_pool.acquire_buffer(vertices, goldy.BufferKind.SCATTERED)[0]
# Create shader and pipeline
shader = goldy.ShaderModule.from_slang(device, goldy.Builtins.VERTEX_COLOR_2D)
pipeline = goldy.RenderPipeline(device, shader, shader, goldy.RenderPipelineDesc())
# Graphics via Scheme (headless)
ctx = device.create_context()
scheme = goldy.Scheme(ctx)
rt = scheme.lease_render_target(100, 100, goldy.TextureFormat.RGBA8_UNORM)
with scheme.render_pass("clear", rt) as rp:
rp.with_parcel(vertex_parcel, goldy.NodeAccess.READ)
rp.clear(goldy.Color(0.1, 0.1, 0.2, 1.0))
rp.set_pipeline(pipeline)
rp.set_vertex_buffer_parcel(0, vertex_parcel)
rp.draw(vertex_count=3)
scheme.copy_to_texture(rt, readback)
memory = goldy.MemoryExchange(ctx)
withdraw = memory.bind_withdraw_texture(scheme, readback)
submission = scheme.submit()
pixels = np.frombuffer(withdraw.claim(submission).consume(), dtype=np.uint8).reshape(100, 100, 4)
Examples
See the examples/ directory for complete examples:
- triangle.py / triangle_headless.py - Colored triangle via Scheme (headless readback)
- triangle_window.py - Windowed triangle via Scheme + present (requires GLFW)
- game_of_life.py - Hybrid compute + render scheme in a window (requires GLFW)
- game_of_life_headless.py - Headless Game of Life smoke test (CI / no display)
- adapter_info.py - Print GPU adapter information
- compute_demo.py - Standalone compute shader example
Run an example:
cd goldy/python
python examples/triangle.py
Features
NumPy Integration
Retained pools accept numpy arrays directly and return buffers (use [0] for a single-unit parcel):
vertices = np.array([...], dtype=np.float32)
pool = goldy.RetainedPool(device)
parcel = pool.acquire_buffer(vertices, goldy.BufferKind.SCATTERED)[0]
Readback uses MemoryExchange withdraw (claim then consume):
memory = goldy.MemoryExchange(ctx)
withdraw = memory.bind_withdraw_texture(scheme, texture)
submission = scheme.submit()
pixels = withdraw.claim(submission).consume() # raw bytes; reshape as needed
Context Managers
Pythonic API with with statements for scheme recording:
with scheme.render_pass("main", rt) as rp:
rp.with_parcel(parcel, goldy.NodeAccess.READ)
rp.set_pipeline(pipeline)
rp.draw(vertex_count=3)
scheme.node("update", pipeline).with_parcel(
parcel, goldy.NodeAccess.READ_WRITE
).dispatch(4, 1, 1)
submission = scheme.submit()
Shader Libraries
Use the built-in goldy_exp library or register custom ones:
# Built-in library
shader = goldy.ShaderModule.from_slang(device, '''
import goldy_exp;
[shader("fragment")]
float4 fs_main(FullscreenVarying input) : SV_Target {
return float4(rainbow(input.uv.x), 1.0);
}
''')
# Custom library
device.register_library('mylib', '''
module mylib;
public float3 my_color() { return float3(1.0, 0.5, 0.0); }
''')
API Reference
Core Classes
| Class | Description |
|---|---|
Instance |
Entry point, enumerate adapters |
Device |
GPU device for creating resources |
RetainedPool |
Allocates retained GPU parcels |
Parcel |
Retained buffer or texture resource |
ShaderModule |
Compiled Slang shader |
RenderPipeline |
Complete render state |
SchemeRenderTargetLease |
Off-screen render target declared on a scheme |
Scheme |
Retained GPU dependency graph (render passes, compute, present) |
SchemeRenderPass |
Draw commands within a render-pass node |
SchemeComputeNode |
Record a compute dispatch node on a scheme |
NodeAccess |
Read/Write/ReadWrite for scheme dependency tracking |
ComputePipeline |
Compute shader pipeline |
Enums
| Enum | Values |
|---|---|
DeviceType |
DISCRETE_GPU, INTEGRATED_GPU, CPU, OTHER |
TextureFormat |
RGBA8_UNORM, BGRA8_UNORM, RGBA16_FLOAT, ... |
BufferKind |
SCATTERED (storage), BROADCAST (uniform) |
PrimitiveTopology |
TRIANGLE_LIST, LINE_LIST, POINT_LIST, ... |
Types
| Type | Description |
|---|---|
Color |
RGBA color (float or byte) |
VertexBufferLayout |
Vertex format description |
RenderPipelineDesc |
Pipeline configuration |
DepthStencilState |
Depth testing configuration |
Testing
cd goldy/python
pytest tests/ -v
Tests are organized into:
test_types.py- Type wrapper tests (no GPU required)test_gpu.py- GPU integration tests (skipped if no GPU)
Requirements
- Python 3.9+
- NumPy 1.20+
- A compatible GPU (DX12 on Windows, Vulkan 1.4+ on Linux)
Backend Selection
Goldy uses DX12 on Windows and Vulkan on Linux by default. Override with GOLDY_BACKEND:
# Use Vulkan on Windows
GOLDY_BACKEND=vulkan python examples/triangle.py
# Use DX12 explicitly
GOLDY_BACKEND=dx12 python examples/triangle.py
Or set it in Python before importing goldy:
import os
os.environ["GOLDY_BACKEND"] = "vulkan"
import goldy
Publishing to PyPI
This package uses GitHub Actions with PyPI Trusted Publishers for automated releases.
Creating a release
- Update version in
pyproject.tomlandpython/goldy/__init__.py - Commit and push changes
- Create a git tag matching the version:
git tag v0.1.1dev0 git push origin v0.1.1dev0
- create a release:
gh release create v0.1.1dev0 --title "v0.1.1dev0" --notes "..." - The publish workflow will automatically build wheels and upload to PyPI
Manual testing (TestPyPI)
For testing before a real release, you can configure a separate Trusted Publisher for TestPyPI at https://test.pypi.org/manage/account/publishing/ and modify the workflow to publish there first.
License
MIT License. See the goldy repository for the full text.
Release files for goldy 0.2.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| goldy-0.2.0.tar.gz | 2.6 MB | Details |
Built distributions (wheels)
| File | Reset | |||
|---|---|---|---|---|
| goldy-0.2.0-cp312-cp312-win_amd64.whl | CPython 3.12 | CPython 3.12 | Windows x86-64 | Details |
| goldy-0.2.0-cp312-cp312-macosx_11_0_arm64.whl | CPython 3.12 | CPython 3.12 | macOS 11.0+ ARM64 | Details |
| goldy-0.2.0-cp312-cp312-macosx_10_12_x86_64.whl | CPython 3.12 | CPython 3.12 | macOS 10.12+ x86-64 | Details |
| goldy-0.2.0-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl | CPython 3.9 | CPython 3.9 | Linux glibc 2.17+ x86-64 | Details |
| goldy-0.2.0-cp39-cp39-manylinux_2_17_aarch64.manylinux2014_aarch64.whl | CPython 3.9 | CPython 3.9 | Linux glibc 2.17+ ARM64 | Details |
Total release size: 520.4 MB
Release files / goldy-0.2.0.tar.gz
| Download URL | goldy-0.2.0.tar.gz |
|---|---|
| Size | 2.6 MB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
9b161123acad5d126e1e79a1a92d528af2ece679cb083944ebcef0ae8461d466
|
|
BLAKE2b-256 checksum How to use checksums |
1fe206267562dee4667453823176f753519a8cebab1f3782c596f60f306402cb
|
| 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 Aug 2, 2026.
Transparency logRelease files / goldy-0.2.0-cp312-cp312-win_amd64.whl
| Download URL | goldy-0.2.0-cp312-cp312-win_amd64.whl |
|---|---|
| Size | 130.9 MB |
| Tags | CPython 3.12 Windows x86-64 |
|
SHA-256 checksum How to use checksums |
843cd53af4e5abfb22cc15730b65c3814d2a94a012d3593177880c729a26faf2
|
|
BLAKE2b-256 checksum How to use checksums |
f96df5f6f78310bb21a5fb153b9e33dd65153aabd344eafaeea12c64df8bc29e
|
| 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 Aug 2, 2026.
Transparency logRelease files / goldy-0.2.0-cp312-cp312-macosx_11_0_arm64.whl
| Download URL | goldy-0.2.0-cp312-cp312-macosx_11_0_arm64.whl |
|---|---|
| Size | 123.0 MB |
| Tags | CPython 3.12 macOS 11.0+ ARM64 |
|
SHA-256 checksum How to use checksums |
ded454da0678645d78175b1f2e36232d43862ac7b072f52261e176cf9ba31676
|
|
BLAKE2b-256 checksum How to use checksums |
1b243ac28fb74053ef780bf9179906156fe1d0182bdf0147bfb98b0ce14e1dde
|
| 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 Aug 2, 2026.
Transparency logRelease files / goldy-0.2.0-cp312-cp312-macosx_10_12_x86_64.whl
| Download URL | goldy-0.2.0-cp312-cp312-macosx_10_12_x86_64.whl |
|---|---|
| Size | 49.3 MB |
| Tags | CPython 3.12 macOS 10.12+ x86-64 |
|
SHA-256 checksum How to use checksums |
eb71d0d304c3793cc8703a99393dae81450fb99ca39c66ef26bc14b06a6b4fc8
|
|
BLAKE2b-256 checksum How to use checksums |
23c65ff1b809e056356fa726b7e49261c1f188bbce27ad09f6135383f2ab21cd
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/6.1.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 Jul 23, 2026.
Transparency logRelease files / goldy-0.2.0-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
| Download URL | goldy-0.2.0-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl |
|---|---|
| Size | 164.7 MB |
| Tags | CPython 3.9 Linux glibc 2.17+ x86-64 |
|
SHA-256 checksum How to use checksums |
883e381180ed3a32887ea16fd48b6e1e96766a91995660f210a05045a8139689
|
|
BLAKE2b-256 checksum How to use checksums |
1eb0c3f0b3314bd049d0ff9c5edd5e52a9148084b94b602e20678381a3b9511a
|
| 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 Aug 2, 2026.
Transparency logRelease files / goldy-0.2.0-cp39-cp39-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
| Download URL | goldy-0.2.0-cp39-cp39-manylinux_2_17_aarch64.manylinux2014_aarch64.whl |
|---|---|
| Size | 49.8 MB |
| Tags | CPython 3.9 Linux glibc 2.17+ ARM64 |
|
SHA-256 checksum How to use checksums |
f2c440f8b0441007e5dde6d23eebf5c7da1904153cd376d128395a86d9f9ff73
|
|
BLAKE2b-256 checksum How to use checksums |
5655708c4c2af8458dcf48d2cda635afad1f7b1eee2b55ec676613046ddc8da8
|
| 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 Aug 2, 2026.
Transparency log