Publish pywasm3 to pypi

extensions
Volodymyr Shymanskyy 3 years ago
parent be93e88768
commit 1ca41e5bdf

@ -516,8 +516,8 @@ jobs:
run: |
cd platforms/python
python setup.py sdist
pip install ./dist/wasm3-*.tar.gz
- name: Test with pytest
pip install ./dist/pywasm3-*.tar.gz
- name: Test
run: |
pip install pytest
pytest platforms/python/test
pytest platforms/python

@ -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)

@ -88,7 +88,7 @@ static PyMethodDef M3_Environment_methods[] = {
};
static PyType_Slot M3_Environment_Type_slots[] = {
{Py_tp_doc, "The m3.Environment type"},
{Py_tp_doc, "The wasm3.Environment type"},
{Py_tp_finalize, delEnvironment},
{Py_tp_new, newEnvironment},
{Py_tp_methods, M3_Environment_methods},
@ -150,7 +150,7 @@ static PyMethodDef M3_Runtime_methods[] = {
};
static PyType_Slot M3_Runtime_Type_slots[] = {
{Py_tp_doc, "The m3.Runtime type"},
{Py_tp_doc, "The wasm3.Runtime type"},
// {Py_tp_finalize, delRuntime},
// {Py_tp_new, newRuntime},
{Py_tp_methods, M3_Runtime_methods},
@ -169,7 +169,7 @@ static PyGetSetDef M3_Module_properties[] = {
};
static PyType_Slot M3_Module_Type_slots[] = {
{Py_tp_doc, "The m3.Module type"},
{Py_tp_doc, "The wasm3.Module type"},
// {Py_tp_finalize, delModule},
// {Py_tp_new, newModule},
// {Py_tp_methods, M3_Module_methods},
@ -280,7 +280,7 @@ M3_Function_call(m3_function *self, PyObject *args, PyObject *kwargs)
}
static PyType_Slot M3_Function_Type_slots[] = {
{Py_tp_doc, "The m3.Function type"},
{Py_tp_doc, "The wasm3.Function type"},
// {Py_tp_finalize, delFunction},
// {Py_tp_new, newFunction},
{Py_tp_call, M3_Function_call},
@ -290,7 +290,7 @@ static PyType_Slot M3_Function_Type_slots[] = {
};
static PyType_Spec M3_Environment_Type_spec = {
"m3.Environment",
"wasm3.Environment",
sizeof(m3_environment),
0,
Py_TPFLAGS_DEFAULT | Py_TPFLAGS_HAVE_GC,
@ -298,7 +298,7 @@ static PyType_Spec M3_Environment_Type_spec = {
};
static PyType_Spec M3_Runtime_Type_spec = {
"m3.Runtime",
"wasm3.Runtime",
sizeof(m3_runtime),
0,
Py_TPFLAGS_DEFAULT | Py_TPFLAGS_HAVE_GC,
@ -306,7 +306,7 @@ static PyType_Spec M3_Runtime_Type_spec = {
};
static PyType_Spec M3_Module_Type_spec = {
"m3.Module",
"wasm3.Module",
sizeof(m3_module),
0,
Py_TPFLAGS_DEFAULT | Py_TPFLAGS_HAVE_GC,
@ -314,7 +314,7 @@ static PyType_Spec M3_Module_Type_spec = {
};
static PyType_Spec M3_Function_Type_spec = {
"m3.Function",
"wasm3.Function",
sizeof(m3_function),
0,
Py_TPFLAGS_DEFAULT | Py_TPFLAGS_HAVE_GC,
@ -353,11 +353,11 @@ static PyModuleDef_Slot m3_slots[] = {
};
PyDoc_STRVAR(m3_doc,
"m3 - wasm3 bindings");
"wasm3 python bindings");
static struct PyModuleDef m3module = {
PyModuleDef_HEAD_INIT,
"m3",
"wasm3",
m3_doc,
0,
0, // methods
@ -368,7 +368,7 @@ static struct PyModuleDef m3module = {
};
PyMODINIT_FUNC
PyInit_m3(void)
PyInit_wasm3(void)
{
return PyModuleDef_Init(&m3module);
}

@ -1,13 +1,35 @@
from setuptools import setup
from distutils.core import Extension
from glob import glob
from pathlib import Path
HERE = Path(__file__).parent
SOURCES = glob('m3/*.c') + ['m3module.c']
setup(
name='wasm3',
version='0.0.1',
name = "pywasm3",
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=[
Extension('m3', sources=SOURCES, include_dirs=['m3'],
extra_compile_args=['-g', '-O0'])]
Extension('wasm3', sources=SOURCES, include_dirs=['m3'],
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"
]
)

@ -1,4 +1,4 @@
import m3
import wasm3 as m3
FIB32_WASM = bytes.fromhex(
"00 61 73 6d 01 00 00 00 01 06 01 60 01 7f 01 7f"

Loading…
Cancel
Save