Revision 32 as of 2013-10-06 20:26:07

Clear message

How to build Python 2.7.5 using Visual Studio 2012 Express on Windows 8 64-bit

My goal with these instructions is to produce a DEBUG build on x86_64 (AMD64 or x64). I'm working on a Python extension that is currently crashing on Windows, but work fine in Linux. I will be building debug version of Numpy and Matplotlib after the DEBUG version of Python is created with these instructions.

Shameless Plug: I'm the author of the C++ & Python module Nsound


References:

Many thanks to sebastien.sable for their page VS2010, which I followed to create these instructions.


Prepare Environment

1. Create a directory to store the Python source tree and dependencies, I called mine python_build.

2. Download Python 2.7.5 source from python.org and unzip it to python_build

3. Download and install an SVN command-line client (Try SlickSVN)

4. Download and install Perl64

5. Download and install Visual Studio Express 2012

Test Environment

1. Open a shell

2. Bring in the msvc compiler environment for x64 by doing:

3. Try running the svn client: 'svn --version':

4. Try running perl: 'perl --version'


Download dependencies

Use the buildbot tools to grab the external dependencies:


Patch External Dependencies

Tcl

Tk


Compile External Dependencies


Manually Build Openssl 1.0.1e

1. Download and unzip openssl-1.0.1e.tar.gz

2. Configure openssl:

3. IMPORTANT, I guess perl creates "symobolic" links inside the include directory which the openssl build environment understands. However Visual Studio doesn't understand them:

4. Build with these commands:


Convert Visual Studio 2008 Solution

1. Open Python-2.7.5\PCbuild\pcbuild.sln with Visual Studio 2012 Express

2. Click OK to perform the "One-Way" upgrade on all the project files.

3. Immediately close Visual Studio 2012 Express

Patch Project Files

See this diff file: PCbuild_patches.txt

I've also just zipped up the project files so you can just unzip them into PCbuild: python-2.7.5-amd64-pcbuild.zip


Build Python

1. Patch Python prevent manifest files from being embedded:

2. Open Python-2.7.5\PCbuild\pcbuild.sln

3. Select 'DEBUG' and 'x64' For the configuration.

4. Click 'Build' -> 'Build Solution' (F7):


Testing Python

FIXME

Install Python

Now that Python has been built, I will use the script below to install executables and libraries under one directory tree, as if it were installed by a self-installer. Building the msi self installer won't work in Visual Studio Express, in addition, the MSI tool won't package up any of the debug libraries.

1. Save this script to your build directory: manual_install.py

2. Run the script from the build directory:

3. Test that the Tkinter module can be imported:

SUCCESS!

Install Numpy & Matplotlib in Debug Mode

Setup Environment

1. Save this text to 'benv64_d.bat':

2. Open a command prompt and call 'benv64_d.bat':

Installing Numpy

1. Download Numpy-1.7.1.zip

2. Build and install with this command:

Verify Numpy Installed

1. Try to import numpy:

SUCCESS!

Build & Install FreeType

1. Download and unzip freetype-2.5.0.1

2. Open 'freetype-2.5.0.1\builds\win32\vs2010\freetype.sln`

3. Select DEBUG and add an 'x64' configuration

4. Build Solution.

5. "Install" freetype to our debug install

Build & Install zlib

1. Download and unzip zlib-1.2.8.tar.gz

2. Open zlib-1.2.8\contrib\vstudio\vc11\zlibvc.sln with Visual Studio 2012 Express

3. Right click on the 'zlibstat' project and click on 'Build'

4. Copy to install directory:

Build & Install libpng

1. Download lpng166.zip

2. Edit the file lpng166\projects\vstudio\zlib.props:

3. Open solution lpng166\projects\vstudio\vstudio.sln

4. Let Visual Studio 2012 update the project files.

5. Adjust project for 64-bit & debug mode

5.1 Right clik on 'libpng' project, select 'Properties'

5.2 Change project type from DLL to static .lib

5.3 Select DEBUG build

5.4 Click on 'win32' and add a new 'x64' configuration

6. Right click on 'libpng' and click on 'Build'

Installing Matplotlib

1. Download and unzip matplotlib-1.3.0


FIXME: Currently need to download and build freetype, zlib, and libpng first!


2. To compile against TK, update the INCLUDE shell variable so matplotlib can find the header, from the python_build dir do:

3. Build and install:

Unable to edit the page? See the FrontPage for instructions.