Skip to main content

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

Project description

PyEnTT

简体中文 | English

Python License Tests

⚠️ Development Warning
This binding is currently under development and does not provide all features of the original EnTT library. The Python API is designed according to Python characteristics and may differ from the C++ interface.

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.12+: 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/ominkk/PyEnTT.git
cd PyEnTT

# Using pip
pip install .

# Or using uv (recommended)
uv pip install -e .

Requirements

  • Python 3.12 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 using uv
uv sync

# Build and install
uv 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.2-cp312-abi3-win_amd64.whl (93.2 kB view details)

Uploaded CPython 3.12+Windows x86-64

entt-0.1.2-cp312-abi3-macosx_15_0_arm64.whl (79.7 kB view details)

Uploaded CPython 3.12+macOS 15.0+ ARM64

File details

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

File metadata

  • Download URL: entt-0.1.2-cp312-abi3-win_amd64.whl
  • Upload date:
  • Size: 93.2 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.2-cp312-abi3-win_amd64.whl
Algorithm Hash digest
SHA256 46b09b43da10003f386d1f67f34ae35f198b17c00491fac27d5a47d152b30c8e
MD5 5ff7ee0fea39ba91523d0db2b6774f36
BLAKE2b-256 4c5f7aea37d1437daa3dd3404163376126b041c7b0d080d366aa625f85a20685

See more details on using hashes here.

File details

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

File metadata

  • Download URL: entt-0.1.2-cp312-abi3-macosx_15_0_arm64.whl
  • Upload date:
  • Size: 79.7 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.2-cp312-abi3-macosx_15_0_arm64.whl
Algorithm Hash digest
SHA256 f34b99a4aa1a60e30238272ed3358ea91d09b614302562208ea6c60b10ce5d88
MD5 e71307714024c9804bf74bf66cebd7db
BLAKE2b-256 96f376bf509cd4441b070dee4d05a8e68ef7440c86b8b725898afe24f1116379

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