Metadata-Version: 2.1
Name: wasmpy-build
Version: 1.0.0
Summary: WebAssembly build tool for CPython C/C++ extensions
Author-email: Olivia Ryan <olivia.r.dev@gmail.com>
License: MIT License
        
        Copyright (c) 2022 Olivia Ryan
        
        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.
        
Project-URL: Issues, https://github.com/olivi-r/wasmpy-build/issues
Project-URL: Repository, https://github.com/olivi-r/wasmpy-build
Classifier: Programming Language :: C
Classifier: Programming Language :: C++
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3.6
Classifier: Programming Language :: Python :: 3.7
Classifier: Programming Language :: Python :: 3.8
Classifier: Programming Language :: Python :: 3.9
Classifier: Programming Language :: Python :: 3.10
Classifier: Programming Language :: Python :: 3.11
Classifier: Programming Language :: Python :: 3.12
Classifier: Programming Language :: Python :: Implementation :: CPython
Classifier: Environment :: WebAssembly
Classifier: Environment :: WebAssembly :: WASI
Classifier: License :: OSI Approved :: MIT License
Requires-Python: >=3.6
Description-Content-Type: text/markdown
License-File: LICENSE
Requires-Dist: appdirs
Requires-Dist: requests
Requires-Dist: tqdm

# wasmpy-build

[![appveyor-build](https://img.shields.io/appveyor/build/olivi-r/wasmpy-build?logo=appveyor)](https://ci.appveyor.com/project/olivi-r/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](https://github.com/WebAssembly/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

```python
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:

```python
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

```bash
wasmpy-build my_file.c -o my_file.wasm
```

### C++

```bash
wasmpy-build++ my_file.cpp -o my_file.wasm
```

or

```bash
wasmpy-build-cpp my_file.cpp -o my_file.wasm
```

# Installation

### Install with pip

```bash
pip install wasmpy-build
```

### Build from source

```bash
git clone --recurse-submodules https://github.com/olivi-r/wasmpy-build
cd wasmpy-build
python generate.py
python -m pip install .
```
