I have found partial answers between the docs, mailing lists, and this question here, but I wanted to get a more direct answer addressing my specifics...
I'm learning cython by trying to wrap small parts, little by little, of a library that I am already using that is currently wrapped in boost::python. I have contributed a tiny bit to this boost wrapper, and am using it as a c++ reference, while at the same time I am using ZeroMQ Python bindings as a cython reference.
My question is about project structure. The current boost version of this lib compiles to a single
pxi, pxd, pyx
While waiting for a definitive answer, I kept playing around with organizing my code. The including of
pyx files into a single
pyx for compilation has been working so far.
setup.py is simple like:
ext_modules = [ Extension( "openni", ["src/openni.pyx"], language="c++", include_dirs=['src/', '/usr/include/ni'], libraries=['OpenNI'], ) ],
openni.pyx looks like:
include "constants.pyx" include "exceptions.pyx" include "context.pyx" ...
I have a common
libopenni.pxd to provide declaration-only externs to the rest of the modules.
I name my
cppclass declarations a different
pxd name than the
pyx class definitions to avoid name collision:
cdef extern from "XnCppWrapper.h" namespace "xn": cdef cppclass Context: ...
from libopenni cimport * from xncontext cimport Context as c_Context cdef class Context: cdef c_Context *handle ...