<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
  <meta content="text/html;charset=ISO-8859-1" http-equiv="Content-Type">
</head>
<body bgcolor="#ffffff" text="#000000">
I'm building a little math library in Pyrex, and I'm having trouble
with some circular cimports.&nbsp; 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.<br>
<br>
<b>**matrix.pxd**<br>
</b>cdef class Matrix:<br>
&nbsp;&nbsp;&nbsp; cdef float m[4][4]<br>
<br>
<b>**matrix.pyx**<br>
</b>cimport vector<br>
<br>
cdef class Matrix:<br>
&nbsp;&nbsp;&nbsp; ### a bunch of methods, including ones that create or manipulate
Vector objects ###<br>
<br>
<b>**vector.pxd**<br>
</b>cdef class Vector:<br>
&nbsp;&nbsp;&nbsp; cdef float x, y, z, w<br>
<br>
<b>**vector.pyx**</b><br>
cimport matrix<br>
<br>
cdef class Vector:<br>
&nbsp;&nbsp;&nbsp; ### a bunch of methods, including one that has a Matrix argument ###<br>
<br>
After building the Pyrex modules into .pyd files, I run a test module.&nbsp;
The first line imports the matrix module and throws this error:<br>
<br>
Traceback (most recent call last):<br>
&nbsp; File "C:\Development\SFStratPrototype\math3d\matrixTest.py", line 1,
in ?<br>
&nbsp;&nbsp;&nbsp; import matrix<br>
&nbsp; File "vector.pxd", line 1, in matrix<br>
&nbsp;&nbsp;&nbsp; cdef class Vector:<br>
&nbsp; File "matrix.pxd", line 1, in vector<br>
&nbsp;&nbsp;&nbsp; cdef class Matrix:<br>
AttributeError: 'module' object has no attribute 'Matrix'<br>
Press any key to continue . . .<br>
<br>
It doesn't seem to like how the modules cimport each other.&nbsp; I can't
see any way to eliminate this circular reference, so what can I do to
fix this error?<br>
<br>
- Mike Wyatt<br>
</body>
</html>