I have a simple project directory and some simple files which failed to compile.
Directory structure:
cythonize: ROOT
|___ cythonize
|___ __init__.pxd
|___ __init__.py
|___ first.pxd
|___ first.pyx
|___ second.pxd
|___ second.pyx
|___ README.md
|___ setup.py
Let me show what are the exact content in every file.
__init__.pxd
:
<EMPTY FILE>
__init__.py
:
<EMPTY FILE>
first.pxd
:
cdef class MyClass:
cdef str good
cdef str bad
cdef str say(self, str x, str y)
first.pyx
:
cdef class MyClass:
cdef str say(self, str x, str y):
return x
second.pxd
:
from . cimport first # removing this does not help
second.pyx
:
#cython language_level=3
from . cimport first
cdef first second(str a, str b):
return first(a, b)
Objective
I am simply trying to cimport
first
from first.pxd
into second.pyx
in order to use first
in second.pyx
.
Compilation Errors
>>> cythonize -i -k -3 cythonize/second.pyx
Compiling C:\...\cythonize\cythonize\second.pyx because it changed.
[1/1] Cythonizing C:\...\cythonize\cythonize\second.pyx
Error compiling Cython file:
------------------------------------------------------------
...
#cython language_level=3
from . cimport first
cdef first second(str a, str b):
^
------------------------------------------------------------
cythonize\second.pyx:5:5: 'first' is not a type identifier
Error compiling Cython file:
------------------------------------------------------------
...
#cython language_level=3
from . cimport first
cdef first second(str a, str b):
return first(a, b) ^
------------------------------------------------------------
cythonize\second.pyx:6:11: 'first' is not a constant, variable or function identifier
Failed compilations: cythonize.second
Maybe one can show what is the minimum viable example that can make this work?