A Python wrapper for Binaryen
Project description
Binaryen.py
Binaryen.py is a python wrapper for Binaryen. Use this to create, optimise and interpret WebAssembly binaries in python.
Installation
First make sure Binaryen is installed and accessible from your path. For Linux/MacOS it's recommended to install it from your package manager or homebrew (on MacOS). Alternatively, download precompiled binaries of Binaryen.
Install through PyPI.
pip install binaryen.py
Test
pytest --doctest-modules --doctest-continue-on-failure
Format
black --extend-exclude binaryen/_binaryen_cffi.py .
Docs
mkdocs serve
Updating the Python header file
Get the latest binaryen header file and binaries.
Comment out #include <stdbool.h>
, #include <stddef.h>
and #include <stdint.h>
cpp -nostdinc -E -P binaryen-c.h | sed '/^\/\//d; s/##//g; s/;;/;/g;' | tr '\n' ' ' | sed '1s/^[[:space:]]*//; s/ */ /g;s/; /;\n/g;' | sed '/^__attribute__((deprecated))/d' | clang-format -style "{ColumnLimit: 0}" > binaryen-py.h
This cleans up the header file and removes deprecated code
Replace Union types with the largest type of that Union. E.g.
struct BinaryenLiteral
{
uintptr_t type;
union
{
int32_t i32;
int64_t i64;
float f32;
double f64;
uint8_t v128[16];
const char *func;
};
};
Becomes
struct BinaryenLiteral
{
uintptr_t type;
uint8_t v128[16];
};
Build the cffi interface by running python binaryen_build.py
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Hashes for binaryen.py-0.0.2-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | f4495ac9341c082a8ac33e8a034fc233d6410356a1803e3c2117040c4e12c2a2 |
|
MD5 | dec86c7e96755445263f708a33618576 |
|
BLAKE2b-256 | e0c2a711f0e773cf2299f6648eda2b64ea07d984fbf46e7ce55bc141cc5664c2 |