Skip to main content

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 as create_canvas() and frame_rate()
  • p5.js-style aliases such as createCanvas() and frameRate() delegate to the same implementations
  • excluded browser-only APIs fail with explicit p5 exceptions 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=True or --headless for 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 packaged p5.rust._canvas extension

For runtime details, see docs/user/backends.md.

Examples

Examples live in examples/.

A few useful entry points:

  • examples/basic_shapes.py
  • examples/bouncing_ball.py
  • examples/transforms.py
  • examples/image_text_data.py
  • examples/pixels_blend_export.py
  • examples/plugin_hooks.py
  • examples/webgl_primitives_gallery.py

See examples/README.md for the full index.

Documentation map

User docs:

  • docs/user/getting_started.md
  • docs/user/lifecycle.md
  • docs/user/backends.md
  • docs/user/compatibility.md
  • docs/user/images_and_pixels.md
  • docs/user/events.md
  • docs/user/plugins.md

Technical docs:

  • docs/technical/testing.md
  • docs/technical/releasing.md
  • docs/technical/hidpi_rendering.md
  • docs/technical/native_pyglet_renderer.md
  • docs/technical/rust_acceleration.md
  • docs/technical/p5_canvas_rust_backend.md
  • docs/technical/canvas_migration_release.md
  • docs/technical/advanced_3d_media_strategy.md
  • docs/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


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

p5py_vibe-0.2.4.tar.gz (107.3 kB view details)

Uploaded Source

Built Distributions

If you're not sure about the file name format, learn more about wheel file names.

p5py_vibe-0.2.4-cp312-cp312-win_amd64.whl (2.8 MB view details)

Uploaded CPython 3.12Windows x86-64

p5py_vibe-0.2.4-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (4.2 MB view details)

Uploaded CPython 3.12manylinux: glibc 2.17+ x86-64

p5py_vibe-0.2.4-cp312-cp312-macosx_11_0_arm64.whl (2.4 MB view details)

Uploaded CPython 3.12macOS 11.0+ ARM64

p5py_vibe-0.2.4-cp312-cp312-macosx_10_12_x86_64.whl (2.5 MB view details)

Uploaded CPython 3.12macOS 10.12+ x86-64

File details

Details for the file p5py_vibe-0.2.4.tar.gz.

File metadata

  • Download URL: p5py_vibe-0.2.4.tar.gz
  • Upload date:
  • Size: 107.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for p5py_vibe-0.2.4.tar.gz
Algorithm Hash digest
SHA256 bd3b7ab883de7342f0a903cc3e48a484e27157da69e409975c5dcc49ec2603e0
MD5 a38f3825777b6a68203f90093d78db18
BLAKE2b-256 fb36f1b12385040b062b781758fbebd5c8feb3ee424a01b9af81b87dd3020754

See more details on using hashes here.

Provenance

The following attestation bundles were made for p5py_vibe-0.2.4.tar.gz:

Publisher: publish.yml on JonathanHHenson/p5.py

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file p5py_vibe-0.2.4-cp312-cp312-win_amd64.whl.

File metadata

  • Download URL: p5py_vibe-0.2.4-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

Hashes for p5py_vibe-0.2.4-cp312-cp312-win_amd64.whl
Algorithm Hash digest
SHA256 60e9fc0c69b3423365af5cb86a97597170342145a7cbc30b1d869bb8d3a47f91
MD5 f3e269d2e1192df58ff7e4e4d67828ed
BLAKE2b-256 05a5ce1f50271aff5859b53ab63749acab54bd0ddc3ca81e5f392d86645dfc37

See more details on using hashes here.

Provenance

The following attestation bundles were made for p5py_vibe-0.2.4-cp312-cp312-win_amd64.whl:

Publisher: publish.yml on JonathanHHenson/p5.py

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file p5py_vibe-0.2.4-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for p5py_vibe-0.2.4-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 7266088a44ae9021fc69531729e1efe9eae7de8dab7bd0846b72f5385eac70cd
MD5 59339ca5a7dbbf49d0a132794977d7c0
BLAKE2b-256 45ca52442dd251e734448ecad6d9e08d6a188e8b6df6357f3cde11834ca60c7a

See more details on using hashes here.

Provenance

The following attestation bundles were made for p5py_vibe-0.2.4-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl:

Publisher: publish.yml on JonathanHHenson/p5.py

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file p5py_vibe-0.2.4-cp312-cp312-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for p5py_vibe-0.2.4-cp312-cp312-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 98b52f4bd9e74a128210303a8ba1be54d109bcfb407321482887f1b5d7fadbb5
MD5 cc54775f49d4ee9f861feec7cd649bcd
BLAKE2b-256 71ceef20d7a0503f3f7780e9dbbd04221909f93ff59cc8e8e422c294658a1e71

See more details on using hashes here.

Provenance

The following attestation bundles were made for p5py_vibe-0.2.4-cp312-cp312-macosx_11_0_arm64.whl:

Publisher: publish.yml on JonathanHHenson/p5.py

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file p5py_vibe-0.2.4-cp312-cp312-macosx_10_12_x86_64.whl.

File metadata

File hashes

Hashes for p5py_vibe-0.2.4-cp312-cp312-macosx_10_12_x86_64.whl
Algorithm Hash digest
SHA256 e9ce5180ec6e23cf77deea0016cd75267c4e8c8f9c69292884ab3a5ef89b8012
MD5 ea63ae432c50536167a3dff3470adbdf
BLAKE2b-256 331944cfb19e486c5468bdb52f95c66fa35f9ef1c8b90e4db7d5b279642ef0ac

See more details on using hashes here.

Provenance

The following attestation bundles were made for p5py_vibe-0.2.4-cp312-cp312-macosx_10_12_x86_64.whl:

Publisher: publish.yml on JonathanHHenson/p5.py

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page