WebGPU API for Python for local and Pyodide development
This library provides a Python wrapper around the WebGPU API that runs in the browser via Pyodide or connects to a local Python instance. It is intended for interactive visualization and compute in environments such as Jupyter notebooks and plain HTML pages.
The package bundles a small rendering framework (scenes, cameras, labels, colormaps) and utilities to work with WGSL shaders from Python. It is used in higher level frameworks like ngsolve_webgpu for GPU-accelerated finite element visualizations in the browser.
Features
- Browser-based GPU access via WebGPU from local Python and Pyodide.
- Python-first API for creating renderers, scenes and simple GUI controls.
- Jupyter integration through a
webgpu.jupyterhelper module. - WGSL tooling:
- simple
#importmechanism for shader code - conditional compilation using
#ifdef/#else/#endif
- simple
- Ready-to-use building blocks:
Renderer,Scene,Camera,Labels,Colormap,Clipping,Font- utilities for GPU buffers and bindings
Requirements
- Python 3.8 or newer
- A browser with WebGPU support (for example a recent Chrome or Edge)
- For notebook use: JupyterLab or Jupyter Notebook
To check WebGPU support in your browser, you can use common WebGPU capability pages (for example WebGPU report pages linked from the project website).
Installation
From PyPI
pip install webgpu
From source
git clone https://github.com/CERBSim/webgpu
cd webgpu
pip install -e .
Documentation
The full project documentation, including API reference, tutorials and user guide, is published at:
Examples
The repository contains several examples:
- examples/first_shader.ipynb – minimal example drawing a triangle with custom WGSL shader code.
- examples/websocket.ipynb – example using the websocket link.
- docs/introduction.ipynb – overview and introductory material.
Additional, more advanced examples in docs/*.ipynb (compute, instanced shapes, selection).
Browser support
This library relies on the browser’s WebGPU implementation. In practice this means:
- A recent Chromium-based browser (Chrome, Edge) or Firefox is recommended.
- Some platforms may require enabling experimental WebGPU flags.
- Mobile and non-Chromium browsers may have partial or no support.
If WebGPU is not available, initialization will fail. See project documentation and browser-specific WebGPU status pages for details and troubleshooting.
License
This project is licensed under the terms of the LGPL-2.1-or-later. See the LICENSE file for details.
Metadata
Release files for webgpu 1.5.7
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| webgpu-1.5.7-py3-none-any.whl | Python 3 | none | any | Details |
Release files / webgpu-1.5.7-py3-none-any.whl
| Download URL | webgpu-1.5.7-py3-none-any.whl |
|---|---|
| Size | 302.1 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
cf28920b9362f2a157e7a5ce428b1b08e4ebb73879d0664e2d9063becdea163c
|
|
BLAKE2b-256 checksum How to use checksums |
b9c4f7fce02f3254c87442f49951f139f33fb3cfae975e06fc677f92a1f85ff1
|
| 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 Sep 21, 2026.
Transparency log