1

我是 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,但这种情况没有发生。

4

2 回答 2

1

最后,我能够为 win64 构建扩展。显然,如果你有 VC 2010 express,你可以调整 disuilts 以使用 msvc9compiler 编译模块。详细信息可以在这里找到。非常感谢 nukeitdotorg 的人提出这个问题,也感谢 JF Sebastian 的提示。

于 2011-03-15T04:46:31.667 回答
0

Did you try to compile it with

python setup.py build --compiler=mingw32

?

于 2011-03-20T22:29:45.617 回答