Script package to create Python package using Windows SDK

I am currently building 64-bit extensions on Windows by following the instructions in Compiling 64-bit Extensions on Windows .

I want a script, so I don't have to open the Windows SDK command shell every time I want to do this, so I have a batch file:

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

      

However, I am getting these errors. How to get back cl.exe

on track?

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

      

Fair warning, I don't know much about creating extensions on Windows as you can see from this post, so please suggest a better way if there is one.

EDIT: The original call to SetEnv.cmd throws an error.

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

      

Then there are some errors for the various commands I use based on the system path (like calls to a subprocess on git that git can't find).

CL.exe is installed here on C:\Program Files (x86)\Microsoft Visual Studio 9.0\VC\Bin\amd64\cl.exe

. If I just open the Windows SDK Cmd shell with a shortcut and set the normal path from here, it is found.

+3


source to share


3 answers


For posterity. This works as expected. However, there is a typo in my batch file. If you replace the first line with

setlocal EnableDelayedExpansion

      



Everything works as expected. The problem is that! WAY! has not been properly expanded in SetEnv.cmd.

+3


source


My solution to this problem is to use a Python script - it's much easier for me than a Windows batch script. You can use the subprocess module to call other programs, and it will keep the environment variables intact unless you explicitly change them.



BTW, Cython isn't the only way to compile Python to EXE. You can use a tool like cz_freeze , which I think is a bit simpler if you don't need other Cython features.

0


source


If Visual Studio is installed on your system, add a step to your script package to run vcvarsall.bat

. For ex, if Visual Studio 2010 is installed, this batch file must be present in

"C:\Program Files (x86)\Microsoft Visual Studio 10.0\VC\vcvarsall.bat",

      

or ever drive you installed Visual Studio unless you overridden the default install location.

0


source







All Articles