-
Notifications
You must be signed in to change notification settings - Fork 374
Building from Source on Windows 32 bit and 64 bit
This is the start of an unofficial guide to building Python packages on Windows. For now, it is one man's experience, in progress. With input from others, I hope it will grow into a more comprehensive guide.
By installing Windows on virtual machines, you can work from one computer, switch between 32-bit and 64-bit Windows, and easily roll back to a fresh installation of Windows if needed. This is a good way to operate.
Make disk images from installation DVDs for 32-bit and 64-bit Windows 7.
dd if=/dev/disk1 -of=disk_image.iso
Downlaod VirtualBoxVM, Oracle's software to hosting virtual machines, and start two virtual machines from the two disk images. Activate their licenses, and then save a snapshot of the fresh installation.
We must* use the 2008 release of Visual Studio to compile packages compatible with Python 2.7. We can still obtain the installer officially from Microsoft at http://go.microsoft.com/?linkid=7729279. When prompted to select optional components, you can uncheck the large Microsoft SQL Server package, which generally should not be necessary for our purposes. The installation process is straightforward.
*There are ways to use more modern releases of Visual Studio -- see this and part of this -- but I'm not interested in that here.
The easiest way to get Python is via Anaconda.
At this stage, on 32-bit Windows, some standard python installations (python setup.py install
) and conda recipes (conda build ...
) work as expected. Packages with pure C or Cython extensions should compile successfully.
Some packages have idiosyncracies, especially those that link to external libraries. The purpose of this wiki page will be to collect advice for handling difficult cases.
Note: For Python 3, use Visual Studio 2010 instead of 2008. (I have not tested this personally.)
()These instructions are gleaned from a README tucked away in the vpython-wx project. I summarize them here in the hope of making them easier to discover and easier to revise.
Install Windows SDK for Windows 7 and .NET Framework 3.5 SP1 using the install from http://www.microsoft.com/en-us/download/details.aspx?id=3138. The full package is a 2.5 GB download. Without the documentation or samples, it's a 422 MB download. Expect a long wait.
Follow these instructions to configure Visual Studio 2008 to use the Windows 7 SDK. The gist is:
- Go to Start > All Programs > Microsoft Windows SDK v7.0 > Visual Studio Registration > Windows SDK Configuration Tool
- Set the Windows 7 SDK as the current SDK for MSBuild and VCBuild.
This will update the Windows 7 SDK build environment and the Visual Studio 2008 IDE build environment to use the Windows 7 SDK headers, libraries and tools. You can also use this tool to switch it back again.
At Tools > Options > Projects and Solutions > VC++ Directories you can see what resources are invoked for Platform x64. You should see $(VCInstallDir)bin
, where $(VCInstallDir)
represents C:\Program Files (x86)\Microsoft Visual Studio 9.0\VC
.
In this VC folder there is a major error in the file vcvarsall.bat
. These lines
:x86_amd64
if not exist "%~dp0bin\x86_amd64\vcvarsx86_amd64.bat" goto missing
call "%~dp0bin\x86_amd64\vcvarsx86_amd64.bat"
must changed to
:x86_amd64
if not exist "%~dp0bin\vcvarsx86_amd64.bat" goto missing
call "%~dp0bin\vcvarsx86_amd64.bat"