A Pythonic creative coding package inspired by p5.js.
Project description
p5-py
p5-py is a Pythonic creative-coding package inspired by p5.js.
It keeps the familiar p5 sketch lifecycle and many p5-style APIs while staying native to Python, backend-agnostic, typed, and testable.
Status
The current package supports a strong 2D-first workflow on the Rust p5_canvas runtime, bounded/headless runs for deterministic tests and export, interactive native windows when available, optional WEBGL-style/3D APIs, optional media extras, and optional Rust acceleration for a few compute-heavy paths.
The public API is intentionally Python-first:
- canonical APIs use
snake_case, such ascreate_canvas()andframe_rate() - p5.js-style aliases such as
createCanvas()andframeRate()delegate to the same implementations - excluded browser-only APIs fail with explicit
p5exceptions instead of failing indirectly
Installation
Install the published package with pip:
pip install p5-py
Install optional media support when you need camera/video helpers:
pip install "p5-py[media]"
For local development in this repository, use uv:
uv sync --dev
Quick start
import p5
def setup() -> None:
p5.create_canvas(320, 240)
p5.no_stroke()
def draw() -> None:
p5.background(245)
p5.fill(255, 80, 80)
p5.circle(160, 120, 80)
p5.run(setup=setup, draw=draw)
Run a sketch headlessly for deterministic tests or export flows:
uv run python examples/basic_shapes.py --headless --frames 1
Runtime
p5-py keeps the user-facing API backend-agnostic while routing rendering, assets, text, pixels, export, and presentation through the Rust p5_canvas runtime.
- use
headless=Trueor--headlessfor bounded/offscreen tests, CI, and export - use interactive runs for native windows when the installed canvas extension supports them
load_image()and image saving are canvas-owned and require the packagedp5.rust._canvasextension
For runtime details, see docs/user/backends.md.
Examples
Examples live in examples/.
A few useful entry points:
examples/basic_shapes.pyexamples/bouncing_ball.pyexamples/transforms.pyexamples/image_text_data.pyexamples/pixels_blend_export.pyexamples/plugin_hooks.pyexamples/webgl_primitives_gallery.py
See examples/README.md for the full index.
Documentation map
User docs:
docs/user/getting_started.mddocs/user/lifecycle.mddocs/user/backends.mddocs/user/compatibility.mddocs/user/images_and_pixels.mddocs/user/events.mddocs/user/plugins.md
Technical docs:
docs/technical/testing.mddocs/technical/releasing.mddocs/technical/hidpi_rendering.mddocs/technical/native_pyglet_renderer.mddocs/technical/rust_acceleration.mddocs/technical/p5_canvas_rust_backend.mddocs/technical/canvas_migration_release.mddocs/technical/advanced_3d_media_strategy.mddocs/technical/project_plan.md
Development workflow
Common local commands:
uv run ruff check .
uv run ruff format .
uv run mypy src
uv run pytest
uv run python examples/basic_shapes.py --headless --frames 1
uv run python scripts/bump_version.py --check
cargo test --manifest-path crates/p5_canvas/Cargo.toml
uv build
Equivalent shortcuts are available in Makefile:
make lint
make test-fast
make test
make typecheck
make version-check
make bump-version VERSION=patch
make build
Compatibility policy
p5-py aims to keep the p5 mental model while remaining idiomatic Python.
- Use the snake_case APIs as the canonical interface.
- Use camelCase aliases when porting or teaching from p5.js material.
- DOM and browser-only features are excluded.
- Unsupported compatibility stubs raise explicit package-specific errors.
See docs/user/compatibility.md 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 Distribution
Built Distributions
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 p5py_vibe-0.2.5.tar.gz.
File metadata
- Download URL: p5py_vibe-0.2.5.tar.gz
- Upload date:
- Size: 107.5 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
200e255f1db525dcc16bad33b7ef77d41ab7e2c9ff782df86bcf606f3b36f9bb
|
|
| MD5 |
b026d54a315337f3e915b8fb46d93a89
|
|
| BLAKE2b-256 |
26a472ef3fff8f9ce069ca8c9f240d416906ed0e71387dc4c5fcd5402c1ebb85
|
Provenance
The following attestation bundles were made for p5py_vibe-0.2.5.tar.gz:
Publisher:
publish.yml on JonathanHHenson/p5.py
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
p5py_vibe-0.2.5.tar.gz -
Subject digest:
200e255f1db525dcc16bad33b7ef77d41ab7e2c9ff782df86bcf606f3b36f9bb - Sigstore transparency entry: 1866633209
- Sigstore integration time:
-
Permalink:
JonathanHHenson/p5.py@7d67b2061536f4c1e57b376cfa07bf7bd036b90c -
Branch / Tag:
refs/tags/v0.2.5 - Owner: https://github.com/JonathanHHenson
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@7d67b2061536f4c1e57b376cfa07bf7bd036b90c -
Trigger Event:
push
-
Statement type:
File details
Details for the file p5py_vibe-0.2.5-cp312-cp312-win_amd64.whl.
File metadata
- Download URL: p5py_vibe-0.2.5-cp312-cp312-win_amd64.whl
- Upload date:
- Size: 2.8 MB
- Tags: CPython 3.12, Windows x86-64
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
dcf2fea4506599c2bb0cd9ed7d111b9c5af0afd140ab10f6abd110243fcbcad3
|
|
| MD5 |
e53b735c5df89cc95c06ad0470836ff3
|
|
| BLAKE2b-256 |
7d2fbfeac410a9ebe89c52b39cd36f8084f0ccee5928fcd3c9e682759d92c1d8
|
Provenance
The following attestation bundles were made for p5py_vibe-0.2.5-cp312-cp312-win_amd64.whl:
Publisher:
publish.yml on JonathanHHenson/p5.py
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
p5py_vibe-0.2.5-cp312-cp312-win_amd64.whl -
Subject digest:
dcf2fea4506599c2bb0cd9ed7d111b9c5af0afd140ab10f6abd110243fcbcad3 - Sigstore transparency entry: 1866633381
- Sigstore integration time:
-
Permalink:
JonathanHHenson/p5.py@7d67b2061536f4c1e57b376cfa07bf7bd036b90c -
Branch / Tag:
refs/tags/v0.2.5 - Owner: https://github.com/JonathanHHenson
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@7d67b2061536f4c1e57b376cfa07bf7bd036b90c -
Trigger Event:
push
-
Statement type:
File details
Details for the file p5py_vibe-0.2.5-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.
File metadata
- Download URL: p5py_vibe-0.2.5-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
- Upload date:
- Size: 4.2 MB
- Tags: CPython 3.12, manylinux: glibc 2.17+ x86-64
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
99285b8c525b8d7149cf53190d8b547d1226e01ef1bd14dffa022b38f6eb9e40
|
|
| MD5 |
adad1cdbee9bbac8ae26a0c5ce62a080
|
|
| BLAKE2b-256 |
5e33ec85e066d7b906787d1528d67076023c1da0975d61cabf6514c98ef9b3c9
|
Provenance
The following attestation bundles were made for p5py_vibe-0.2.5-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl:
Publisher:
publish.yml on JonathanHHenson/p5.py
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
p5py_vibe-0.2.5-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl -
Subject digest:
99285b8c525b8d7149cf53190d8b547d1226e01ef1bd14dffa022b38f6eb9e40 - Sigstore transparency entry: 1866633524
- Sigstore integration time:
-
Permalink:
JonathanHHenson/p5.py@7d67b2061536f4c1e57b376cfa07bf7bd036b90c -
Branch / Tag:
refs/tags/v0.2.5 - Owner: https://github.com/JonathanHHenson
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@7d67b2061536f4c1e57b376cfa07bf7bd036b90c -
Trigger Event:
push
-
Statement type:
File details
Details for the file p5py_vibe-0.2.5-cp312-cp312-macosx_11_0_arm64.whl.
File metadata
- Download URL: p5py_vibe-0.2.5-cp312-cp312-macosx_11_0_arm64.whl
- Upload date:
- Size: 2.4 MB
- Tags: CPython 3.12, macOS 11.0+ ARM64
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
ebfc9fbb17b35ef5ec7f84b14ec4100f6b91490b012193d3265d74a9fd7843f1
|
|
| MD5 |
0b0676997e7cc21cb12be0c49cdb8246
|
|
| BLAKE2b-256 |
b20ed8a46e554fc4f2edbea4ebbbde71bd306e43557121eceacd7574ec9a8674
|
Provenance
The following attestation bundles were made for p5py_vibe-0.2.5-cp312-cp312-macosx_11_0_arm64.whl:
Publisher:
publish.yml on JonathanHHenson/p5.py
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
p5py_vibe-0.2.5-cp312-cp312-macosx_11_0_arm64.whl -
Subject digest:
ebfc9fbb17b35ef5ec7f84b14ec4100f6b91490b012193d3265d74a9fd7843f1 - Sigstore transparency entry: 1866633706
- Sigstore integration time:
-
Permalink:
JonathanHHenson/p5.py@7d67b2061536f4c1e57b376cfa07bf7bd036b90c -
Branch / Tag:
refs/tags/v0.2.5 - Owner: https://github.com/JonathanHHenson
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@7d67b2061536f4c1e57b376cfa07bf7bd036b90c -
Trigger Event:
push
-
Statement type:
File details
Details for the file p5py_vibe-0.2.5-cp312-cp312-macosx_10_12_x86_64.whl.
File metadata
- Download URL: p5py_vibe-0.2.5-cp312-cp312-macosx_10_12_x86_64.whl
- Upload date:
- Size: 2.5 MB
- Tags: CPython 3.12, macOS 10.12+ x86-64
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
fcb0789400ca3e4e000148b3f6dd80c6fac4e85c13c4e3e59c3b630dabd30c0a
|
|
| MD5 |
2a4c8706d77a28864e8560c303025bc0
|
|
| BLAKE2b-256 |
cd38ab70139e1899abd47719fa3ebd8280a25566b8ee419f2e94892e023789e8
|
Provenance
The following attestation bundles were made for p5py_vibe-0.2.5-cp312-cp312-macosx_10_12_x86_64.whl:
Publisher:
publish.yml on JonathanHHenson/p5.py
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
p5py_vibe-0.2.5-cp312-cp312-macosx_10_12_x86_64.whl -
Subject digest:
fcb0789400ca3e4e000148b3f6dd80c6fac4e85c13c4e3e59c3b630dabd30c0a - Sigstore transparency entry: 1866633881
- Sigstore integration time:
-
Permalink:
JonathanHHenson/p5.py@7d67b2061536f4c1e57b376cfa07bf7bd036b90c -
Branch / Tag:
refs/tags/v0.2.5 - Owner: https://github.com/JonathanHHenson
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@7d67b2061536f4c1e57b376cfa07bf7bd036b90c -
Trigger Event:
push
-
Statement type: