Skip to main content

PyBevy: A Python Real-Time Engine Built on Bevy

Project description

PyBevy: A Python Real-Time Engine Built on Bevy

Discord License pypi pypi downloads

$ 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

Hot reloading demo

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

Linux System Dependencies

PyBevy's pre-built wheels link against system display and audio libraries. On most desktop distributions these are already present.

If you see an ImportError mentioning libwayland-client.so or libasound.so:

# Debian/Ubuntu
sudo apt install libwayland-client0 libasound2t64

# Fedora/RHEL
sudo dnf install alsa-lib wayland

Docker / headless environments also need a software GPU driver:

apt install -y libwayland-client0 libasound2t64 mesa-vulkan-drivers

ALSA warnings about missing audio devices are harmless and can be ignored.

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 — llvmlite does 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: PyBevyPlugin embeds 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.

Development Process

PyBevy started in May 2025 as a pure-Python ECS prototype, then moved through a ctypes FFI layer before pivoting to PyO3, which became the real foundation. Hand-written .pyi type stubs drove the API design before the Rust integration was fully in place. The project also builds on Bevy experience going back to 2021.

The ECS query model, safety/validity system, and core Bevy component bindings were developed manually across multiple iterations.

From November 2025 onward, AI tools were used more heavily for API coverage expansion across Bevy's large surface area, crate splitting into ~30 feature crates, and parts of the test/stub/documentation workflow.

To keep that process grounded, PyBevy is backed by a custom Rust API compliance tool that validates bindings against Bevy's source and the Python stubs, and a test suite spanning 100K+ lines. Both publishing soon.

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

Community & Contributing

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

No source distribution files available for this release.See tutorial on generating distribution archives.

Built Distributions

If you're not sure about the file name format, learn more about wheel file names.

pybevy-0.2.1-cp314-cp314-win_amd64.whl (29.9 MB view details)

Uploaded CPython 3.14Windows x86-64

pybevy-0.2.1-cp314-cp314-manylinux_2_28_x86_64.whl (29.2 MB view details)

Uploaded CPython 3.14manylinux: glibc 2.28+ x86-64

pybevy-0.2.1-cp314-cp314-macosx_11_0_arm64.whl (26.5 MB view details)

Uploaded CPython 3.14macOS 11.0+ ARM64

pybevy-0.2.1-cp314-cp314-macosx_10_12_x86_64.whl (27.7 MB view details)

Uploaded CPython 3.14macOS 10.12+ x86-64

pybevy-0.2.1-cp313-cp313-win_amd64.whl (29.6 MB view details)

Uploaded CPython 3.13Windows x86-64

pybevy-0.2.1-cp313-cp313-manylinux_2_28_x86_64.whl (29.1 MB view details)

Uploaded CPython 3.13manylinux: glibc 2.28+ x86-64

pybevy-0.2.1-cp313-cp313-macosx_11_0_arm64.whl (26.4 MB view details)

Uploaded CPython 3.13macOS 11.0+ ARM64

pybevy-0.2.1-cp313-cp313-macosx_10_12_x86_64.whl (27.6 MB view details)

Uploaded CPython 3.13macOS 10.12+ x86-64

pybevy-0.2.1-cp312-cp312-win_amd64.whl (29.6 MB view details)

Uploaded CPython 3.12Windows x86-64

pybevy-0.2.1-cp312-cp312-manylinux_2_28_x86_64.whl (29.1 MB view details)

Uploaded CPython 3.12manylinux: glibc 2.28+ x86-64

pybevy-0.2.1-cp312-cp312-macosx_11_0_arm64.whl (26.4 MB view details)

Uploaded CPython 3.12macOS 11.0+ ARM64

pybevy-0.2.1-cp312-cp312-macosx_10_12_x86_64.whl (27.6 MB view details)

Uploaded CPython 3.12macOS 10.12+ x86-64

File details

Details for the file pybevy-0.2.1-cp314-cp314-win_amd64.whl.

File metadata

  • Download URL: pybevy-0.2.1-cp314-cp314-win_amd64.whl
  • Upload date:
  • Size: 29.9 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

Hashes for pybevy-0.2.1-cp314-cp314-win_amd64.whl
Algorithm Hash digest
SHA256 4dffacfec344057dd2c68e2a24543aabfef9d8056a419a99072de21513992e9d
MD5 38904347ebcb5aa93e8c39db745aa2ee
BLAKE2b-256 85f5a25f2b01a8da1c36e7962f5e04a15558f5f874c1efbb8bc8699f04d94b0f

See more details on using hashes here.

File details

Details for the file pybevy-0.2.1-cp314-cp314-manylinux_2_28_x86_64.whl.

File metadata

File hashes

Hashes for pybevy-0.2.1-cp314-cp314-manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 31249917b3fc099a72ab4a098ddec5e030a392ac3478779530f45d3aa29a6c64
MD5 6b8a45d64eba529294d0b73a0feb9b70
BLAKE2b-256 c5a14db1e1afcb2d3ea72fa837520a5775f80052b497172ec23aea932deaa73c

See more details on using hashes here.

File details

Details for the file pybevy-0.2.1-cp314-cp314-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for pybevy-0.2.1-cp314-cp314-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 097ff86018b21e6028fd9c91e5a3d7a74106417fe4c296bfa39d785539d70024
MD5 f82f7ca6782e04d2d302cab1b0e0c0fa
BLAKE2b-256 c836260096448125bb012b96d53e82ea57d4839a705935d9210b1aec01d45a18

See more details on using hashes here.

File details

Details for the file pybevy-0.2.1-cp314-cp314-macosx_10_12_x86_64.whl.

File metadata

File hashes

Hashes for pybevy-0.2.1-cp314-cp314-macosx_10_12_x86_64.whl
Algorithm Hash digest
SHA256 307943020f7f7e5e5b16a42e7f9a6a0b2e63089201745222cec251d94de5a22f
MD5 e2ff098a11cf7c1dc8aa29a92c576248
BLAKE2b-256 78bd02a1d5994f483785311b81d2783e0ae973e805906144e4c617befbb1c3e3

See more details on using hashes here.

File details

Details for the file pybevy-0.2.1-cp313-cp313-win_amd64.whl.

File metadata

  • Download URL: pybevy-0.2.1-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

Hashes for pybevy-0.2.1-cp313-cp313-win_amd64.whl
Algorithm Hash digest
SHA256 34052817b710c58869b10462d03b127a8e47c8215ccb4a1368399624d2221c34
MD5 4fd947e8a3167fc656b5baacb1d2fb69
BLAKE2b-256 ebfee75309784cb9c88455666d62931980be926b3df1c8bdb38b2f8e22744516

See more details on using hashes here.

File details

Details for the file pybevy-0.2.1-cp313-cp313-manylinux_2_28_x86_64.whl.

File metadata

File hashes

Hashes for pybevy-0.2.1-cp313-cp313-manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 2ef7ba4cb7c43e5a50834d04f0e9099744dd9ad08b22060319b0c3b53d93c2f5
MD5 1892b05e3405c4c03e315d3b34f769c9
BLAKE2b-256 0659916289d2f3e967b5557d61cea98d6ea28540e96a0925aadbca9c660e7280

See more details on using hashes here.

File details

Details for the file pybevy-0.2.1-cp313-cp313-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for pybevy-0.2.1-cp313-cp313-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 c715687264fb80991a74d1dde8d9b22fcfe9bde826f4d03aa91f246b20a8cf39
MD5 c7e2daf4c0e7e64d0ee49b5319a3a236
BLAKE2b-256 d85ee2188e6e632f9c253c3b445f31f88448776ffba4d9190ed4521399caf16a

See more details on using hashes here.

File details

Details for the file pybevy-0.2.1-cp313-cp313-macosx_10_12_x86_64.whl.

File metadata

File hashes

Hashes for pybevy-0.2.1-cp313-cp313-macosx_10_12_x86_64.whl
Algorithm Hash digest
SHA256 3bf73f461c9763154fe29b5ce0afce09979483076e356e199218d615a27254f7
MD5 97b341945799a260a5db4063fadd9dd3
BLAKE2b-256 298e8c59779afdaba6f2154a06d8059aa258f282f2b25f45fd604911aed2a13b

See more details on using hashes here.

File details

Details for the file pybevy-0.2.1-cp312-cp312-win_amd64.whl.

File metadata

  • Download URL: pybevy-0.2.1-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

Hashes for pybevy-0.2.1-cp312-cp312-win_amd64.whl
Algorithm Hash digest
SHA256 81b2457836b969d6f8e553acd969183b0126496f2a85fb5d3faf9d0439ff475a
MD5 b916c6f97f7f67b118b6a456f8540149
BLAKE2b-256 98a601ca1060f0a44fb3ff002ada0647641ba099505f4428889785ac53b54b2a

See more details on using hashes here.

File details

Details for the file pybevy-0.2.1-cp312-cp312-manylinux_2_28_x86_64.whl.

File metadata

File hashes

Hashes for pybevy-0.2.1-cp312-cp312-manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 1f440f5b27f0e97a6370ea88e238bdf25a0f26d81b7c04b7d5b3aa78af4c187c
MD5 cfeff2238f5763d829b18c5ec5afd787
BLAKE2b-256 11608015abfb4a2d9e8e89471ae30bcdb63e701dc9e9a0e81949be828e51f9db

See more details on using hashes here.

File details

Details for the file pybevy-0.2.1-cp312-cp312-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for pybevy-0.2.1-cp312-cp312-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 8537c7a6f4bab1a2c923ec5b06be984a8e2c3a0fb6765f9b072c5c9db0fd47ad
MD5 c5dd60f47d13fd9b5b5750773063e749
BLAKE2b-256 e51589d79731b45a59750668711c9f2fa5ed418e7218c9d4a6546e8204e85e50

See more details on using hashes here.

File details

Details for the file pybevy-0.2.1-cp312-cp312-macosx_10_12_x86_64.whl.

File metadata

File hashes

Hashes for pybevy-0.2.1-cp312-cp312-macosx_10_12_x86_64.whl
Algorithm Hash digest
SHA256 0c0d6e506e255b7fac48b8cd2df09a1a6104daef51e6cf4f1e2f2d6c6202bd75
MD5 7138dbc176309f578f47e39c9a2c3562
BLAKE2b-256 f31e40f2854f68984d27ebd00c5d9d445167d75b128207665eb359f1bb6300f2

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page