August'24: Kamaelia is in maintenance mode and will recieve periodic updates, about twice a year, primarily targeted around Python 3 and ecosystem compatibility. PRs are always welcome. Latest Release: 1.14.32 (2024/3/24)
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.