Skip to content

Support "python mode" for the p5 package and support the py5 package #949

@tuzz

Description

@tuzz

The p5 package that the Pyodide prototype is using is based on the p5.js library. It uses names like createCanvas instead of size which means that programs can't be copied to your local machine and run with the p5 package in CPython. The editor-ui shims are adapting the interface of the p5.js library (example) so we need to write equivalent adapters for p5 and also the py5 package which has a few additional modifications in the shim.

While investigating this, I found this helpful video which explains the different Processing libraries and found this useful table that also contains a list with features and limitations of each. In short, we need to support "python mode" in a web context and the only implementation that supports that (from the table) is ProcessingJS which is used by Skulpt and Trinket but is no longer supported. The pyp5js project has a GitHub issue where someone attempted to translate between python mode and p5.js with Python but the code was only a proof of concept.

Therefore, I think we have two possible approaches:

  1. Convert our p5 and py5 shims from Skulpt plugins to plain JavaScript files that export an object in that format that Pyodide's registerJsModule function expects. Then, instead of using the p5 package from the Basthon project, we could just register this module instead.

  2. Convert our p5 and py5 shims from Skulpt plugins to Python packages that import p5.js and export the "python mode" interface we want. This might be more portable because it isn't Pyodide specific but is probably more effort because we need to adapt from the the shims written in JavaScript to the equivalent in Python.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions