Interactions between WebAssembly and Python
Project description
wasmpy
Interacting with WebAssembly code from python.
Wasmpy is a fairly lightweight layer that sits between Python and the WebAssembly code. When attempting to import a WebAssembly file, the file is read and it is converted into native machine code for native speeds.
This project is intended to be used in conjunction with wasmpy-build, although it does support regular WebAssembly files too.
Installing
Install the latest version:
python -m pip install wasmpy
Or build and install from source:
git clone https://github.com/olivi-r/wasmpy.git
cd wasmpy
python setup.py assemble
python -m pip install .
Usage
WasmPy defines import hooks to make the loading of WebAssembly binary files much easier! Just import the wasmpy
library then you are good to go!
Example:
If you have the following project setup:
|- my_wasm_file.wasm
|- main.py
Then in main.py
the following code will load the WebAssembly file:
import wasmpy
import my_wasm_file
The hook also allows importing the files from submodules, eg:
|- main.py
|- my_module
| |- my_wasm_file.wasm
Then
import wasmpy
from my_module import my_wasm_file
Functions can be called with the call function from the imported module:
import wasmpy
import wasm_math
wasm_math.call("add")(...)
This is due to WebAssembly supporting exported names that may not be valid Python names, such as add two numbers
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.1.3-cp36-abi3-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | bd80a5b617a574d33df38f2e6a9d56627df7a8bf6a0aadeb9befb8f4972b16bb |
|
MD5 | 140f0880e30bec80bd533f4a4ba37773 |
|
BLAKE2b-256 | 303af83cff073cb7ab8a7ca3c7d8d0d2590b3e5a16baa58ab33c17585faf4e86 |
Hashes for wasmpy-0.1.3-cp36-abi3-win32.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | ed90b5717903ee3f59ed41a0bb49523ccf6c84d8318863952faa0d3f37cbb1b5 |
|
MD5 | 30e6ce619592a73ee21d61e72198bd11 |
|
BLAKE2b-256 | 4c66d09ca64a57229d11491589146b867a454bf5786b1fe930ee3b30f7d4ed54 |
Hashes for wasmpy-0.1.3-cp36-abi3-musllinux_1_1_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | ae2a8ef0b33761572534bc1eba423d63d99fe0d56d41316740478fcaaf7b45a2 |
|
MD5 | 0950e6d385920cb4eec571651c5f153f |
|
BLAKE2b-256 | c0a2228104a0fcd59c215ff6a42159c9950dad8c4e59957e983236df0f1229d6 |
Hashes for wasmpy-0.1.3-cp36-abi3-musllinux_1_1_i686.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 9eeab759ec012750fa02d28b2633bcd99e0e1c848d655b77819205492b591bb9 |
|
MD5 | aa4c74a869e09896efebf5825874ebd7 |
|
BLAKE2b-256 | 44d2747d0bf691cf4a8fe627a14d082774c7f374185d82923abaa91494678f06 |
Hashes for wasmpy-0.1.3-cp36-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | f58b02b41dcfe56009237afa4189cd41f73844d18b4d8ec0f54def0b583ad34b |
|
MD5 | 39e1a3c365137b3a20daeca9647b5f57 |
|
BLAKE2b-256 | d324be2de7bf79ca9237fb54c62280ed36dda148f868a632ade32a80f4fcce4c |
Hashes for wasmpy-0.1.3-cp36-abi3-manylinux_2_5_i686.manylinux1_i686.manylinux_2_17_i686.manylinux2014_i686.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 8ba68b857496ccc887c2c40d10b15ff735cfa04fb031ae3dd9a20d8e37ee0311 |
|
MD5 | e06d1ca54dc91cd36d1d5a66cb520a63 |
|
BLAKE2b-256 | 3245179ca2f82507c695fa2be9bd01c9e1d11d7f68422b2f5bede799076848ea |