在Windows上构建64位C Python扩展Windows、Python

2023-09-07 23:03:43 作者:醉魂愁梦相伴

我问这个问题,因为我需要建立一个特定的模块(aspell_python, HTTP://wm.ite。 PL / PROJ /中的aspell-蟒蛇/ )与我的64位的Python 2.6中运行一个疗程的Windows 7(64位)的机器上工作。我也一直想知道如何加速某些功能的使用C code,所以我想使自己的外部C模块为Python的未来。

I am asking this question because I need to build a specific module (aspell_python, http://wm.ite.pl/proj/aspell-python/) to work with my 64-bit Python 2.6 which runs on a Windows 7 (64-bit of course) machine. I also always wanted to know how to speed up certain functions with C code so I'd like to make my own external C modules for Python in the future.

谁能告诉我成功地构建在C中的64位Python扩展所需的步骤?我知道Python的,我知道,C,但我不知道有关Visual Studio或Windows开发的具体事宜。我试图按照使用Visual Studio 2008中的Python网站(http://docs.python.org/extending/windows.html#building-on-windows)官方指导(这是唯一可用的商用产品在这里),但甚至连最基本的例子将无法建立。

Can anyone please tell me the steps required to successfully build a 64-bit Python extension in C? I know Python, I know C but I don't know about Visual Studio or Windows specific developer matters. I tried to follow the official guide on the Python web site (http://docs.python.org/extending/windows.html#building-on-windows) using Visual Studio 2008 (which is the only commercial product available here) but even the most basic example would fail to build.

推荐答案

我已经成功地通过了在运行以下命令Visual Studio 2008中的x64 Win64的命令提示符编译的C扩展Python的64位Windows之前扩展的源代码分发的顶级目录:

I've successfully compiled C extensions for Python on 64-bit Windows before by running the following commands from the "Visual Studio 2008 x64 Win64 Command Prompt" in the top level directory of the source distribution of the extension:

set DISTUTILS_USE_SDK=1
set MSSdk=1
python setup.py install