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.0-cp312-abi3-win_amd64.whl (93.1 kB view details)

Uploaded CPython 3.12+Windows x86-64

entt-0.1.0-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.0-cp312-abi3-win_amd64.whl.

File metadata

  • Download URL: entt-0.1.0-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.0-cp312-abi3-win_amd64.whl
Algorithm Hash digest
SHA256 298d37d6992dbd2a73e9670d64fe5ddbef9e8148bbcbbe46ea521d0fd6c97cbc
MD5 44c0600e10423eb3f0476b82acbcc324
BLAKE2b-256 84fb41ca9e5534d36bcebf495048e5541e4ba06b2c0891c56daf4976773edc48

See more details on using hashes here.

File details

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

File metadata

  • Download URL: entt-0.1.0-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.0-cp312-abi3-macosx_15_0_arm64.whl
Algorithm Hash digest
SHA256 12123fc91224805290d577289aaff6ab5683ff0ddd6d1c3bf3377c1d5a9c5b04
MD5 a2b9e2099e7ad7bedb12a08b857503bc
BLAKE2b-256 ad80ed2b4080ec8972c9b1555709528ae3a0ef070cfa250eabc5b86a2c1cad6d

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