WebAssembly from Python.
Project description
wasmpy
WebAssembly in Python.
Wasmpy is a lightweight layer that sits between Python and WebAssembly. When attempting to import a WebAssembly file, the file is converted into machine code for native speeds.
Installing
python3 -m pip install wasmpy
Usage
To get started, first import the wasmpy
module to register the WebAssembly import hooks.
Then you can just import wasm_or_wat_file
to load a WebAssembly module.
Example
|- my_module
|- __init__.py
|- wasm_math.wat
File: __init__.py
import wasmpy
from .wasm_math import add
File: wasm_math.wat
(module
(func (export "add") (param i32 i32) (result i32)
(i32.add (local.get 0) (local.get 1))
)
)
>>> import my_module
>>> my_module.add(45, 960)
1005
>>>
Building From Source
On Windows this requires the mingw-w64 as
tool to be on PATH.
git clone https://github.com/olivi-r/wasmpy.git
cd wasmpy
python3 setup.py assemble
python3 -m pip install .
Limitations
Wasmpy is still in active development, and only supports x86/x86-64 Windows and Linux machines and lacks some key features:
i64.div_s
,i64.div_u
,i64.rem_s
andi64.rem_u
instructions on x86- memories and memory instructions
- most control instructions
- imports
- tables
Wasmpy is being developed in accordance with the wasm-core-1 recommendation, which means it lacks support for features introduced in WebAssembly 2.0 drafts.
In future all of these limitations will be overcome and wasmpy will offer support for WASI and allow interfacing directly with CPython's c-api similar to standard C/C++ Python extensions.
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
Hashes for wasmpy-0.2.0-cp36-abi3-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | a4d40bceeb845bfb522ef41e02e45447d73e74813b8999ee121f1aea502ea276 |
|
MD5 | 79fd1a60c9cec6471d9af27d38535c6f |
|
BLAKE2b-256 | 394076cc5c92097f97eab61c96a8bd14b00ef6c45d94e60b50cdcdc1f341ed96 |
Hashes for wasmpy-0.2.0-cp36-abi3-win32.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | ca1cef80f7c38ed77a213ed91d72597d1097e3bb88999a465db775f204225684 |
|
MD5 | 8f5b9c4da8ddc4bf981c67c4341f327f |
|
BLAKE2b-256 | b229c8a1c2721ad2f43650a84e528d04331c5fc86149340f3dc7e35e70f6e6b5 |
Hashes for wasmpy-0.2.0-cp36-abi3-musllinux_1_1_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | c829ee5932d187cbd347d38ffe348129f4da1619cafaa6e4de8f1159c0de0e7b |
|
MD5 | e6c8b780c4332f265fb3ff483e8a8c81 |
|
BLAKE2b-256 | f72cbb3e55ed750c33b8576e23ebbad7eaec7f9896cf46cb8f416173e3e8be8d |
Hashes for wasmpy-0.2.0-cp36-abi3-musllinux_1_1_i686.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 93de057385e694ca75cece3e1420919cd1412a4c818ce0c3a03b4fd729fef5ea |
|
MD5 | 4093e0600714499049f1c24aad42f7cd |
|
BLAKE2b-256 | 73c0906fea7d1ae0e82e08c77bf7cbc07d25f01b7ef8b953b91edfa0a36c55c4 |
Hashes for wasmpy-0.2.0-cp36-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | aef17c41f8685ce549714adbd6c807ba25b92d8efacd9e62a716048295e2824b |
|
MD5 | bd91f71207c369341993ded381dc6dcd |
|
BLAKE2b-256 | 58089e9eea08097bceae22c194e7301aba1837e8bb983c0c01450841fc4001cc |
Hashes for wasmpy-0.2.0-cp36-abi3-manylinux_2_5_i686.manylinux1_i686.manylinux_2_17_i686.manylinux2014_i686.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | ce5d493f426f924efde3144413710630de1d9358347309394db29cb7f5fc8394 |
|
MD5 | 38d515357996d4612b5eb06defe2acb5 |
|
BLAKE2b-256 | 2e7aeb6106e88c893b861dfc03a12ab4b26503965337d13fd252e6ca50e7b284 |