Skip to main content

Wasmer logo Wasmer Python PyPI version Wasmer Python Documentation Wasmer PyPI downloads Wasmer Slack Channel

A complete and mature WebAssembly runtime for Python based on Wasmer.

Features:

  • Easy to use: The wasmer API mimics the standard WebAssembly API,
  • Fast: wasmer executes the WebAssembly modules as fast as possible, close to native speed,
  • Safe: All calls to WebAssembly will be fast, but more importantly, completely safe and sandboxed,
  • Modular: wasmer can compile the WebAssembly modules with different engines or compiler.

Documentation: browse the detailed API documentation full of examples.

Examples as tutorials: browse the examples/ directory, it's the best place for a complete introduction!

Quick Introduction

The wasmer package brings the required API to execute WebAssembly modules. In a nutshell, wasmer compiles the WebAssembly module into compiled code, and then executes it. wasmer is designed to work in various environments and platforms: From nano single-board computers to large and powerful servers, including more exotic ones. To address those requirements, Wasmer provides 2 engines and 3 compilers.

Succinctly, an engine is responsible to drive the compilation and the execution of a WebAssembly module. By extension, a headless engine can only execute a WebAssembly module, i.e. a module that has previously been compiled, or compiled, serialized and deserialized. By default, the wasmer package comes with 2 headless engines:

  1. wasmer.engine.JIT, the compiled machine code lives in memory,
  2. wasmer.engine.Native, the compiled machine code lives in a shared object file (.so, .dylib, or .dll), and is natively executed.

Because wasmer does not embed compilers in its package, engines are headless, i.e. they can't compile WebAssembly module; they can only execute them. Compilers live in their own standalone packages. Let's briefly introduce them:

Compiler package Description PyPi
wasmer_compiler_singlepass Super fast compilation times, slower execution times. Not prone to JIT-bombs. Ideal for blockchains On PyPi Downloads
wasmer_compiler_cranelift Fast compilation times, fast execution times. Ideal for development On PyPi Downloads
wasmer_compiler_llvm Slow compilation times, very fast execution times (close to native, sometimes faster). Ideal for Production On PyPi Downloads

We generally recommend wasmer_compiler_cranelift for development purposes and wasmer_compiler_llvm in production.

Learn more by reading the documentation of the wasmer.engine submodule.

Install

To install the wasmer Python package, and let's say the wasmer_compiler_cranelift compiler, just run those commands in your shell:

$ pip install wasmer==1.1.0
$ pip install wasmer_compiler_cranelift==1.1.0

And you're ready to get fun!

Example

We highly recommend to read the examples/ directory, which contains a sequence of examples/tutorials. It's the best place to learn by reading examples.

But for the most eager of you, and we know you're numerous you mischievous, there is a quick toy program in examples/appendices/simple.rs, written in Rust:

#[no_mangle]
pub extern fn sum(x: i32, y: i32) -> i32 {
    x + y
}

After compilation to WebAssembly, the examples/appendices/simple.wasm binary file is generated. (Download it).

Then, we can execute it in Python:

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

# Let's define the store, that holds the engine, that holds the compiler.
store = Store(engine.JIT(Compiler))

# Let's compile the module to be able to execute it!
module = Module(store, open('simple.wasm', 'rb').read())

# Now the module is compiled, we can instantiate it.
instance = Instance(module)

# Call the exported `sum` function.
result = instance.exports.sum(5, 37)

print(result) # 42!

And then, finally, enjoy by running:

$ python examples/appendices/simple.py

Development

The Python extension is written in Rust, with pyo3 and maturin.

First, you need to install Rust and Python. We will not make you the affront to explain to you how to install Python (if you really need, check pyenv). For Rust though, we advise to use rustup, then:

$ rustup install stable

To set up your environment, you'll need just, and then, install the prelude of this project:

$ cargo install just
$ just --list # to learn about all the available recipes
$ just prelude

It will install pyo3 and maturin for Python and for Rust. It will also install virtualenv.

Then, simply run:

$ source .env/bin/activate
$ just build api
$ just build compiler-cranelift
$ python examples/appendices/simple.py

Supported platforms

We try to provide wheels for as many platforms and architectures as possible. For the moment, here are the supported platforms and architectures:

Platform Architecture Triple Packages
Linux amd64 x86_64-unknown-linux-gnu wasmer ✅
wasmer_compiler_singlepass ✅
wasmer_compiler_cranelift ✅
wasmer_compiler_llvm ✅
aarch64 aarch64-unknown-linux-gnu wasmer ✅
wasmer_compiler_singlepass ❌ 1
wasmer_compiler_cranelift ✅
wasmer_compiler_llvm ✅
Darwin amd64 x86_64-apple-darwin wasmer ✅
wasmer_compiler_singlepass ✅
wasmer_compiler_cranelift ✅
wasmer_compiler_llvm ✅
Windows amd64 x86_64-pc-windows-msvc wasmer ✅
wasmer_compiler_singlepass ✅
wasmer_compiler_cranelift ✅
wasmer_compiler_llvm ❌ 2

Notes:

  • 1 wasmer_compiler_singlepass does not support aarch64 for the moment
  • 2 wasmer_compiler_llvm is not packaging properly on Windows for the moment

Wheels are all built for the following Python versions:

  • Python 3.7,
  • Python 3.8.
  • Python 3.9.
  • Python 3.10,
Learn about the “fallback” py3-none-any wheel

py3-none-any.whl

A special wasmer-$(version)-py3-none-any wheel is built as a fallback. The wasmer libray will be installable, but it will raise an ImportError exception saying that “Wasmer is not available on this system”.

This wheel will be installed if none matches before (learn more by reading the PEP 425, Compatibility Tags for Built Distributions).

Testing

Build all the packages and run the tests:

$ just build-all
$ just test

What is WebAssembly?

Quoting the WebAssembly site:

WebAssembly (abbreviated Wasm) is a binary instruction format for a stack-based virtual machine. Wasm is designed as a portable target for compilation of high-level languages like C/C++/Rust, enabling deployment on the web for client and server applications.

About speed:

WebAssembly aims to execute at native speed by taking advantage of common hardware capabilities available on a wide range of platforms.

About safety:

WebAssembly describes a memory-safe, sandboxed execution environment […].

License

The entire project is under the MIT License. Please read the LICENSE file.

Metadata

Release files for wasmer 1.1.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Built distributions (wheels)

Table of built distributions (wheels) for wasmer 1.1.0
File Actions
wasmer-1.1.0-py3-none-any.whl Python 3 none any Details for wasmer-1.1.0-py3-none-any.whl
wasmer-1.1.0-cp310-none-win_amd64.whl CPython 3.10 none Windows x86-64 Details for wasmer-1.1.0-cp310-none-win_amd64.whl
wasmer-1.1.0-cp310-cp310-manylinux_2_24_x86_64.whl CPython 3.10 CPython 3.10 Linux glibc 2.24+ x86-64 Details for wasmer-1.1.0-cp310-cp310-manylinux_2_24_x86_64.whl
wasmer-1.1.0-cp310-cp310-macosx_10_7_x86_64.whl CPython 3.10 CPython 3.10 macOS 10.7+ x86-64 Details for wasmer-1.1.0-cp310-cp310-macosx_10_7_x86_64.whl
wasmer-1.1.0-cp39-none-win_amd64.whl CPython 3.9 none Windows x86-64 Details for wasmer-1.1.0-cp39-none-win_amd64.whl
wasmer-1.1.0-cp39-cp39-manylinux_2_24_x86_64.whl CPython 3.9 CPython 3.9 Linux glibc 2.24+ x86-64 Details for wasmer-1.1.0-cp39-cp39-manylinux_2_24_x86_64.whl
wasmer-1.1.0-cp39-cp39-macosx_11_0_arm64.whl CPython 3.9 CPython 3.9 macOS 11.0+ ARM64 Details for wasmer-1.1.0-cp39-cp39-macosx_11_0_arm64.whl
wasmer-1.1.0-cp39-cp39-macosx_10_7_x86_64.whl CPython 3.9 CPython 3.9 macOS 10.7+ x86-64 Details for wasmer-1.1.0-cp39-cp39-macosx_10_7_x86_64.whl
wasmer-1.1.0-cp38-none-win_amd64.whl CPython 3.8 none Windows x86-64 Details for wasmer-1.1.0-cp38-none-win_amd64.whl
wasmer-1.1.0-cp38-cp38-manylinux_2_24_x86_64.whl CPython 3.8 CPython 3.8 Linux glibc 2.24+ x86-64 Details for wasmer-1.1.0-cp38-cp38-manylinux_2_24_x86_64.whl
wasmer-1.1.0-cp38-cp38-macosx_10_7_x86_64.whl CPython 3.8 CPython 3.8 macOS 10.7+ x86-64 Details for wasmer-1.1.0-cp38-cp38-macosx_10_7_x86_64.whl
wasmer-1.1.0-cp37-none-win_amd64.whl CPython 3.7 none Windows x86-64 Details for wasmer-1.1.0-cp37-none-win_amd64.whl
wasmer-1.1.0-cp37-cp37m-manylinux_2_24_x86_64.whl CPython 3.7 CPython 3.7 pymalloc Linux glibc 2.24+ x86-64 Details for wasmer-1.1.0-cp37-cp37m-manylinux_2_24_x86_64.whl
wasmer-1.1.0-cp37-cp37m-macosx_10_7_x86_64.whl CPython 3.7 CPython 3.7 pymalloc macOS 10.7+ x86-64 Details for wasmer-1.1.0-cp37-cp37m-macosx_10_7_x86_64.whl

Total release size: 19.3 MB

Release files / wasmer-1.1.0-py3-none-any.whl

Download URL wasmer-1.1.0-py3-none-any.whl
Size 1.6 kB
Tags Python 3
SHA-256 checksum
How to use checksums
2caf8c67feae9cd4246421551036917811c446da4f27ad4c989521ef42751931
BLAKE2b-256 checksum
How to use checksums
396b30e25924cae7add377f5601e71c778e9a1e515c7a58291f52756c1bb7e87
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.7.1 importlib_metadata/4.10.0 pkginfo/1.8.2 requests/2.27.1 requests-toolbelt/0.9.1 tqdm/4.62.3 CPython/3.9.9

Release files / wasmer-1.1.0-cp310-none-win_amd64.whl

Download URL wasmer-1.1.0-cp310-none-win_amd64.whl
Size 1.4 MB
Tags CPython 3.10 Windows x86-64
SHA-256 checksum
How to use checksums
d0d93aec6215893d33e803ef0a8d37bf948c585dd80ba0e23a83fafee820bc03
BLAKE2b-256 checksum
How to use checksums
2470ca7bf7a3f85d8de745eca73e40bc83cf86bb52ea494b33721fc0572889ab
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.7.1 importlib_metadata/4.10.0 pkginfo/1.8.2 requests/2.27.1 requests-toolbelt/0.9.1 tqdm/4.62.3 CPython/3.9.9

Release files / wasmer-1.1.0-cp310-cp310-manylinux_2_24_x86_64.whl

Download URL wasmer-1.1.0-cp310-cp310-manylinux_2_24_x86_64.whl
Size 1.6 MB
Tags CPython 3.10 Linux glibc 2.24+ x86-64
SHA-256 checksum
How to use checksums
ab1ae980021e5ec0bf0c6cdd3b979b1d15a5f3eb2b8a32da8dcb1156e4a1e484
BLAKE2b-256 checksum
How to use checksums
a7793f53cf611cbdd04a9b9997bf3ad18e5602350f90d404c162fbf3112684f2
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.7.1 importlib_metadata/4.10.0 pkginfo/1.8.2 requests/2.27.1 requests-toolbelt/0.9.1 tqdm/4.62.3 CPython/3.9.9

Release files / wasmer-1.1.0-cp310-cp310-macosx_10_7_x86_64.whl

Download URL wasmer-1.1.0-cp310-cp310-macosx_10_7_x86_64.whl
Size 1.5 MB
Tags CPython 3.10 macOS 10.7+ x86-64
SHA-256 checksum
How to use checksums
c2af4b907ae2dabcac41e316e811d5937c93adf1f8b05c5d49427f8ce0f37630
BLAKE2b-256 checksum
How to use checksums
cf0a9e5efd92e5cf24d5c08030b4f76dcdf10cbc55c639bbf4df8aeb0c76d448
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.7.1 importlib_metadata/4.10.0 pkginfo/1.8.2 requests/2.27.1 requests-toolbelt/0.9.1 tqdm/4.62.3 CPython/3.9.9

Release files / wasmer-1.1.0-cp39-none-win_amd64.whl

Download URL wasmer-1.1.0-cp39-none-win_amd64.whl
Size 1.4 MB
Tags CPython 3.9 Windows x86-64
SHA-256 checksum
How to use checksums
a0a4730ec4907a4cb0d9d4a77ea2608c2c814f22a22b73fc80be0f110e014836
BLAKE2b-256 checksum
How to use checksums
b032f6978008cdfd7b932a9ae7dc233688f0a4db29b73b59c23d9182731d57a3
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.7.1 importlib_metadata/4.10.0 pkginfo/1.8.2 requests/2.27.1 requests-toolbelt/0.9.1 tqdm/4.62.3 CPython/3.9.9

Release files / wasmer-1.1.0-cp39-cp39-manylinux_2_24_x86_64.whl

Download URL wasmer-1.1.0-cp39-cp39-manylinux_2_24_x86_64.whl
Size 1.6 MB
Tags CPython 3.9 Linux glibc 2.24+ x86-64
SHA-256 checksum
How to use checksums
c0b37117f6d3ff51ee96431c7d224d99799b08d174e30fcd0fcd7e2e3cb8140c
BLAKE2b-256 checksum
How to use checksums
dda66f9cf77500073969c96afd626857694418d707cc97c15705665250420c67
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.7.1 importlib_metadata/4.10.0 pkginfo/1.8.2 requests/2.27.1 requests-toolbelt/0.9.1 tqdm/4.62.3 CPython/3.9.9

Release files / wasmer-1.1.0-cp39-cp39-macosx_11_0_arm64.whl

Download URL wasmer-1.1.0-cp39-cp39-macosx_11_0_arm64.whl
Size 1.3 MB
Tags CPython 3.9 macOS 11.0+ ARM64
SHA-256 checksum
How to use checksums
aa112198b743cff2e391230436813fb4b244a24443e37866522b7197e3a034da
BLAKE2b-256 checksum
How to use checksums
f7d1502e40f1c63c8ddcfc9c5dee41af1c109c0cc0373e176c476cf46c205b21
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.7.1 importlib_metadata/4.8.2 pkginfo/1.8.2 requests/2.26.0 requests-toolbelt/0.9.1 tqdm/4.62.3 CPython/3.9.9

Release files / wasmer-1.1.0-cp39-cp39-macosx_10_7_x86_64.whl

Download URL wasmer-1.1.0-cp39-cp39-macosx_10_7_x86_64.whl
Size 1.5 MB
Tags CPython 3.9 macOS 10.7+ x86-64
SHA-256 checksum
How to use checksums
ee442f0970f40ec5e32011c92fd753fb2061da0faa13de13fafc730c31be34e3
BLAKE2b-256 checksum
How to use checksums
1242142b95b68e3cb9f1b49174677e1861575a47fdac0221f46d9a8631d2b469
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.7.1 importlib_metadata/4.10.0 pkginfo/1.8.2 requests/2.27.1 requests-toolbelt/0.9.1 tqdm/4.62.3 CPython/3.9.9

Release files / wasmer-1.1.0-cp38-none-win_amd64.whl

Download URL wasmer-1.1.0-cp38-none-win_amd64.whl
Size 1.4 MB
Tags CPython 3.8 Windows x86-64
SHA-256 checksum
How to use checksums
20b5190112e2e94a8947967f2bc683c9685855d0f34130d8434c87a55216a3bd
BLAKE2b-256 checksum
How to use checksums
7fd71d346733b1c32dc6a95053e09baa9979322dc09fd5273b3db328c547f059
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.7.1 importlib_metadata/4.10.0 pkginfo/1.8.2 requests/2.27.1 requests-toolbelt/0.9.1 tqdm/4.62.3 CPython/3.9.9

Release files / wasmer-1.1.0-cp38-cp38-manylinux_2_24_x86_64.whl

Download URL wasmer-1.1.0-cp38-cp38-manylinux_2_24_x86_64.whl
Size 1.6 MB
Tags CPython 3.8 Linux glibc 2.24+ x86-64
SHA-256 checksum
How to use checksums
b9e5605552bd7d2bc6337519b176defe83bc69b98abf3caaaefa4f7ec231d18a
BLAKE2b-256 checksum
How to use checksums
93f597ecad043c138f48c37ce4f0fa782831b5d2dbb3f7d80031f07105b9e7ba
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.7.1 importlib_metadata/4.10.0 pkginfo/1.8.2 requests/2.27.1 requests-toolbelt/0.9.1 tqdm/4.62.3 CPython/3.9.9

Release files / wasmer-1.1.0-cp38-cp38-macosx_10_7_x86_64.whl

Download URL wasmer-1.1.0-cp38-cp38-macosx_10_7_x86_64.whl
Size 1.5 MB
Tags CPython 3.8 macOS 10.7+ x86-64
SHA-256 checksum
How to use checksums
214d9a3cfb577ea9449eb2b5f13adceae34c55365e4c3d930066beb86a7f67bc
BLAKE2b-256 checksum
How to use checksums
a177e8f9b4e32fcdf2d54dfab67e26cc7557a094e85817281e8f203294d4ea52
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.7.1 importlib_metadata/4.10.0 pkginfo/1.8.2 requests/2.27.1 requests-toolbelt/0.9.1 tqdm/4.62.3 CPython/3.9.9

Release files / wasmer-1.1.0-cp37-none-win_amd64.whl

Download URL wasmer-1.1.0-cp37-none-win_amd64.whl
Size 1.4 MB
Tags CPython 3.7 Windows x86-64
SHA-256 checksum
How to use checksums
a182a6eca9b46d895b4985fc822fab8da3d2f84fab74ca27e55a7430a7fcf336
BLAKE2b-256 checksum
How to use checksums
d6389f92d6a54aa11fcb74e3dd1a790a2ed531ff267ed3d2e256480ad00ce26b
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.7.1 importlib_metadata/4.10.0 pkginfo/1.8.2 requests/2.27.1 requests-toolbelt/0.9.1 tqdm/4.62.3 CPython/3.9.9

Release files / wasmer-1.1.0-cp37-cp37m-manylinux_2_24_x86_64.whl

Download URL wasmer-1.1.0-cp37-cp37m-manylinux_2_24_x86_64.whl
Size 1.6 MB
Tags CPython 3.7 CPython 3.7 pymalloc Linux glibc 2.24+ x86-64
SHA-256 checksum
How to use checksums
85e6a5bf44853e8e6a12e947ee3412da9e84f7ce49fc165ba5dbd293e9c5c405
BLAKE2b-256 checksum
How to use checksums
5c7f9b96442cc3984baa7a5e5651901202176cb30fe879fef0c4f79020566262
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.7.1 importlib_metadata/4.10.0 pkginfo/1.8.2 requests/2.27.1 requests-toolbelt/0.9.1 tqdm/4.62.3 CPython/3.9.9

Release files / wasmer-1.1.0-cp37-cp37m-macosx_10_7_x86_64.whl

Download URL wasmer-1.1.0-cp37-cp37m-macosx_10_7_x86_64.whl
Size 1.5 MB
Tags CPython 3.7 CPython 3.7 pymalloc macOS 10.7+ x86-64
SHA-256 checksum
How to use checksums
1e63d16bd6e2e2272d8721647831de5c537e0bb08002ee6d7abf167ec02d5178
BLAKE2b-256 checksum
How to use checksums
7121091c53b34e312bea376cb4a5806834f84e674e7f78d52eb92423cedf8a5f
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.7.1 importlib_metadata/4.10.0 pkginfo/1.8.2 requests/2.27.1 requests-toolbelt/0.9.1 tqdm/4.62.3 CPython/3.9.9

Security for wasmer 1.1.0

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page