gpt4 book ai didi

python - 使用 Windows SDK 构建 Python 包的批处理脚本

转载 作者:可可西里 更新时间:2023-11-01 09:25:48 26 4
gpt4 key购买 nike

我目前正在按照 Compiling 64-bit extension modules on Windows 中的说明在 Windows 上构建 64 位扩展.

我想编写脚本,这样我就不必每次都打开 Windows SDK 命令外壳,所以我有一个批处理文件:

setlocal EnabledDelayedExpansion
CALL "C:\Program Files\Microsoft SDKs\Windows\v7.0\Bin\SetEnv.cmd" /x64 /release
set DISTUTILS_USE_SDK=1
\path\to\python.exe \path\to\setup.py bdist --format=msi

但是,我遇到了这些错误。如何让 cl.exe 回到路径上?

Could not locate executable cl.exe
Executable cl.exe does not exist

公平警告,我对在 Windows 上构建扩展知之甚少,从这篇文章可以明显看出,所以如果有更好的方法,请提出建议。

编辑:对 SetEnv.cmd 的原始调用确实会引发错误。

The x64 compilers are not currently installed.
Please go to Add/Remove Programs to update your installation.
.
Setting SDK environment relative to C:\Program Files\Microsoft SDKs\Windows\v7.0
.
The system cannot find the batch label specified - Set_x64

根据系统路径,我使用的各种命令会出现一些错误(例如,对 git 的子进程调用找不到 git)。

CL.exe 安装在 C:\Program Files (x86)\Microsoft Visual Studio 9.0\VC\Bin\amd64\cl.exe。如果我只是通过快捷方式打开 Windows SDK Cmd Shell 并从这里按照通常的方式安装,就可以找到。

最佳答案

为了子孙后代。这按预期工作。但是,我的批处理文件中有错字。如果将第一行替换为

setlocal EnableDelayedExpansion

一切都按预期进行。问题是 !PATH!未在 SetEnv.cmd 中正确扩展。

关于python - 使用 Windows SDK 构建 Python 包的批处理脚本,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/10092287/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com