2016-09-28 65 views
1

我有一个用Cython文件combined.pyx,它把多个PYX时跳过错误重新编译文件一起:用Cython修改包括

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 

如何判断用Cython /蟒蛇,它需要同时检查file1.part.pyxfile2.part.pyx确定是否当重新编译combined.pyx

回答

1

修复方法是在将其扩展到setup之前将其扩展为cythonize

固定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'])