Skip to main content
File added late

1 file was added to this release more than 14 days after its initial publication. Inspect the release files before installing.

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.0.0
$ pip install wasmer_compiler_cranelift==1.0.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 excecute 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.6,
  • Python 3.7,
  • Python 3.8.
  • Python 3.9.
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.0.0

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

File added late

1 file was uploaded more than 14 days after the first file in this release.

While project maintainers occasionally add legitimate files to an existing release, late additions can also indicate a security compromise.

We recommend inspecting the release files before installing.

Built distributions (wheels)

Table of built distributions (wheels) for wasmer 1.0.0
File
wasmer-1.0.0-py3-none-any.whl Python 3 none any Details
wasmer-1.0.0-cp39-none-win_amd64.whl CPython 3.9 none Windows x86-64 Details
wasmer-1.0.0-cp39-cp39-manylinux2010_x86_64.whl CPython 3.9 CPython 3.9 Linux glibc 2.12+ x86-64 Details
wasmer-1.0.0-cp39-cp39-macosx_11_0_arm64.whl CPython 3.9 CPython 3.9 macOS 11.0+ ARM64 Details
wasmer-1.0.0-cp39-cp39-macosx_10_7_x86_64.whl CPython 3.9 CPython 3.9 macOS 10.7+ x86-64 Details
wasmer-1.0.0-cp38-none-win_amd64.whl CPython 3.8 none Windows x86-64 Details
wasmer-1.0.0-cp38-cp38-manylinux2010_x86_64.whl CPython 3.8 CPython 3.8 Linux glibc 2.12+ x86-64 Details
wasmer-1.0.0-cp38-cp38-macosx_10_7_x86_64.whl CPython 3.8 CPython 3.8 macOS 10.7+ x86-64 Details
wasmer-1.0.0-cp37-none-win_amd64.whl CPython 3.7 none Windows x86-64 Details
wasmer-1.0.0-cp37-cp37m-manylinux2010_x86_64.whl CPython 3.7 CPython 3.7 pymalloc Linux glibc 2.12+ x86-64 Details
wasmer-1.0.0-cp37-cp37m-macosx_10_7_x86_64.whl CPython 3.7 CPython 3.7 pymalloc macOS 10.7+ x86-64 Details
wasmer-1.0.0-cp36-none-win_amd64.whl CPython 3.6 none Windows x86-64 Details
wasmer-1.0.0-cp36-cp36m-manylinux2010_x86_64.whl CPython 3.6 CPython 3.6 pymalloc Linux glibc 2.12+ x86-64 Details
wasmer-1.0.0-cp36-cp36m-macosx_10_7_x86_64.whl CPython 3.6 CPython 3.6 pymalloc macOS 10.7+ x86-64 Details

Total release size: 18.8 MB

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

Download URL wasmer-1.0.0-py3-none-any.whl
Size 5.0 kB
Tags Python 3
SHA-256 checksum
How to use checksums
427e9c5e5301a453a09b8b9ceb8c793d85411b8f45e54c9c0d801566dd8d214e
BLAKE2b-256 checksum
How to use checksums
53cc41a6e63f290c94657475c18fb89ce1f279a77055d8e83793c00977a324d2
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.3.0 pkginfo/1.7.0 requests/2.25.1 setuptools/51.1.2 requests-toolbelt/0.9.1 tqdm/4.56.0 CPython/3.9.1

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

Download URL wasmer-1.0.0-cp39-none-win_amd64.whl
Size 1.4 MB
Tags CPython 3.9 Windows x86-64
SHA-256 checksum
How to use checksums
690c5ed46a98e91bc638f52a25e5011c5baa1ef0581f414018eb7aa0e7f844bc
BLAKE2b-256 checksum
How to use checksums
a064fef2b9d3b2ed13ca60f8e321762ad5e19baee0628394292c2296a7a67325
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.3.0 pkginfo/1.7.0 requests/2.25.1 setuptools/51.1.2 requests-toolbelt/0.9.1 tqdm/4.56.0 CPython/3.9.1

Release files / wasmer-1.0.0-cp39-cp39-manylinux2010_x86_64.whl

Download URL wasmer-1.0.0-cp39-cp39-manylinux2010_x86_64.whl
Size 1.6 MB
Tags CPython 3.9 Linux glibc 2.12+ x86-64
SHA-256 checksum
How to use checksums
04e5d51eed336be0e1bf1445aa032fc34466b77220c26732b8990df872f29e92
BLAKE2b-256 checksum
How to use checksums
af81dac18dda0e178a476f180d79cc5a65e5af1d221114a4dca196b027d2d14b
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.3.0 pkginfo/1.7.0 requests/2.25.1 setuptools/51.1.2 requests-toolbelt/0.9.1 tqdm/4.56.0 CPython/3.9.1

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

File added late

This file was uploaded more than 14 days after the first file in this release.

While project maintainers occasionally add legitimate files to an existing release, late additions can also indicate a security compromise.

We recommend inspecting the release file before installing.

Download URL wasmer-1.0.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
f390a54e26775456602f21d5d7d62dbad487f6a1022cab4379d7eac2c812d7ce
BLAKE2b-256 checksum
How to use checksums
50a86ca78e64ca6874577f9ad28bef63f2ab0d63ae6251144f54498cfe703284
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.4.1 importlib_metadata/4.0.1 pkginfo/1.7.0 requests/2.25.1 requests-toolbelt/0.9.1 tqdm/4.60.0 CPython/3.9.2

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

Download URL wasmer-1.0.0-cp39-cp39-macosx_10_7_x86_64.whl
Size 1.4 MB
Tags CPython 3.9 macOS 10.7+ x86-64
SHA-256 checksum
How to use checksums
1fada13fb536f44e12d7c98c557f5b7a55df94389d3cb90964193dcc8e16f0fa
BLAKE2b-256 checksum
How to use checksums
b94c388fc6fa2237182104fbf474359809b8a107b7ad7a0c0fcc591a55a3d023
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.3.0 pkginfo/1.7.0 requests/2.25.1 setuptools/51.1.2 requests-toolbelt/0.9.1 tqdm/4.56.0 CPython/3.9.1

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

Download URL wasmer-1.0.0-cp38-none-win_amd64.whl
Size 1.4 MB
Tags CPython 3.8 Windows x86-64
SHA-256 checksum
How to use checksums
8b13214b5dcc84d43f4c44e2309442497f19137561afada7f34babad89365355
BLAKE2b-256 checksum
How to use checksums
525b274138e3588ea7703cf0e323ebddde619a44110423700727c453916bd6c6
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.3.0 pkginfo/1.7.0 requests/2.25.1 setuptools/51.1.2 requests-toolbelt/0.9.1 tqdm/4.56.0 CPython/3.9.1

Release files / wasmer-1.0.0-cp38-cp38-manylinux2010_x86_64.whl

Download URL wasmer-1.0.0-cp38-cp38-manylinux2010_x86_64.whl
Size 1.6 MB
Tags CPython 3.8 Linux glibc 2.12+ x86-64
SHA-256 checksum
How to use checksums
a08be93aff695ce3be871994f726716b68bef36bd583bccad75778359cd273df
BLAKE2b-256 checksum
How to use checksums
c64a68fc07e7f37f25a3dbd783a92c9da877f85c1a61a86550cf6c286969d956
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.3.0 pkginfo/1.7.0 requests/2.25.1 setuptools/51.1.2 requests-toolbelt/0.9.1 tqdm/4.56.0 CPython/3.9.1

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

Download URL wasmer-1.0.0-cp38-cp38-macosx_10_7_x86_64.whl
Size 1.4 MB
Tags CPython 3.8 macOS 10.7+ x86-64
SHA-256 checksum
How to use checksums
11e73026cb7e9a948b86324bd573cafe4d7be91f65ff45b1dc67485044348754
BLAKE2b-256 checksum
How to use checksums
7151f133ada281f50e00661a8fabc6d02a8b2dbd558c16b6d171c38e3b22540e
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.3.0 pkginfo/1.7.0 requests/2.25.1 setuptools/51.1.2 requests-toolbelt/0.9.1 tqdm/4.56.0 CPython/3.9.1

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

Download URL wasmer-1.0.0-cp37-none-win_amd64.whl
Size 1.4 MB
Tags CPython 3.7 Windows x86-64
SHA-256 checksum
How to use checksums
15b355fed4ebe9d912a7fe236391aac591cc64c7647e14e517c2a6f451a83914
BLAKE2b-256 checksum
How to use checksums
e0fd917d49cc32c25946d8127a3cd2d04638ff706c3c14c5747b9267e9c87c18
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.3.0 pkginfo/1.7.0 requests/2.25.1 setuptools/51.1.2 requests-toolbelt/0.9.1 tqdm/4.56.0 CPython/3.9.1

Release files / wasmer-1.0.0-cp37-cp37m-manylinux2010_x86_64.whl

Download URL wasmer-1.0.0-cp37-cp37m-manylinux2010_x86_64.whl
Size 1.6 MB
Tags CPython 3.7 CPython 3.7 pymalloc Linux glibc 2.12+ x86-64
SHA-256 checksum
How to use checksums
dd6c5ab2c41e9fd31442483ac7adc81d886cc3242d604dc3c895df257aa7dbe2
BLAKE2b-256 checksum
How to use checksums
1c9eb653d0252402565783a501fa67479554537d0c5c537ec00b3a4f31f68bce
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.3.0 pkginfo/1.7.0 requests/2.25.1 setuptools/51.1.2 requests-toolbelt/0.9.1 tqdm/4.56.0 CPython/3.9.1

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

Download URL wasmer-1.0.0-cp37-cp37m-macosx_10_7_x86_64.whl
Size 1.4 MB
Tags CPython 3.7 CPython 3.7 pymalloc macOS 10.7+ x86-64
SHA-256 checksum
How to use checksums
e2ecd788140468d2d489fc92537b47e2baf4ffdec00fe41f055715d261e4988b
BLAKE2b-256 checksum
How to use checksums
7e4c7f09d2876d3093a2b9c352d0bf362130e8a2ca24795fec354a8fe6e0230c
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.3.0 pkginfo/1.7.0 requests/2.25.1 setuptools/51.1.2 requests-toolbelt/0.9.1 tqdm/4.56.0 CPython/3.9.1

Release files / wasmer-1.0.0-cp36-none-win_amd64.whl

Download URL wasmer-1.0.0-cp36-none-win_amd64.whl
Size 1.4 MB
Tags CPython 3.6 Windows x86-64
SHA-256 checksum
How to use checksums
d77b169079183c131d398c57dfc36e5cc4b34ae2543878ac2056e858f040c099
BLAKE2b-256 checksum
How to use checksums
681f9208f245d7ebad6db3b60139fe0fbf3e3a727c1a9a49ec52b0633f2befab
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.3.0 pkginfo/1.7.0 requests/2.25.1 setuptools/51.1.2 requests-toolbelt/0.9.1 tqdm/4.56.0 CPython/3.9.1

Release files / wasmer-1.0.0-cp36-cp36m-manylinux2010_x86_64.whl

Download URL wasmer-1.0.0-cp36-cp36m-manylinux2010_x86_64.whl
Size 1.6 MB
Tags CPython 3.6 CPython 3.6 pymalloc Linux glibc 2.12+ x86-64
SHA-256 checksum
How to use checksums
6b41046db73facc064cb9649627d9cdd1b88ada74e745134e44e09ada6827056
BLAKE2b-256 checksum
How to use checksums
82c2acd4e837879745460e816e774d77d1d961b4f21c8e2ef081b9ba4490f211
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.3.0 pkginfo/1.7.0 requests/2.25.1 setuptools/51.1.2 requests-toolbelt/0.9.1 tqdm/4.56.0 CPython/3.9.1

Release files / wasmer-1.0.0-cp36-cp36m-macosx_10_7_x86_64.whl

Download URL wasmer-1.0.0-cp36-cp36m-macosx_10_7_x86_64.whl
Size 1.4 MB
Tags CPython 3.6 CPython 3.6 pymalloc macOS 10.7+ x86-64
SHA-256 checksum
How to use checksums
0d755a93184380f9785e1f8269b070f4a4a3285ae0f7f9571cfaf2ea215b102d
BLAKE2b-256 checksum
How to use checksums
b20017cf9a7c3df396e45b926db64cc4fcbf5b4e8ccff1bc7a52b36f264e4148
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.3.0 pkginfo/1.7.0 requests/2.25.1 setuptools/51.1.2 requests-toolbelt/0.9.1 tqdm/4.56.0 CPython/3.9.1

Release history Release notifications | RSS feed

This release

1.0.0 This release

14 release files

0.4.1

7 release files

0.3.0

7 release files

0.2.0

6 release files

0.1.5

6 release files

0.1.4

6 release files

0.1.3

1 release file

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