A Python based WebGPU API using pyodide
Project description
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.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distributions
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file webgpu-1.1.2-py3-none-any.whl.
File metadata
- Download URL: webgpu-1.1.2-py3-none-any.whl
- Upload date:
- Size: 198.6 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
a9683794fb008317eb609ac0f06ec40b52ebde48e35a11c8fa9500767a382352
|
|
| MD5 |
67d42e75283f2d3e4bb51e70f13777f1
|
|
| BLAKE2b-256 |
6eb8d266055dc51ec86f821e38f14094297ce954f038f53da565371168eb96ba
|
Provenance
The following attestation bundles were made for webgpu-1.1.2-py3-none-any.whl:
Publisher:
deploy.yml on CERBSim/webgpu
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
webgpu-1.1.2-py3-none-any.whl -
Subject digest:
a9683794fb008317eb609ac0f06ec40b52ebde48e35a11c8fa9500767a382352 - Sigstore transparency entry: 1162767907
- Sigstore integration time:
-
Permalink:
CERBSim/webgpu@a39b623d3c069a724787ac7ea91bbd013960e2c1 -
Branch / Tag:
refs/tags/v1.1.2 - Owner: https://github.com/CERBSim
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
deploy.yml@a39b623d3c069a724787ac7ea91bbd013960e2c1 -
Trigger Event:
push
-
Statement type: