ryanking13-pyodide
v0.21.0
Published
The Pyodide JavaScript package
Downloads
4
Readme
Pyodide JavaScript package
Usage
Download and extract Pyodide packages from Github
releases
(pyodide-build-*.tar.bz2
). The version of the release needs to match exactly the version of this package.
Then you can load Pyodide in Node.js as follows,
let pyodide_pkg = await import("pyodide/pyodide.js");
let pyodide = await pyodide_pkg.loadPyodide({
indexURL: "<pyodide artifacts folder>",
});
await pyodide.runPythonAsync("1+1");
Note: To start node REPL with support for top level await, use node --experimental-repl-await
.
See the documentation fore more details.
Details
The JavaScript code in this package is responsible for the following tasks:
- Defines the public JavaScript API
- Package loading code to allow loading of other Python packages.
- Can load micropip to bootstrap loading of pure Python wheels
- Loads the CPython interpreter and the core/pyodide emscripten application which embeds the interpreter.
- Injects the
js/pyodide
JavaScript API intosys.modules
. This is the final runtime dependency forcore/pyodide
&py/pyodide
, so after this step the interpreter is fully up and running.