April 2024 - This site, and Kamaelia are being updated. There is significant work needed, and PRs are welcome.

Using Pyrex To Write Components

First stab at writing Kamaelia Components using Pyrex. This code uses Pyrex 0.9.3, and has some issues that need resolving, but this does actually work.

File: pyrexcomponent.pyx

#
# Simple pyrex component
#

import Axon.Component.component

cdef class test(Axon.Component.component):

def mainBody(self):

if self.dataReady("inbox"):

return 1

File: Axon.Component.pxd

class component:

File: setup.py

from distutils.core import setup
from distutils.extension import Extension
from Pyrex.Distutils import build_ext

setup(

name = 'PyrexComponent',

ext_modules=list(

Extension("pyrexcomponent",

),

),

cmdclass = {'build_ext': build_ext}

)

Build

Creating an instance

Summary

There's clearly some minor issues here and scope for improvement, but this clearly shows that you can write components in pyrex, which therefore means you can pull in any library with a C interface with relative ease.