Overview

Purpose

helloworld-python-binding is a minimal AFB service implemented with afb-libpython.

The project mirrors the public API of helloworld-binding and helloworld-rust-binding while showing how the same service can be implemented directly in Python.

The sample demonstrates:

  • creation of an AFB binder and API from Python;
  • hello and sum request handling;
  • typed request conversion and replies;
  • AFB event creation, subscription and publication;
  • the info verb generated automatically by afb-libpython;
  • execution as a native redpesk application;
  • functional validation and redtest integration.

Architecture

Unlike the C sample, the Python implementation does not produce a loadable .so binding. The application starts libafb itself, creates the helloworld API and enters the AFB event loop.

The helloworld API is exported through AFB transports to clients such as afb-client or afb-binder.

                 +----------------------+
                 |      AFB client      |
                 | afb-client / tests   |
                 +----------+-----------+
                            |
                            | AFB API
                            v
                 +----------------------+
                 |     libafb-python    |
                 | started from Python  |
                 +----------+-----------+
                            |
                            v
                 +----------------------+
                 |      helloworld      |
                 | hello / sum / info   |
                 +----------------------+

The binding itself does not depend on external hardware. It can therefore be executed on a development host, in a redpesk development environment (like using the localbuilder), or on a redpesk target (QEMU, aarch64 or x86_64 target).

Shared API contract

The service exposes:

  • API helloworld;
  • verb hello;
  • verb sum;
  • verb info;
  • event helloworld/verb_called.

The C, Python and Rust samples expose the same public verbs and event, and keep the same essential request semantics. Each implementation is nevertheless free to use the conventions of its own language instead of reproducing implementation-specific constraints from another binding.

For example, the Python hello implementation uses Python-native value formatting and does not impose the fixed reply-size limit inherited from the C implementation. The sum verb keeps signed 64-bit validation and wrapping because that is part of the shared API contract.

info is another intentional implementation difference: afb-libpython provides a default implementation of this verb from the API metadata, so the Python service does not need to register a second explicit info callback. The default implementation can still be overridden when custom behavior is required.

Project layout

The main project files are organized as follows:

bin/                              launcher for running the service from sources
helloworld_python_binding/        main Python source package
rpconfig/manifest.yml             redpesk application manifest
redtest/run-redtest               redtest entry point
tests/                            functional tests and CI helpers
docs/                             project documentation
helloworld-python-binding.spec    RPM packaging
pyproject.toml                    Python project metadata