Skip to main content

Python bindings for EnTT - A high-performance Entity Component System library

Project description

PyEnTT

简体中文 | English

Python License Tests

Python bindings for EnTT - A high-performance Entity Component System library for game development and real-time applications.

Features

  • High Performance: Zero-overhead abstractions leveraging EnTT's C++ core
  • ECS Architecture: Entity-Component-System for flexible game design
  • Type Safety: Full Python type hints support
  • Cross-Platform: Supports Linux, macOS, and Windows
  • Python 3.10+: Stable ABI wheels for wide compatibility
  • Modern Python: Uses nanobind for efficient bindings

Installation

Install from PyPI:

pip install entt

Or install from source:

git clone https://github.com/your-username/PyEnTT.git
cd PyEnTT
pip install .

Requirements

  • Python 3.10 or higher
  • C++17 compatible compiler (GCC 7+, Clang 5+, MSVC 2017+)

Quick Start

from entt import Registry, Entity, Component

# Define a component
class Position:
    def __init__(self, x: float, y: float):
        self.x = x
        self.y = y

class Velocity:
    def __init__(self, x: float, y: float):
        self.x = x
        self.y = y

# Create a registry
registry = Registry()

# Create entities
entity1 = registry.create()
entity2 = registry.create()

# Add components
registry.emplace(entity1, Position, 0.0, 0.0)
registry.emplace(entity1, Velocity, 1.0, 0.5)
registry.emplace(entity2, Position, 10.0, 5.0)

# Query entities with specific components
view = registry.view(Position, Velocity)

for entity in view:
    pos = registry.get(entity, Position)
    vel = registry.get(entity, Velocity)
    print(f"Entity {entity}: pos=({pos.x}, {pos.y}), vel=({vel.x}, {vel.y})")

Advanced Usage

Observer Pattern

from entt import SignalObserver, SignalEvent

class MyObserver(SignalObserver):
    def on_construct(self, reg, entity):
        print(f"Entity {entity} constructed")
    
    def on_update(self, reg, entity):
        print(f"Entity {entity} updated")
    
    def on_destroy(self, reg, entity):
        print(f"Entity {entity} destroyed")

observer = MyObserver()
registry.connect(Position, SignalEvent.OnConstruct, observer)

Reactive Storage

from entt import ReactiveStorage

# Create reactive storage for reactive components
storage = registry.reactive()

# Subscribe to events
storage.on_construct(Position)

Documentation

For more detailed documentation, examples, and API reference, please visit our documentation.

Testing

Run tests:

pytest

Building from Source

# Install build dependencies
pip install nanobind scikit-build-core

# Build and install
pip install -e .

Contributing

Contributions are welcome! Please see CONTRIBUTING.md for details.

License

This project is licensed under the MIT License - see the LICENSE file for details.

Acknowledgments

Links

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.

entt-0.1.1-cp312-abi3-win_amd64.whl (93.1 kB view details)

Uploaded CPython 3.12+Windows x86-64

entt-0.1.1-cp312-abi3-macosx_15_0_arm64.whl (79.5 kB view details)

Uploaded CPython 3.12+macOS 15.0+ ARM64

File details

Details for the file entt-0.1.1-cp312-abi3-win_amd64.whl.

File metadata

  • Download URL: entt-0.1.1-cp312-abi3-win_amd64.whl
  • Upload date:
  • Size: 93.1 kB
  • Tags: CPython 3.12+, Windows x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.10.8 {"installer":{"name":"uv","version":"0.10.8","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

File hashes

Hashes for entt-0.1.1-cp312-abi3-win_amd64.whl
Algorithm Hash digest
SHA256 7e92d598d7878796b5d97c0063818edfa73fee299b470a00543f6957c690b554
MD5 2f86c5346bdd9c27be33fb0707e7d6e6
BLAKE2b-256 f434844fe22355b4a71756949ce14a4eb24a169839821b46c13ff47d05731897

See more details on using hashes here.

File details

Details for the file entt-0.1.1-cp312-abi3-macosx_15_0_arm64.whl.

File metadata

  • Download URL: entt-0.1.1-cp312-abi3-macosx_15_0_arm64.whl
  • Upload date:
  • Size: 79.5 kB
  • Tags: CPython 3.12+, macOS 15.0+ ARM64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.10.8 {"installer":{"name":"uv","version":"0.10.8","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

File hashes

Hashes for entt-0.1.1-cp312-abi3-macosx_15_0_arm64.whl
Algorithm Hash digest
SHA256 7b91444f3d90077730cef2161c471545c1e035e23141d6bea2da9f189358ac6f
MD5 7e8307eb585b7f9d193df47ce91b925f
BLAKE2b-256 d0184fb9e7e1b9a237f2f196c7f444449ca2d52f7faa369db46c1999b1ac9f03

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