跳转到主要内容

运行WebAssembly二进制文件的Python扩展

项目描述

Wasmer logo Wasmer Python,LLVM 编译器 PyPI 版本 Wasmer Python 文档 Wasmer PyPI 下载 Wasmer Slack 通道

wasmer 是一个完整成熟的 WebAssembly 运行时,用于 Python。 wasmer_compiler_llvmwasmer 提供了 LLVM 编译器,使得 wasmer 能够编译 WebAssembly 模块。

其他编译器存在

  • wasmer_compiler_cranelift,
  • wasmer_compiler_singlepass.

要获取更全面的视图,请参阅 wasmer 包本身 的文档。

安装

此包必须与 wasmer 包一起使用,因此

$ pip install wasmer
$ pip install wasmer_compiler_llvm

用法

wasmer.engine 中的任何引擎都可以将 wasmer_compiler_llvm.Compiler 类作为参数

from wasmer import engine, Store, Module, Instance
from wasmer_compiler_llvm import Compiler

# Let's use the LLVM compiler with the JIT engine…
store = Store(engine.JIT(Compiler))

# … or with the native engine!
store = Store(engine.Native(Compiler))

# And now, compile the module.
module = Module(store, open('my_program.wasm', 'rb').read())

# Now it's compiled, let's instantiate it.
instance = Instance(module)

# And get fun, for example by calling the `sum` exported function!
print(instance.exports.sum(1, 2))

文档

请访问 https://wasmerio.github.io/wasmer-python/api/wasmer_compiler_llvm/ 浏览文档。

或者,运行 just build compiler-llvm 然后运行 just doc 以在 docs/api/wasmer_compiler_llvm.html 内生成文档。

项目详情


下载文件

下载适用于您平台的文件。如果您不确定选择哪个,请了解有关 安装包 的更多信息。

源代码分发

此版本没有可用的源代码分发文件。有关 生成分发存档 的教程。

构建分发

wasmer_compiler_llvm-1.1.0-py3-none-any.whl (1.8 kB 查看哈希值)

上传时间 Python 3

wasmer_compiler_llvm-1.1.0-cp310-cp310-manylinux_2_27_x86_64.whl (13.2 MB 查看哈希值)

上传时间 CPython 3.10 manylinux: glibc 2.27+ x86-64

wasmer_compiler_llvm-1.1.0-cp310-cp310-macosx_10_7_x86_64.whl (12.4 MB 查看哈希值)

上传时间 CPython 3.10 macOS 10.7+ x86-64

wasmer_compiler_llvm-1.1.0-cp39-cp39-manylinux_2_27_x86_64.whl (13.2 MB 查看哈希值)

上传于 CPython 3.9 manylinux: glibc 2.27+ x86-64

wasmer_compiler_llvm-1.1.0-cp39-cp39-macosx_11_0_arm64.whl (12.9 MB 查看哈希值)

上传于 CPython 3.9 macOS 11.0+ ARM64

wasmer_compiler_llvm-1.1.0-cp39-cp39-macosx_10_7_x86_64.whl (12.4 MB 查看哈希值)

上传于 CPython 3.9 macOS 10.7+ x86-64

wasmer_compiler_llvm-1.1.0-cp38-cp38-manylinux_2_27_x86_64.whl (13.2 MB 查看哈希值)

上传于 CPython 3.8 manylinux: glibc 2.27+ x86-64

wasmer_compiler_llvm-1.1.0-cp38-cp38-macosx_10_7_x86_64.whl (12.4 MB 查看哈希值)

上传于 CPython 3.8 macOS 10.7+ x86-64

wasmer_compiler_llvm-1.1.0-cp37-cp37m-manylinux_2_27_x86_64.whl (13.2 MB 查看哈希值)

上传于 CPython 3.7m manylinux: glibc 2.27+ x86-64

wasmer_compiler_llvm-1.1.0-cp37-cp37m-macosx_10_7_x86_64.whl (12.4 MB 查看哈希值)

上传于 CPython 3.7m macOS 10.7+ x86-64

支持者