我是 cython 的新手,如果我在这里遗漏了一些明显的东西,请原谅我。我正在尝试构建 c 扩展以在 python 中使用以增强性能。我有具有一堆功能的 fc.py 模块,并尝试使用 dsutils 通过 cython 生成 .dll 并在 win64 上运行:
c:\python26\python c:\cythontest\setup.py build_ext --inplace
我在 C:\Python26\Lib\distutils 中有 dsutils.cfg。根据需要, disutils.cfg 具有以下配置设置:
[build]
compiler = mingw32
我的 startup.py 看起来像这样:
from distutils.core import setup
from distutils.extension import Extension
from Cython.Distutils import build_ext
ext_modules = [Extension('fc', [r'C:\cythonTest\fc.pyx'])]
setup(
name = 'FC Extensions',
cmdclass = {'build_ext': build_ext},
ext_modules = ext_modules
)
这是命令行输出的样子:
C:\python26\python C:\cythontest\setup.py build_ext --inplace
running build_ext
cythoning C:\cythonTest\fc.pyx to C:\cythonTest\fc.c
building 'FC' extension
C:\MinGW\bin\gcc.exe -mno-cygwin -mdll -O -Wall -Ic:\python26\include -Ic:\pytho
n26\PC -c C:\cythonTest\fc.c -o c:\cythontest\fc.o
我有用于目标/主机 amdwin64 类型构建的最新版本 mingw。我有最新版本的 cython for python26 for win64。Cython 确实给了我一个没有错误的 fc.c,只有一些类型转换的警告,一旦我做对了,我会处理的。此外,它生成 fc.def 和 fc.o 文件,而不是提供 .dll。我没有错误。我在线程上发现它会根据需要自动创建 .so 或 .dll,但这种情况没有发生。