Metadata-Version: 2.1
Name: wasm-runtime
Version: 0.2
Summary: WebAssembly-powered, sandboxed implementation of Python runtime for safely exec()-cuting dynamic Python code.
Author-email: AWeirdDev <aweirdscratcher@gmail.com>
License: MIT License
        
        Copyright (c) 2024 JC
        
        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: Source, https://github.com/AWeirdScratcher/wasm_runtime
Project-URL: Bug Tracker, https://github.com/AWeirdScratcher/wasm_runtime/issues
Keywords: wasm,runtime,python,sandbox,restricted,limited
Classifier: Programming Language :: Python :: 3
Classifier: License :: OSI Approved :: MIT License
Classifier: Operating System :: OS Independent
Requires-Python: >=3
Description-Content-Type: text/markdown
License-File: LICENSE
Requires-Dist: requests

# wasm-runtime

WebAssembly-powered, sandboxed implementation of Python runtime for safely `exec()`-cuting dynamic Python code.

This is an active version of [wasm_exec](https://github.com/Jflick58/wasm_exec) created by [Justin Flick](https://github.com/Jflick58).<br />See [Jflick58/wasm_exec/LICENSE](https://github.com/Jflick58/wasm_exec/blob/main/LICENSE) and [● wasm_runtime/LICENSE](https://github.com/AWeirdDev/wasm_runtime).

<div align="center">

`$ pip install wasm-runtime`

</div>

<br />

## Use

```python
from wasm_runtime import WasmRuntime

runtime = WasmRuntime()
result = runtime.exec("print('Hi, Mom!')")

print(result)
# Result(stdout='Hi, Mom!\n', stderr='', ...)
```

## <kbd>class</kbd> WasmRuntime

```python
__init__(
    self, 
    use_fuel: bool = False, 
    fuel: int = 400_000_000, 
    runtime_path: str = ""
)
```

Creates a new instance of WebAssembly runtime.

Original code by Justin Flick.

**Args:**
- use_fuel (`bool`): Whether to use fuel.
- fuel (`int`): Fuel.
- runtime_path (`str`): Runtime path. If not specified, the runtime will be downloaded automatically.

### <kbd>def</kbd> exec

```python
exec(self, code: str) -> Result
```

Execute Python code.

**Args:**
- code (`str`): Python code.

## <kbd>dataclass</kbd> Result

```python
stdout: str
stderr: str
memory_size: int
data_len: int
fuel_consumed: int
```
