Skip to main content

WebAssembly build tool for CPython C/C++ extensions

Project description

wasmpy-build

appveyor-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


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

Uploaded Source

Built Distribution

wasmpy_build-1.0.0-py3-none-any.whl (1.8 MB view hashes)

Uploaded Python 3

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page