8

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 ?

1 Answer 1

6
+50

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.

Sign up to request clarification or add additional context in comments.

1 Comment

Lol, of course. Haven't thought about this. Unfortunately, relative import isn't supported yet, but using from DrawAPI cimport utils works just fine. :) +50 bounty worth & +1

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.