It seems like compiling an __init__.pyx that contains a cimport statement is buggy.
This is my folder-structure:
DrawAPI\
__init__.pyx
utils.pxd
The __init__.pyx:
cimport utils
Compiling the __init__.pyx with cython gives me that utils.pxd could not be found. But renaming __init__.pyx to any other name, like foo.pyx for instance
DrawAPI\
foo.pyx
utils.pxd
and then compiling foo.pyx works just fine.
Am I doing something wrong ?
If a directory contains an
__init__.pyor__init__.pyxfile it is assumed to be a package directory. So in your example the utils module is assumed to belong to the packageDrawAPIand its FQMN isDrawAPI.utilsHowever, if
DrawAPIis the current directory you’re running the compiler from, and you haven’t added DrawAPI to the include path theutils.pxdwon’t be found (as you have discovered…)If you intend utils to be a top-level module then you will have to move it somewhere else where there is no
__init__.pyxfile.If you intend it to reside in a package, then cd to the directory containing
DrawAPIand compile from there.