cython setup.py 给出 .o 而不是 .dll

发布于 2024-10-21 11:30:43 字数 1254 浏览 2 评论 0原文

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

I am a newbie to cython, so pardon me if I am missing something obvious here. I am trying to build c extensions to be used in python for enhanced performance. I have fc.py module with a bunch of function and trying to generate a .dll through cython using dsutils and running on win64:

c:\python26\python c:\cythontest\setup.py build_ext --inplace

I have the dsutils.cfg in C:\Python26\Lib\distutils. As required the disutils.cfg has the following config settings:

[build]
compiler = mingw32

My startup.py looks like this:

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
)

This is what the command line outputs looks like :

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

I have latest version mingw for target/host amdwin64 type builds. I have the latest version of cython for python26 for win64. Cython does give me an fc.c without errors, only a few warning for type conversions, which I will handle once I have it right. Further it produces fc.def an fc.o files Instead of giving a .dll. I get no errors. I find on threads that it will create the .so or .dll automatically as required, which is not happening.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

挽心 2024-10-28 11:30:43

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

Finally, I was able to build extension for win64. Apparently, if you have VC 2010 express, you can tweak the disuilts to use msvc9compiler for compiling the module. The details can be found here. Many thanks to the guys at nukeitdotorg for putting up this, and also to J.F. Sebastian for his tips.

向日葵 2024-10-28 11:30:43

你尝试用 编译它吗

python setup.py build --compiler=mingw32

Did you try to compile it with

python setup.py build --compiler=mingw32

?

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文