修改包含时,Cython错误地跳过重新编译

时间:2016-09-28 23:46:08

标签: include cython setup.py

我有一个cython文件combined.pyx,它将几个pyx文件合并在一起:

include file1.part.pyx
include file2.part.pyx
...

我还有一个setup.py:

from distutils.core import setup
from Cython.Distutils import build_ext, Extension

setup(
    ext_modules=[Extension(
        "bla.combined",
        ["src/bla/combined.pyx"])],
    requires=['Cython'],
    cmdclass={'build_ext': build_ext})

我这样跑:

python setup.py build_ext --build-lib src

我遇到的问题是,在确定是否需要再次运行时,设置仅查看combined.pyx。它没有注意file1.part.pyx,因此当我修改file1.part.pyx并重新运行设置时,没有任何反应:

 python2.7 setup.py build_ext --build-lib src
 running build_ext
 skipping 'src/bla/combined.c' Cython extension (up-to-date)

 Process finished with exit code 0

在确定是否重新编译file1.part.pyx时,如何告诉cython / python还需要检查file2.part.pyxcombined.pyx

1 个答案:

答案 0 :(得分:2)

在将cythonize提供给setup之前,修复了setup.py

固定的from distutils.core import setup from Cython.Distutils import Extension from Cython.Build import cythonize setup( ext_modules=cythonize(Extension( "bla.combined", ["src/bla/combined.pyx"])), requires=['Cython'])

div