我有一个简单的项目目录和一些简单的档案,无法汇编。
名录结构:
cythonize: ROOT
|___ cythonize
|___ __init__.pxd
|___ __init__.py
|___ first.pxd
|___ first.pyx
|___ second.pxd
|___ second.pyx
|___ README.md
|___ setup.py
让我表明每个档案中的确切内容。
_init__.pxd
:
<EMPTY FILE>
_init__.py
:
<EMPTY FILE>
<代码>第1.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
我只是试图将<代码>cimportfirst
从first.pxd
输入second.pyx
,以便在second.pyx
中使用<>。
Compilation Errors
>>> cythonize -i -k -3 cythonize/second.pyx
Compiling C:...cythonizecythonizesecond.pyx because it changed.
[1/1] Cythonizing C:...cythonizecythonizesecond.pyx
Error compiling Cython file:
------------------------------------------------------------
...
#cython language_level=3
from . cimport first
cdef first second(str a, str b):
^
------------------------------------------------------------
cythonizesecond.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) ^
------------------------------------------------------------
cythonizesecond.pyx:6:11: first is not a constant, variable or function identifier
Failed compilations: cythonize.second
也许人们可以说明什么是能够使这项工作取得成功的最低可行范例?