【发布时间】:2018-05-01 20:47:20
【问题描述】:
我的项目目录结构如下:
.
├── Makefile
├── pxd
├── pyx
│ ├── Landscaping.pyx
│ ├── Shrubbing.pxd
│ └── Shrubbing.pyx
└── setup.py
但是,如果我将Shrubbing.pxd 移动到其他任何地方,例如,移动到pxd/,我会收到以下错误:
Error compiling Cython file:
------------------------------------------------------------
...
import pyx.Shrubbing
cimport Shrubbing
^
------------------------------------------------------------
pyx/Landscaping.pyx:2:8: 'Shrubbing.pxd' not found
Error compiling Cython file:
------------------------------------------------------------
...
import pyx.Shrubbing
cimport Shrubbing
cdef Shrubbing.Shrubbery sh
^
------------------------------------------------------------
这很奇怪,因为在 setup.py 我有:
from distutils.core import setup, Extension
from Cython.Build import cythonize
setup(ext_modules=cythonize([
Extension(
'pyx.Landscaping',
sources=["pyx/Landscaping.pyx"],
include_dirs=['pxd']), # <-- HERE
Extension('pyx.Shrubbing', sources=["pyx/Shrubbing.pyx"])
]))
明确指定Shrubbing.pxd 的新目录。
源文件都很短,但为了避免这篇文章混乱,我将发布一个存储库的链接:https://github.com/lobachevzky/landscaping
感谢您的帮助。
【问题讨论】:
标签: cython include-path