将 cython 构建到 cpp 时找不到 pxd
pxd not found when building cython into cpp
我有这样的目录结构:
project/lib/src/a.pyx
project/lib/src/<some other files>
project/helpers/cython/b.pyx
project/helpers/cython/b.pxd
project/helpers/cython/setup.py
project/helpers/cython/__init__.py
project/helpers/cython/setup.py
看起来像这样:
from distutils.core import setup
from Cython.Build import cythonize
setup(
ext_modules=cythonize("helpers/cython/b.pyx"),
)
在a.pyx
中,我有以下几行:
import helpers.cython.b as utils
cimport helpers.cython.b as utils_c
当,在project/lib/
,我运行
cython src/*.pyx srsc/*.pxd -a --cplus
,我收到错误消息
import helpers.cython.b as utils
cimport helpers.cython.b as utils_c
^
------------------------------------------------------------
a.pyx:29:8: 'helpers/cython/b.pxd' not found
当我没有 cimport
行时,cython 可以毫无问题地找到正确的目录。
关于我做错了什么的想法?我尝试按照文档中给出的示例进行设置,但没有成功。
谢谢!
我遇到了类似的问题。尝试让 cython 通过 include_dirs
访问您的 project
目录,如下所示:
cython src/*.pyx srs/*.pxd -a --cplus --include-dir ../
我有这样的目录结构:
project/lib/src/a.pyx
project/lib/src/<some other files>
project/helpers/cython/b.pyx
project/helpers/cython/b.pxd
project/helpers/cython/setup.py
project/helpers/cython/__init__.py
project/helpers/cython/setup.py
看起来像这样:
from distutils.core import setup
from Cython.Build import cythonize
setup(
ext_modules=cythonize("helpers/cython/b.pyx"),
)
在a.pyx
中,我有以下几行:
import helpers.cython.b as utils
cimport helpers.cython.b as utils_c
当,在project/lib/
,我运行
cython src/*.pyx srsc/*.pxd -a --cplus
,我收到错误消息
import helpers.cython.b as utils
cimport helpers.cython.b as utils_c
^
------------------------------------------------------------
a.pyx:29:8: 'helpers/cython/b.pxd' not found
当我没有 cimport
行时,cython 可以毫无问题地找到正确的目录。
关于我做错了什么的想法?我尝试按照文档中给出的示例进行设置,但没有成功。
谢谢!
我遇到了类似的问题。尝试让 cython 通过 include_dirs
访问您的 project
目录,如下所示:
cython src/*.pyx srs/*.pxd -a --cplus --include-dir ../