Skip to main content

wesl-py

Python bindings for the Rust WESL compiler. WESL adds imports and conditional compilation to WGSL. Run shader tests with pytest. Compilation needs no GPU.

Installation

Requires Python 3.12 or later.

The distribution name is wesl-py; import it as wesl.

TODO: add pip install instructions.

Compile a shader

Save as shaders/exposure.wesl:

fn apply_exposure(color: vec3f, stops: f32) -> vec3f {
    let adjusted = color * exp2(stops);
    @if(clamp_output) return clamp(adjusted, vec3f(0.0), vec3f(1.0));
    @if(!clamp_output) return adjusted;
}

Import it from shaders/main.wesl:

import package::exposure::apply_exposure;

@fragment
fn main(@location(0) color: vec4f) -> @location(0) vec4f {
    return vec4f(apply_exposure(color.rgb, 1.0), color.a);
}

Enable a shader feature at compile time:

import wesl

result = wesl.compile_file(
    "shaders/main.wesl",
    features={"clamp_output": True},
)
print(result.wgsl)

Pass result.wgsl to your renderer, such as device.create_shader_module(code=result.wgsl) in wgpu-py. The GPU runtime validates the WGSL. Use compile_source() for a string or compile() for a mapping of modules. See the API reference for options, library imports, and diagnostics.

compile_file() resolves imports from the shader file's parent directory. Use Compiler.from_project() for a wesl.toml project.

Test a shader

Save this as shaders/math.test.wesl:

import wgsl_test::expectEq;

@test
fn addition() {
    expectEq(3u + 4u, 7u);
}

Run pytest:

python -m pytest shaders -q

The plugin collects @test functions and reports failures at the shader file and line. Assertion shaders are bundled. Execution requires a hardware or software WebGPU adapter. See the shader testing guide for Python fixtures, compute tests, and image comparisons.

License

MIT.

Metadata

Release files for wesl-py 0.1.0

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

Source distribution (sdist)

Source distribution for wesl-py 0.1.0
File Size Uploaded Provenance Actions
wesl_py-0.1.0.tar.gz 616.6 kB With provenance Details for wesl_py-0.1.0.tar.gz

Built distributions (wheels)

Table of built distributions (wheels) for wesl-py 0.1.0
File Actions
wesl_py-0.1.0-cp312-abi3-win_amd64.whl CPython 3.12 abi3 Windows x86-64 Details for wesl_py-0.1.0-cp312-abi3-win_amd64.whl
wesl_py-0.1.0-cp312-abi3-manylinux_2_28_x86_64.whl CPython 3.12 abi3 Linux glibc 2.28+ x86-64 Details for wesl_py-0.1.0-cp312-abi3-manylinux_2_28_x86_64.whl
wesl_py-0.1.0-cp312-abi3-manylinux_2_28_aarch64.whl CPython 3.12 abi3 Linux glibc 2.28+ ARM64 Details for wesl_py-0.1.0-cp312-abi3-manylinux_2_28_aarch64.whl
wesl_py-0.1.0-cp312-abi3-macosx_11_0_arm64.whl CPython 3.12 abi3 macOS 11.0+ ARM64 Details for wesl_py-0.1.0-cp312-abi3-macosx_11_0_arm64.whl

Total release size: 7.4 MB

Release files / wesl_py-0.1.0.tar.gz

Download URL wesl_py-0.1.0.tar.gz
Size 616.6 kB
Tags Source
SHA-256 checksum
How to use checksums
81efaf3386cf5d1dbc22b25d45b35b29bdefc336984956f18cb15b4f517a0778
BLAKE2b-256 checksum
How to use checksums
1ab8cf9c1f0e32f5f218db707c4474a49d8b18fad5aedb9ae59459949b461922
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 Oct 17, 2026.

Transparency log

Release files / wesl_py-0.1.0-cp312-abi3-win_amd64.whl

Download URL wesl_py-0.1.0-cp312-abi3-win_amd64.whl
Size 1.8 MB
Tags CPython 3.12 Windows x86-64 abi3
SHA-256 checksum
How to use checksums
ddf972559c4d9df5abacc4fd8b3a8fb8ad5000e1e3f41030f65bc7516600bdd6
BLAKE2b-256 checksum
How to use checksums
2d66fed4463924550156c604c6b102a66a0c2b228432a0c96d12a9372ffc6ff9
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 Oct 17, 2026.

Transparency log

Release files / wesl_py-0.1.0-cp312-abi3-manylinux_2_28_x86_64.whl

Download URL wesl_py-0.1.0-cp312-abi3-manylinux_2_28_x86_64.whl
Size 1.7 MB
Tags CPython 3.12 Linux glibc 2.28+ x86-64 abi3
SHA-256 checksum
How to use checksums
98edc40494713c0167dbe6de247db297698e6ea342ba6162a15e487d80874b46
BLAKE2b-256 checksum
How to use checksums
3b36059f9a0e696cb0c7cd05e43578abf248ce04a062c191c9da65081c4b448d
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 Oct 17, 2026.

Transparency log

Release files / wesl_py-0.1.0-cp312-abi3-manylinux_2_28_aarch64.whl

Download URL wesl_py-0.1.0-cp312-abi3-manylinux_2_28_aarch64.whl
Size 1.6 MB
Tags CPython 3.12 Linux glibc 2.28+ ARM64 abi3
SHA-256 checksum
How to use checksums
96a1821ee411aa0996fe23deb9ebf52fcfbc33690c24aefc6baaf76cba5aa48c
BLAKE2b-256 checksum
How to use checksums
2041a8d89ea7355095e12821aa8a05d42bdab410694cf3c372032b5f4a0b9456
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 Oct 17, 2026.

Transparency log

Release files / wesl_py-0.1.0-cp312-abi3-macosx_11_0_arm64.whl

Download URL wesl_py-0.1.0-cp312-abi3-macosx_11_0_arm64.whl
Size 1.5 MB
Tags CPython 3.12 abi3 macOS 11.0+ ARM64
SHA-256 checksum
How to use checksums
f6e52dc3c18b88dffc69e1640c5c5946dd08c74b31a4d3b560503e01b1323ba8
BLAKE2b-256 checksum
How to use checksums
93f1be254620d0d70cdd2b8cb740cc5bb4f3f4e436fc88afefb7ed6da811afe5
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 Oct 17, 2026.

Transparency log

Security for wesl-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.

Select from 5 files

Attestation for wesl_py-0.1.0.tar.gz

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 17, 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.

Release history Release notifications | RSS feed

This release

0.1.0 This release

5 release files Full provenance

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