Metadata-Version: 2.1
Name: wasmpy
Version: 0.1.3
Summary: Interactions between WebAssembly and Python
Home-page: https://github.com/olivi-r/wasmpy
Author: Olivia Ryan
Author-email: olivia.r.dev@gmail.com
License: MIT
Classifier: Development Status :: 3 - Alpha
Classifier: Intended Audience :: Developers
Classifier: Environment :: WebAssembly
Classifier: Programming Language :: C++
Classifier: Programming Language :: Assembly
Classifier: Programming Language :: Python :: 3.6
Classifier: Programming Language :: Python :: 3.7
Classifier: Programming Language :: Python :: 3.8
Classifier: Programming Language :: Python :: 3.9
Classifier: Programming Language :: Python :: 3.10
Classifier: Programming Language :: Python :: 3.11
Classifier: License :: OSI Approved :: MIT License
Requires-Python: >=3.6
Description-Content-Type: text/markdown
License-File: LICENSE

[![AppVeyor](https://img.shields.io/appveyor/build/olivi-r/wasmpy)](https://ci.appveyor.com/project/olivi-r/wasmpy)

# 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](https://github.com/olivi-r/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:
```py
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 
```py
import wasmpy
from my_module import my_wasm_file
```

Functions can be called with the call function from the imported module:

```py
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`
