forked from Mirrors/wasm3
parent
be93e88768
commit
1ca41e5bdf
@ -0,0 +1,21 @@
|
|||||||
|
MIT License
|
||||||
|
|
||||||
|
Copyright (c) 2019 Volodymyr Shymanskyy
|
||||||
|
|
||||||
|
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||||
|
of this software and associated documentation files (the "Software"), to deal
|
||||||
|
in the Software without restriction, including without limitation the rights
|
||||||
|
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||||
|
copies of the Software, and to permit persons to whom the Software is
|
||||||
|
furnished to do so, subject to the following conditions:
|
||||||
|
|
||||||
|
The above copyright notice and this permission notice shall be included in all
|
||||||
|
copies or substantial portions of the Software.
|
||||||
|
|
||||||
|
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||||
|
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||||
|
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||||
|
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||||
|
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||||
|
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||||
|
SOFTWARE.
|
@ -0,0 +1,34 @@
|
|||||||
|
# pywasm3
|
||||||
|
|
||||||
|
Python binding for Wasm3, the fastest WebAssembly interpreter.
|
||||||
|
|
||||||
|
## Install
|
||||||
|
|
||||||
|
```sh
|
||||||
|
pip3 install pywasm3
|
||||||
|
```
|
||||||
|
|
||||||
|
## Usage example
|
||||||
|
|
||||||
|
```py
|
||||||
|
import wasm3
|
||||||
|
|
||||||
|
# WebAssembly binary
|
||||||
|
WASM = bytes.fromhex("""
|
||||||
|
00 61 73 6d 01 00 00 00 01 06 01 60 01 7e 01 7e
|
||||||
|
03 02 01 00 07 07 01 03 66 69 62 00 00 0a 1f 01
|
||||||
|
1d 00 20 00 42 02 54 04 40 20 00 0f 0b 20 00 42
|
||||||
|
02 7d 10 00 20 00 42 01 7d 10 00 7c 0f 0b
|
||||||
|
""")
|
||||||
|
|
||||||
|
env = wasm3.Environment()
|
||||||
|
rt = env.new_runtime(1024)
|
||||||
|
mod = env.parse_module(WASM)
|
||||||
|
rt.load(mod)
|
||||||
|
func = rt.find_function("fib")
|
||||||
|
result = func.call_argv("24")
|
||||||
|
print(result) # 46368
|
||||||
|
```
|
||||||
|
|
||||||
|
### License
|
||||||
|
This project is released under The MIT License (MIT)
|
@ -1,13 +1,35 @@
|
|||||||
from setuptools import setup
|
from setuptools import setup
|
||||||
from distutils.core import Extension
|
from distutils.core import Extension
|
||||||
from glob import glob
|
from glob import glob
|
||||||
|
from pathlib import Path
|
||||||
|
|
||||||
|
HERE = Path(__file__).parent
|
||||||
|
|
||||||
SOURCES = glob('m3/*.c') + ['m3module.c']
|
SOURCES = glob('m3/*.c') + ['m3module.c']
|
||||||
|
|
||||||
setup(
|
setup(
|
||||||
name='wasm3',
|
name = "pywasm3",
|
||||||
version='0.0.1',
|
version = "0.0.2",
|
||||||
|
description = "The fastest WebAssembly interpreter",
|
||||||
|
platforms = "any",
|
||||||
|
url = "https://github.com/wasm3/wasm3",
|
||||||
|
license = "MIT",
|
||||||
|
author = "Volodymyr Shymanskyy",
|
||||||
|
author_email = "vshymanskyi@gmail.com",
|
||||||
|
|
||||||
|
long_description = (HERE / "README.md").read_text(),
|
||||||
|
long_description_content_type = "text/markdown",
|
||||||
|
|
||||||
ext_modules=[
|
ext_modules=[
|
||||||
Extension('m3', sources=SOURCES, include_dirs=['m3'],
|
Extension('wasm3', sources=SOURCES, include_dirs=['m3'],
|
||||||
extra_compile_args=['-g', '-O0'])]
|
extra_compile_args=['-g', '-O0'])],
|
||||||
|
|
||||||
|
classifiers = [
|
||||||
|
"Topic :: Software Development :: Libraries :: Python Modules",
|
||||||
|
"Development Status :: 4 - Beta",
|
||||||
|
"License :: OSI Approved :: MIT License",
|
||||||
|
"Operating System :: POSIX :: Linux",
|
||||||
|
"Operating System :: Microsoft :: Windows",
|
||||||
|
"Operating System :: MacOS :: MacOS X"
|
||||||
|
]
|
||||||
)
|
)
|
||||||
|
Loading…
Reference in new issue