Keyboard shortcuts

Press or to navigate between chapters

Press S or / to search in the book

Press ? to show this help

Press Esc to hide this help

Python Plugin Development

DaiC leverages pybind11 to bridge the Python environment with the core C++ engine.

Prerequisites

Before developing, ensure you have the DaiC Python bindings installed in your environment:

pip install DaiCCore

The Plugin Class

Your plugin must be structured as a Python package (a directory containing an init.py file). Inside, you must define a class that inherits from DaiCCore.Plugin. Python

import DaiCCore

class Example(DaiCCore.Plugin):
    # Metadata
    name = "Example"         # Must match the folder name
    description = "A brief description of your plugin"
    version = "1.0.0"
    author = "Your Name"

    def init(self):
        """Called when the plugin is first loaded."""
        pass

    def run(self):
        """Main execution logic for the plugin."""
        pass

    def terminate(self):
        """Cleanup logic before the plugin is unloaded."""
        pass

Dependency Management

DaiC features an automated dependency resolver. If your plugin requires external libraries (like requests or numpy), simply include a standard requirements.txt file in your plugin folder.

Workflow:

  • Detection: On startup, DaiC scans for requirements.txt.
  • Installation: Missing dependencies are automatically installed via pip into the DaiC virtual environment.
  • Isolation: This ensures your plugin has everything it needs to run without manual user intervention.

Directory Example

plugins/
└── python/
    └── Example/
        ├── __init__.py      <-- Contains the Example class
        └── requirements.txt <-- Optional dependencies

Strict Naming: Just like C++ plugins, the Python class name must be identical to the folder name.