WebAssembly build tool for CPython C/C++ extensions
Project description
wasmpy-build
This tool can compile CPython C extension files, such as the ones created by Cython, to WebAssembly so that the extensions are platform independent.
Currently supports CPython 3.6 to 3.12.
wasi-sdk is automatically downloaded on first use.
Usage
Wasmpy-build can be easily integrated into an existing project by the use of a drop-in build_ext
override:
From a setup.py
script
from wasmpy_build import build_ext
from setuptools import setup, Extension
setup(
ext_modules=[Extension("mymodule", ["mymodule.c"])],
cmdclass={"build_ext": build_ext},
)
This also works with generated sources, like from Cython:
from Cython.Build import cythonize
from wasmpy_build import build_ext
from setuptools import setup, Extension
setup(
ext_modules=cythonize([
Extension("mymodule", ["mymodule.pyx"])
]),
cmdclass={"build_ext": build_ext},
)
From the command line
C
wasmpy-build my_file.c -o my_file.wasm
C++
wasmpy-build++ my_file.cpp -o my_file.wasm
or
wasmpy-build-cpp my_file.cpp -o my_file.wasm
Installation
Install with pip
pip install wasmpy-build
Build from source
git clone --recurse-submodules https://github.com/olivi-r/wasmpy-build
cd wasmpy-build
python generate.py
python -m pip install .
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
wasmpy_build-1.0.0.tar.gz
(1.4 MB
view details)
Built Distribution
File details
Details for the file wasmpy_build-1.0.0.tar.gz
.
File metadata
- Download URL: wasmpy_build-1.0.0.tar.gz
- Upload date:
- Size: 1.4 MB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.1.0 CPython/3.8.17
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 |
5c33f0e177107ff3a2f7890d615c1bb2aacd9cbd62a8b924d865795256056bc6
|
|
MD5 |
dc01f59cbf1b6a61cdf61777f5c10d65
|
|
BLAKE2b-256 |
e16147d6495987463a9b1f5bb44efcbca7ceee334db75079f9da50d5b3db67e6
|
File details
Details for the file wasmpy_build-1.0.0-py3-none-any.whl
.
File metadata
- Download URL: wasmpy_build-1.0.0-py3-none-any.whl
- Upload date:
- Size: 1.8 MB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.1.0 CPython/3.8.17
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 |
b1f55cd9170f4346251c0aa592af9dd552f3a7e4156b4b51cd7d515180ea6237
|
|
MD5 |
b691e48bf3f7432e2e9114ed280d4ed7
|
|
BLAKE2b-256 |
dfd2d3dba19c1194f64868e8aec0b0be650fb3236300a7181fe2bbe6b542fef0
|