Favicon of RustPython

RustPython

RustPython is a Python 3 interpreter built in Rust, usable as a standalone binary, embedded in Rust apps, or compiled to WebAssembly.

RustPython website screenshot
RustPython GitHub repository preview

RustPython is a Python 3 interpreter implemented entirely in Rust, without CPython bindings. It's aimed at Rust developers who want to embed Python scripting into their applications, run Python in the browser via WebAssembly, or explore how a Python implementation looks in Rust. It's not a drop-in CPython replacement for production workloads; the project itself says it's not fully production-ready yet.

Key features

  • Pure Rust implementation: no bindings to CPython, so the whole interpreter compiles as a Rust crate.
  • WASM support: runs in the browser (there's a live online demo) and compiles to a standalone WASI module that runs in any WASI-compatible runtime.
  • Rust embedding: exposes an API for embedding Python scripting inside Rust applications, with example code (hello_embed.rs, mini_repl.rs) included in the repo.
  • Experimental JIT: an opt-in JIT feature compiles individual Python functions to native code via a __jit__() call on function objects.
  • pip and venv support: rustpython -m venv creates a virtual environment, and --install-pip sets up pip when the ssl feature is enabled, so you can install packages from PyPI.
  • Configurable SSL backend: supports rustls (default) or OpenSSL, useful when you need to match your deployment's crypto stack.
  • Interactive REPL: run cargo run --release (or the installed rustpython binary) for a Python shell, or pass -c to run one-liners.

Ideal use cases

RustPython fits well when you need to add a Python scripting layer to a Rust application without shelling out to a system Python or linking against CPython's C API. Projects like time-series databases and game engines have used it this way, embedding Python for user-defined logic. It also works for running Python logic inside WebAssembly, in the browser or in WASI runtimes, where a native CPython binary isn't an option.

It's a reasonable choice for experimenting with Rust and Python interoperability, for testing how Python code behaves in a sandboxed WASM context, or for tools (like linters) that need to parse or interpret Python without a system Python dependency.

It's not the right fit if you need full CPython compatibility, access to the entire CPython C extension ecosystem, or a production-grade interpreter with guaranteed performance parity. Packaging is also still rough: there's no polished installer, and pip support depends on optional SSL features that require extra system dependencies. If your project depends heavily on C-extension-based packages (numpy-heavy pipelines, for instance), check compatibility carefully before committing.

Installation

You need the latest stable Rust toolchain. Install it via rustup.rs if you don't have it, and check your version with rustc --version.

Clone and run directly:

git clone https://github.com/RustPython/RustPython
cd RustPython
cargo run --release -- -c 'print("Hello, RustPython!")'

Or drop into the interactive shell:

cargo run --release

On Windows, set git config core.symlinks true before cloning (the Lib/ directory uses symlinks), and set the RUSTPYTHONPATH environment variable to the Lib path in the project directory.

To install it as a standalone binary:

cargo install --git https://github.com/RustPython/RustPython rustpython
rustpython

For pip support, enable the ssl feature when installing, then run:

cargo install --git https://github.com/RustPython/RustPython
rustpython --install-pip

For WebAssembly (WASI), add the target and build with the freeze-stdlib feature:

rustup target add wasm32-wasip1
cargo build --release --target wasm32-wasip1 --features="freeze-stdlib"

The experimental JIT compiler requires the jit cargo feature plus autoconf, automake, libtool, and clang installed on your system:

cargo run --features jit
Categories:

Frequently asked questions

Share:

Stars
22.4K
Forks
1.5K
Last commit
13 hours ago
Repository age
8 years
License
MIT
Self-hosted
No
Activity score
82/100
View Repository
Ad
Favicon

 

  
 

Similar to RustPython

Favicon

 

  
 
Favicon

 

  
 
Favicon