Agriya Khetarpal
Python/JavaScript
Foreign function interface
WebAssembly + JavaScript stdlib
{
Glue code
micropip
(CDN)
225+ packages!
(PyPI)
pure Python wheels
and essential low-level libraries
https://diataxis.fr/
Diátaxis, from the Ancient Greek δῐᾰ́τᾰξῐς: dia (across) and taxis (arrangement).
New entrant!
Jupyter running natively in the browser – powered by WASM, powered by Pyodide!
in code editors & IDEs
through literate programming environments
via containers and virtualisation software
threading
or multiprocessing
socket
from the stdlib)Words by the Google Chrome team, comics adaptation by Scott McCloud
This work is licensed under the Creative Commons Attribution-Noncommercial-No Derivative Works 2.5 License.
Words by the Google Chrome team, comics adaptation by Scott McCloud
This work is licensed under the Creative Commons Attribution-Noncommercial-No Derivative Works 2.5 License.
Quick show of hands: how many of you have used five?
three?
one?
pytest
, or other test runnersStart
Check out sources
Set up
Python and Emscripten
pyodide build
Invoke
Run tests
Install Node.js
End
pypa/build
pyodide build
builds a wheelpip install build && python -m build
sysconfig
data to trick cross-compilationpyodide-build
toolEmscripten
Drop-in replacements for GNU
GCC
and ld
, and wrappers for CMake
, Make
, and other build tools
{distribution}-{version}-{python tag}-{abi tag}-{platform tag}.whl
Pure Python wheels are named mypackage-0.1.0-py3-none-any.whl
Compiled wheels get tagged as
mypackage-0.1.0-cp312-cp312-emscripten_3_1_58-wasm32-any.whl
i.e., reflecting the Emscripten version in the ABI tag. This has now changed to pyodide_20XY_Z
to reflect the current year and build number.
They will contain Emscripten-compiled shared objects. Let's see an example from the scipy.odr
module (orthogonal distance regression)
manylinux-amd64
wheel
WebAssembly wheel
├── __init__.py
├── __odrpack.cpython-312-x86_64-linux-gnu.so
├── _odrpack.py
├── models.py
└── odrpack.py
├── __init__.py
├── __odrpack.cpython-312-wasm32-emscripten.so
├── _odrpack.py
├── models.py
└── odrpack.py
ELF binaries
WASM binaries
0x7F
magic number
\0asm
magic number
wasm32-emscripten
target are nascent (flang
and LFortran)gfortran
) and commercial ones (NAG, ifx
, ifort
, etc.)f2c
to convert all the Fortran 77 code to C codef2c
bugs, or wrapper differencescall_indirect (param i32 i32) (result i32)
func $funcname (param $var0 i32 i32 i32) (result i32)
function pointer defined with two inputs
when the symbol asks for three
jupyterlite-sphinx
A Sphinx
extension providing a set of utilities to convert doctest-based examples to notebooks
provides a Pyodide kernel for those noteboks
Simply add the .. try_examples
::
reST stub to your example's docstring:
>>> x = 2 >>> y = 2 >>> x + y 4
and a button in the HTML source is generated for you!
pip install jupyterlite-sphinx
emscripten-forge – like conda-forge, but for wasm32-emscripten
as a target
PySheets – a powerful Pythonic spreadsheet UI, running in the browser
PyCafe – a platform for sharing and running Python browser applications
reactive Jupyter notebooks that can be deployed as WASM data apps
PyScript – a framework for Python web applications (uses MicroPython and Pyodide)
Please feel free to say hello!
in/agriyakhetarpal
agriyakhetarpal
agriyakhetarpal
agriyakhetarpal [at] outlook [dot] com
Content licensed under the CC-by-SA Attribution-ShareAlike Version 4.0 International License
Special thanks to (note: pending permission from them)
Ralf Gommers
Albert Steppi
Melissa Mendonça
Robert Hood Chatham
Gyeongjae Choi
Loïc Estève
Emoji by openmoji.org