[Pyrex] Circular cimports
Mike Wyatt
mwyatt at wi.rr.com
Fri Jun 9 03:16:03 UTC 2006
I'm building a little math library in Pyrex, and I'm having trouble with
some circular cimports. I'll post short excerpts from my various files,
then show the error that I'm getting when I try to use one of the modules.
***matrix.pxd**
*cdef class Matrix:
cdef float m[4][4]
***matrix.pyx**
*cimport vector
cdef class Matrix:
### a bunch of methods, including ones that create or manipulate
Vector objects ###
***vector.pxd**
*cdef class Vector:
cdef float x, y, z, w
***vector.pyx***
cimport matrix
cdef class Vector:
### a bunch of methods, including one that has a Matrix argument ###
After building the Pyrex modules into .pyd files, I run a test module.
The first line imports the matrix module and throws this error:
Traceback (most recent call last):
File "C:\Development\SFStratPrototype\math3d\matrixTest.py", line 1, in ?
import matrix
File "vector.pxd", line 1, in matrix
cdef class Vector:
File "matrix.pxd", line 1, in vector
cdef class Matrix:
AttributeError: 'module' object has no attribute 'Matrix'
Press any key to continue . . .
It doesn't seem to like how the modules cimport each other. I can't see
any way to eliminate this circular reference, so what can I do to fix
this error?
- Mike Wyatt
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.copyleft.no/pipermail/pyrex/attachments/20060609/a60f797b/attachment.html
More information about the Pyrex
mailing list