A Python interpreter in Rust, built for running untrusted Python.
minipython implements the Python syntax frontend, core runtime semantics and a small in-memory standard library, aiming at CPython 3.14.6 behaviour rather than replacing CPython. It ships one binary, mnpy, a Rust library and a Python client package, and every entry point runs code in a separate worker process with time, memory, instruction, output and allocation limits.
Install
- From source
cargo build --release
What it does
- A worker-process sandbox with limits on by default: time, memory, instructions, output and allocations.
- Imports limited to a fixed allowlist such as json, math, collections, itertools and argparse.
- The host is reachable only through external functions you register by name, from Rust or Python.
What it leaves out on purpose
- No real open(), input(), sockets, subprocesses or C extensions. Anything outside the allowlist fails with ModuleNotFoundError.
- A behaviour counts as supported only when a differential test against CPython 3.14.6 backs it.
cat agent_code.py import json from collections import Counter orders = [{"item": "tea", "qty": 2}, {"item": "cake", "qty": 1}, {"item": "tea", "qty": 3}] totals = Counter() for o in orders: totals[o["item"]] += o["qty"] print(json.dumps(dict(totals))) mnpy agent_code.py {"tea": 5, "cake": 1} mnpy blocked.py builtin open blocked builtin input blocked module os blocked module socket blocked module subprocess blocked module _ctypes blocked cat loop.py def spin(): while True: pass spin() mnpy loop.py sandbox error: instruction limit exceeded