I don't see any memoryview usage in that example. Could you post a
minimal working example (not dependent on any external types or
functions) that produces this behaviour?
In foo.pyx:
----------------------------------------------------
from foo cimport *
cdef int baz( long[:] a ):
return 0
----------------------------------------------------
In foo.pxd:
----------------------------------------------------
cimport numpy as np
cdef int baz( long[:] a )
cdef inline np.ndarray[ long, ndim = 1 ] foo():
cdef np.ndarray[ long, ndim = 1 ] out = np.empty( ( 8, ), dtype = 'i8' )
baz( out )
return out
----------------------------------------------------
in bar.pyx:
----------------------------------------------------
cimport numpy as np
from foo cimport foo
cdef int bar():
cdef np.ndarray[ long, ndim = 1 ] q = foo()
----------------------------------------------------
Now, in python, import of bar fails:
----------------------------------------------------
In [1]: import pyximport; pyximport.install(); import bar
/Users/shauncutts/.pyxbld/temp.macosx-10.7-intel-2.7/pyrex/bar.c: In function ‘__pyx_f_3foo_foo’:
/Users/shauncutts/.pyxbld/temp.macosx-10.7-intel-2.7/pyrex/bar.c:1761: warning: implicit declaration of function ‘__Pyx_PyObject_to_MemoryviewSlice_ds_long’
/Users/shauncutts/.pyxbld/temp.macosx-10.7-intel-2.7/pyrex/bar.c:1761: error: incompatible types in assignment
/Users/shauncutts/.pyxbld/temp.macosx-10.7-intel-2.7/pyrex/bar.c: In function ‘__pyx_f_3foo_foo’:
/Users/shauncutts/.pyxbld/temp.macosx-10.7-intel-2.7/pyrex/bar.c:1761: warning: implicit declaration of function ‘__Pyx_PyObject_to_MemoryviewSlice_ds_long’
/Users/shauncutts/.pyxbld/temp.macosx-10.7-intel-2.7/pyrex/bar.c:1761: error: incompatible types in assignment
/Users/shauncutts/.pyxbld/temp.macosx-10.7-intel-2.7/pyrex/bar.c: In function ‘__pyx_array_MemoryView_5array___cinit__’:
/Users/shauncutts/.pyxbld/temp.macosx-10.7-intel-2.7/pyrex/bar.c:3931: warning: implicit conversion shortens 64-bit value into a 32-bit value
/Users/shauncutts/.pyxbld/temp.macosx-10.7-intel-2.7/pyrex/bar.c: In function ‘__pyx_memoryview_get_item_pointer’:
/Users/shauncutts/.pyxbld/temp.macosx-10.7-intel-2.7/pyrex/bar.c:5896: warning: implicit conversion shortens 64-bit value into a 32-bit value
lipo: can't open input file: /var/folders/pq/ww1fn4v55h77lg9xpxvt6htm0000gn/T//ccYJkRAx.out (No such file or directory)
----------------------------------------------------
Note if bar.pyx is changed to itself have an assignment of a memoryview from a vector everything is ok, as the compiler includes proper prototype for __Pyx_PyObject_to_MemoryviewSlice_ds_long.
The point is, when bar.pyx doesn't have any such copies, but the prototype is required because of inline code included from foo.pxd, we have a problem.