开发者

Cython cimport and __init__.pyx buggy?

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__.py or __init__.pyx file it is assumed to be a package directory. So in your example the utils module is assumed to belong to the package DrawAPI and its FQMN is DrawAPI.utils

However, if DrawAPI is the current directory you're running the compiler from, and you haven't added DrawAPI to the include path the utils.pxd won'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__.pyx file.

If you intend it to reside in a package, then cd to the directory containing DrawAPI and compile from there.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜