[Python-Dev] Compile Python on Windows (OpenSSL)

Steve Dower Steve.Dower at microsoft.com
Tue Jan 13 23:18:40 CET 2015

Victor Stinner wrote:
> To compile Python on Windows, there are a few information in the Developer
> Guide:
> https://docs.python.org/devguide/setup.html#windows-compiling

I'm sorry, I've been slack and haven't updated this guide with the new changes. That said, there aren't that many changes to what is already in the guide - mostly new information that I'd like to add. I'll try and get something written up this week.

> Python 3.5 now requires Visual Studio 2010 *SP1*, or newer Visual Studio:
> http://bugs.python.org/issue22919#msg233637

Technically, Python 3.5 requires Visual Studio 2015, as the decision was made to move to the newer compiler for this release (and make whatever schedule changes were necessary to ensure everything will be available - it was on python-dev, though I don't have links handy).

It will still open and build with Visual Studio 2010 SP1 or later, however, buildbots should move to VS 2015 as they can, since that will be the official toolset. (I'm not pushing too hard until 2015 RC is released, since that's when Microsoft start supporting upgrades to newer versions. We do have one buildbot that's already using VS 2015 Preview though.)

> I found PCbuild\readme.txt which is not mentionned in the devguide :-/
> https://hg.python.org/cpython/file/56f717235c45/PCbuild/readme.txt
> (at least not on the Windows section of the setup page)

That should help, since I've updated that file. Though it's a little ahead of its time still, so a lot of the instructions do not yet have to be followed strictly, and I consider being able to build with VS 2010 SP1 a feature that we want to keep supporting for now while we transition.

> I found some clues to build OpenSSL to be able to build the Python ssl module,
> but I still have issues.
> Is there a more complete documentation?
> I found how to install svn.exe, perl.exe and nasm.exe, but not how to install
> nmake.exe. I don't know the command to build OpenSSL.

You don't require perl, you don't have to install nasm or build OpenSSL. Calling PCBuild/get_externals.bat will get nasm and the OpenSSL sources, and PCBuild/build.bat will rebuild OpenSSL as necessary.

nmake is part of Visual C++, so it should be available once you have your path configured (PCBuild/env.bat).

So a complete guide to check out and build Python on Windows should be:

1. Install SVN and put it on your path
2. Run PCBuild\get_externals.bat (this is the only step that requires SVN)
3. Install Visual Studio 2010 SP1 or later
4. Open PCBuild\pcbuild.sln in Visual Studio *or* run PCBuild\build.bat from the command line.

> I don't care of building OpenSSL, my goal is only to build the Python ssl
> module. Is there a way to install a development version of OpenSSL (.lib files
> if I remember correctly) from an installer/binary?

If you can find ssleay.lib and libeay.lib somewhere, they'll probably work. If not, those projects are in PCBuild and will be built automatically (if necessary) when you build _ssl.vcxproj or _hashlib.vcxproj.


> My draft notes:
> +Compile CPython on Windows
> +==========================
> +
> +To build the Python ssl extension:
> +
> +Need:
> +
> +* Visual Studio 2010 SP1 or newer
> +* CPython source code (default branch: 3.5)
> +* perl binary: ActivePerl
> +* svn binary, ex: SilkSVN
> +* nasm and nmake binaries: compile NASM (install the binary doesn't
> install nmake)
> +
> +Read PCbuild/readme.txt.
> +
> +* Build Python (in debug mode)
> +* Type: PCbuild\get_externals.bat
> +* Type: PCbuild\win32\python_d.exe PCbuild\prepare_ssl.py
> externals\openssl-1.0.1j
> Victor

More information about the Python-Dev mailing list