On Jul 13, 2009, at 2:19 PM, Soeren Apel wrote:

> Hello everyone,
>
> I'm trying to use cython to build a customized python extension that
> interfaces evas from the enlightenment foundation libraries. Their  
> team
> has already written a binding which my work relies upon:
> http://trac.enlightenment.org/e/browser/trunk/BINDINGS/python/ 
> python-evas
>
> I took the files in evas/ and include/, added my move_relative.pyx  
> file
> and tried to compile the bunch. However, there are problems arising.
> Unfortunately I couldn't find any way to solve this, nor could I find
> anyone able to help me with this. For this reason, you're my last
> hope :)
>
>
> Scenario 1: If my move_relative.pyx contains
> ------------------------------------------------------------------
> import evas
>
> cdef _evas_move_relative(evas.c_evas.Evas_Object *obj, int dx, int  
> dy):
>         cdef int x, y
>
>         c_evas.evas_object_geometry_get(obj, &x, &y, NULL, NULL)
>         c_evas.evas_object_move(obj, x + dx, y + dy)
>
>
> def evas_move_relative(evas.c_evas.Object object, dx, dy):
>         _evas_move_relative(object.obj, dx, dy)
> ------------------------------------------------------------------
> the code makes use of the python-evas binding as intended but fails to
> compile:
>
> move_relative.pyx:10:23: 'move_relative' is not a cimported module
>
> I neither understand the meaning of the error message, nor does it  
> give
> any helpful clues as to how the problem can be resolved. With that,  
> I'm
> kind of stuck.

I'm not sure what that error means either. I could expect "'evas is  
not a cimported module."

>
> Scenario 2: If my move_relative.pyx contains
> ------------------------------------------------------------------
> cimport c_evas
>
> cdef _evas_move_relative(c_evas.Evas_Object *obj, int dx, int dy):
>         cdef int x, y
>
>         c_evas.evas_object_geometry_get(obj, &x, &y, NULL, NULL)
>         c_evas.evas_object_move(obj, x + dx, y + dy)
>
>
> def evas_move_relative(c_evas.Object object, dx, dy):
>         _evas_move_relative(object.obj, dx, dy)
> ------------------------------------------------------------------
> the code compiles just fine but an import fails on runtime:
>
> Traceback (most recent call last):
>   File "01-smart_object_cython.py", line 7, in <module>
>     from move_relative import evas_move_relative
>   File "c_evas.pxd", line 682, in move_relative (move_relative.c:1036)
> ImportError: No module named c_evas
>
> Line 1036 contains a call to __Pyx_ImportType() that imports c_evas.
>
> I can see why the import would fail as c_evas is a submodule of  
> evas but
> the fact that cython doesn't fail compilation with the "cimported
> module" message confuses me.
>
> I would be very happy if someone could shed some light into this issue
> and give me a pointer on where to look.

This is because there is no module c_evas, it's in the evas package  
so has to be imported as evas.c_evas.

It looks like their directory structure is

/evas
     evas.c_evas.pyx  # creates the module evas.c_evas, I'm really  
tempted to depreciate the dotted-filename style of package naming
     ...
/include
     /evas
         c_evas.pxd

Somehow /include/evas is in your include path, rather than just / 
include. You need to "cimport evas.c_evas as c_evas" (or "as evas" if  
you want).

- Robert
_______________________________________________
Cython-dev mailing list
[email protected]
http://codespeak.net/mailman/listinfo/cython-dev

Reply via email to