PyBevy: A Python Real-Time Engine Built on Bevy
Project description
PyBevy: A Python Real-Time Engine Built on Bevy
$ pip install pybevy
Beta. Python 3.12+. API evolving — breaking changes expected. Independently developed, community-maintained. Not affiliated with the Bevy project.
pybevy.com — Project website & documentation
Write Python, save the file, and see your 3D scene update. Use NumPy, JAX, and PyTorch in the same process as a real 3D renderer. And when you want it, the AI can join the loop — it writes code, sees the result, and iterates.
- Fast hot reload — edit code, see changes near instantly, no restart, no recompile
- Built on Bevy's renderer and ECS — PBR, volumetric fog, cascaded shadows, bloom, SSAO
- Python ecosystem in-process — NumPy, JAX, PyTorch, Numba — just import
- Optional AI feedback loop — the AI writes Python, reloads, inspects the running scene, and iterates
- If you know Bevy's Rust API, PyBevy should feel immediately familiar
Getting Started
Installation
Pre-compiled wheels are available for the following platforms:
| Platform | Architecture |
|---|---|
| Linux | x86_64 |
| macOS | ARM (Apple Silicon), x86_64 |
| Windows | x86_64 |
Browser sandbox is in development — follow #12 for progress.
pip install pybevy --upgrade
Free-Threaded Python (3.13t+)
PyBevy supports Python's free-threaded mode (PEP 703). Non-conflicting Python systems run truly in parallel on separate cores via Bevy's multi-threaded scheduler — no GIL serialization. Validated on CPython 3.14t. Performance depends on workload and scene complexity; see Benchmarks for methodology and numbers.
Note: The Numba JIT path (View API Tier 3) is not yet available on free-threaded Python —
llvmlitedoes not ship 3.14t wheels yet. Tracked in #8.
Quick Example
Parent-child entity hierarchy with a rotating parent cube. The child cube inherits the parent's transform automatically.
from pybevy.decorators import component, entrypoint
from pybevy.prelude import *
@component
class Rotator(Component):
"""Marks entities that should rotate."""
def rotator_system(
time: Res[Time],
query: Query[Mut[Transform], With[Rotator]]
) -> None:
for transform in query:
transform.rotate_x(3.0 * time.delta_secs())
def setup(
commands: Commands,
meshes: ResMut[Assets[Mesh]],
materials: ResMut[Assets[StandardMaterial]],
) -> None:
cube_handle = meshes.add(Cuboid(2.0, 2.0, 2.0))
cube_material = materials.add(StandardMaterial(
base_color=Color.srgb(0.8, 0.7, 0.6)
))
# Parent cube — rotates
parent = commands.spawn(
Mesh3d(cube_handle),
MeshMaterial3d(cube_material),
Transform.from_xyz(0.0, 0.0, 1.0),
Rotator(),
)
# Child cube — follows the parent
parent.with_children(
lambda child: [
child.spawn(
Mesh3d(cube_handle),
MeshMaterial3d(cube_material),
Transform.from_xyz(0.0, 0.0, 3.0),
)
]
)
commands.spawn(PointLight(), Transform.from_xyz(4.0, 5.0, -4.0))
commands.spawn(
Camera3d(),
Transform.from_xyz(5.0, 10.0, 10.0).looking_at(Vec3.ZERO, Vec3.Y),
)
@entrypoint
def main(app: App) -> App:
return (
app.add_plugins(DefaultPlugins)
.add_systems(Startup, setup)
.add_systems(Update, rotator_system)
)
if __name__ == "__main__":
main().run()
Save this as main.py and run with hot reload:
pybevy watch --full main.py
Edit the code — the engine hot reloads near instantly, no restart, no recompile.
The --full flag reloads everything on each change, including setup systems. Without it, only Update systems are reloaded — faster for iterating on runtime behavior once your scene is set up.
Native Plugin Approach (Rust + Python)
If you already have a Rust Bevy application, you can embed Python systems into it with PyBevyPlugin. Prototype in Python, ship critical paths in Rust.
Security:
PyBevyPluginembeds a full CPython interpreter with unrestricted host access. Never execute untrusted Python code. We advise against using this for user-submitted plugin/modding systems without external sandboxing.
// main.rs - Your existing Rust Bevy application
use bevy::prelude::*;
use pybevy::PyBevyPlugin;
fn main() {
App::new()
.add_plugins(DefaultPlugins)
// Add Python systems from a module
.add_plugins(
PyBevyPlugin::new("game_logic")
.with_startup_system("setup")
.with_update_system("ai_behavior")
.with_hot_reload() // Edit Python, press F5 to reload!
)
// Mix with native Rust systems
.add_systems(Update, physics_step)
.run();
}
# game_logic.py
from pybevy.prelude import *
ROTATION_SPEED = 1.0 # Change this and press F5!
def setup(commands: Commands) -> None:
commands.spawn(Transform.from_xyz(0.0, 0.0, 0.0))
def ai_behavior(query: Query[Mut[Transform]], time: Res[Time]) -> None:
for transform in query:
transform.rotation *= Quat.from_rotation_y(time.delta_secs() * ROTATION_SPEED)
See docs/native-plugin.md for the full guide, including #[derive(PyComponent)] for exposing Rust components to Python and hot reload details.
AI Feedback Loop
PyBevy includes a built-in MCP server that lets AI agents write Python, reload the scene, capture screenshots, inspect entities, and iterate — automatically. The AI sees what it builds.
claude mcp add pybevy -- pybevy mcp # Claude Code
codex mcp add pybevy -- pybevy mcp # Codex
gemini mcp add pybevy -- pybevy mcp # Gemini CLI
Also works with Cursor and other MCP-compatible editors. See docs/mcp.md for full setup.
Bevy Compatibility
PyBevy versions target specific Bevy versions:
| pybevy | Bevy |
|---|---|
| 0.2.x | 0.18 |
| 0.1.x | 0.18 |
PyBevy follows Bevy's API conventions as closely as possible and targets full coverage of Bevy's public API. Core modules like transforms, lighting, cameras, and input are fully covered; others are in progress. See API Coverage for current per-module stats and Limitations for known constraints.
Limitations
- No built-in physics — use NumPy or JAX for physics computation, PyBevy for visualization.
- Desktop only — Linux, macOS, Windows. No mobile.
- Code only — no visual editor.
- API is evolving — see Limitations for known constraints.
Documentation
- pybevy.com — Project website
- Examples — Runnable examples covering 2D, 3D, ECS, animation, and more
- API Coverage — Per-module Bevy API coverage stats
- Limitations — Known limitations
Community & Contributing
- Discord: Pybevy Discord — questions, discussion, showcases
- Contributing: See CONTRIBUTING.md
License
All code in this repository is dual-licensed under either:
at your option.
By contributing, you agree your work will be released under both licenses.
When you want it, the world runs itself.
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distributions
Built Distributions
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file pybevy-0.2.0-cp314-cp314-win_amd64.whl.
File metadata
- Download URL: pybevy-0.2.0-cp314-cp314-win_amd64.whl
- Upload date:
- Size: 29.8 MB
- Tags: CPython 3.14, Windows x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.12.3
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
cced8e8b00418739176b15ea2a0361cd4f3a7c1f0b2483052928eded8ba5034e
|
|
| MD5 |
49b5acaba216807cc129c1b4d3d88cfc
|
|
| BLAKE2b-256 |
e8d3e945ab8dcbb505ecadcfc94ec6d62e57d93366b60a76c63eb7ce2e6ad78f
|
File details
Details for the file pybevy-0.2.0-cp314-cp314-manylinux_2_28_x86_64.whl.
File metadata
- Download URL: pybevy-0.2.0-cp314-cp314-manylinux_2_28_x86_64.whl
- Upload date:
- Size: 29.2 MB
- Tags: CPython 3.14, manylinux: glibc 2.28+ x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.12.3
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
03a64a01a1ea758d60b12575d638550fffc34f17e08e6d001d44120835886543
|
|
| MD5 |
2207e0e84632027db5d8a53009ad998b
|
|
| BLAKE2b-256 |
016d19075959d2f5a1cf1ec77d4d3a04cbedf975b24b727bb4f2dc496090de00
|
File details
Details for the file pybevy-0.2.0-cp314-cp314-macosx_11_0_arm64.whl.
File metadata
- Download URL: pybevy-0.2.0-cp314-cp314-macosx_11_0_arm64.whl
- Upload date:
- Size: 26.6 MB
- Tags: CPython 3.14, macOS 11.0+ ARM64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.12.3
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
41690cbf061cd846b6d75e2415d61fbe9e0e2d75cd0e38ff072625d4ecb1d25f
|
|
| MD5 |
3a4d9266e4056687621f9158dba7efa3
|
|
| BLAKE2b-256 |
43152b4ca2ae926a9616fe06f194a495e615c102daed776f1c90e4d9dce4ad95
|
File details
Details for the file pybevy-0.2.0-cp314-cp314-macosx_10_12_x86_64.whl.
File metadata
- Download URL: pybevy-0.2.0-cp314-cp314-macosx_10_12_x86_64.whl
- Upload date:
- Size: 27.7 MB
- Tags: CPython 3.14, macOS 10.12+ x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.12.3
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
68b1368e221e2d7d19a2148b1917545a867374b29f02cdfd3a1e42749d2c16c2
|
|
| MD5 |
9302c4f14c5b493e5f3b7871cc90a645
|
|
| BLAKE2b-256 |
35de5e409c64461a8bd8473882e6703da4f3fffc0ab3701dd06c9bc94f2221b5
|
File details
Details for the file pybevy-0.2.0-cp313-cp313-win_amd64.whl.
File metadata
- Download URL: pybevy-0.2.0-cp313-cp313-win_amd64.whl
- Upload date:
- Size: 29.6 MB
- Tags: CPython 3.13, Windows x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.12.3
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
4444e0d508f6201f20ec4769bf0b4e05abe33853281e252297f15665137dfc20
|
|
| MD5 |
342319c69d245faac0478fde15fbe483
|
|
| BLAKE2b-256 |
c80f76a16263eadca0c1241aabdf1d25fe69287c4c682996f9439614b0c2bec3
|
File details
Details for the file pybevy-0.2.0-cp313-cp313-manylinux_2_28_x86_64.whl.
File metadata
- Download URL: pybevy-0.2.0-cp313-cp313-manylinux_2_28_x86_64.whl
- Upload date:
- Size: 29.1 MB
- Tags: CPython 3.13, manylinux: glibc 2.28+ x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.12.3
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
4cdf02df7b1a4c721787cc7244dc05ead44bec60bf10adbac1a4d2ff935159ad
|
|
| MD5 |
49357d757a14dec92a1d1bef0b9cd9c1
|
|
| BLAKE2b-256 |
ffc06419c63f15ac566249d9d1dbcfca870a18f85b4e2b0e6b60af55ccc070df
|
File details
Details for the file pybevy-0.2.0-cp313-cp313-macosx_11_0_arm64.whl.
File metadata
- Download URL: pybevy-0.2.0-cp313-cp313-macosx_11_0_arm64.whl
- Upload date:
- Size: 26.4 MB
- Tags: CPython 3.13, macOS 11.0+ ARM64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.12.3
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
32736f4e2ee0a9ca93b285bd6872c9c7c63de1f8425c8d9ade49ab8bd86bdad3
|
|
| MD5 |
2dba7b80d3197c8b08030a3b15d41c01
|
|
| BLAKE2b-256 |
ab9053307ba59a98f0a787535ac50c10982e2e62720b02bb0ebe4e56c71e9944
|
File details
Details for the file pybevy-0.2.0-cp313-cp313-macosx_10_12_x86_64.whl.
File metadata
- Download URL: pybevy-0.2.0-cp313-cp313-macosx_10_12_x86_64.whl
- Upload date:
- Size: 27.6 MB
- Tags: CPython 3.13, macOS 10.12+ x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.12.3
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
e44671d44ba1d04227f2f4ea0fb14c2e0fb3bcce3891fe02b0b12a93ffb681a9
|
|
| MD5 |
688fb9464343297abab48e0415c66ea7
|
|
| BLAKE2b-256 |
f0acbc9ee52a3535b943c95a50c60f7f9b4f68a43ebed19189a86d0afda9f186
|
File details
Details for the file pybevy-0.2.0-cp312-cp312-win_amd64.whl.
File metadata
- Download URL: pybevy-0.2.0-cp312-cp312-win_amd64.whl
- Upload date:
- Size: 29.6 MB
- Tags: CPython 3.12, Windows x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.12.3
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
0c2ba6b2f9390670d24b1b4ff8322967d7fe5f1b19c1a124948f3f3e97702a54
|
|
| MD5 |
a41d652b7903606411223c8ef99ec6b8
|
|
| BLAKE2b-256 |
cb6655907917d41f70249e36f2583952f6c4d4076557190e43b2445f3f5fb46c
|
File details
Details for the file pybevy-0.2.0-cp312-cp312-manylinux_2_28_x86_64.whl.
File metadata
- Download URL: pybevy-0.2.0-cp312-cp312-manylinux_2_28_x86_64.whl
- Upload date:
- Size: 29.1 MB
- Tags: CPython 3.12, manylinux: glibc 2.28+ x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.12.3
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
a81c0e538f5f27b697b986fbc8c1d10003ff4a4dd5f81e60c0f9f5c4db9986e3
|
|
| MD5 |
ff4b84a80c7820a816b2b9cfcb1a31b1
|
|
| BLAKE2b-256 |
396a2f818c18bf134c0928afdde52e6c60cf7ebd3719af0230674462825cba90
|
File details
Details for the file pybevy-0.2.0-cp312-cp312-macosx_11_0_arm64.whl.
File metadata
- Download URL: pybevy-0.2.0-cp312-cp312-macosx_11_0_arm64.whl
- Upload date:
- Size: 26.4 MB
- Tags: CPython 3.12, macOS 11.0+ ARM64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.12.3
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
ce1fc314b3ef1e2a2d998d52bb4c390c6f3f4d7436c4b9df8475c409521eac2e
|
|
| MD5 |
45f99e0c2e3b0cd17c4d7bfb7717bb11
|
|
| BLAKE2b-256 |
67ba1961bdd2d9f2ae82dcae29c48120e4c9e7356681511809384e286bef8f58
|
File details
Details for the file pybevy-0.2.0-cp312-cp312-macosx_10_12_x86_64.whl.
File metadata
- Download URL: pybevy-0.2.0-cp312-cp312-macosx_10_12_x86_64.whl
- Upload date:
- Size: 27.6 MB
- Tags: CPython 3.12, macOS 10.12+ x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.12.3
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
755de83cbaa49993f0d95add9e538cc1f4950c46b7dcdd26891dc1ef15be8125
|
|
| MD5 |
816c7060ae4bf8f8f813305bd5f92fc9
|
|
| BLAKE2b-256 |
19b67210e9887e893d1859cc86f47b5428e1a47f298cff3e82ba522887d933cf
|