Compile CPython on Windows — Unofficial Python Development (Victor's notes) documentation (original) (raw)

http://bugs.python.org/issue30350

People

People who understands these things.

Build Python on Windows

Command:

PCbuild\build.bat -e -d -p x64

Options:

Build a Windows VM

Python and Visual Studio version matrix

For Python 3.7 and later, VS 2017 is recommended (Community Edition is plenty), minimum installer options:

VS 2019 installer option:

Python version Visual Studio
Python 2.7 VS 2008 and VS 2010
Python 3.4 VS 2010
Python 3.5 and 3.6 VS 2015 (or newer)
Python 3.7 VS 2017
Python 3.8 VS 2017
Python 3.9 VS 2017
Python 3.10 (master) VS 2017

python.exe binaries delivered by python.org:

Dependencies

Python master needs binary dependencies fromgithub.com/python/cpython-bin-deps and source dependencies from github.com/python/cpython-source-deps.PCbuild\get_externals.bat, which is called automatically byPCbuild\build.bat, will take care of fetching these for you if you have any of Git, Python, NuGet, or PowerShell available.

See PCbuild\get_externals.bat to learn what to put where if you aren’t using PCbuild\build.bat.

Compile the master branch

To build the Python interpreter and all extension modules, including the ssl extension:

Requirements:

Compile 64-bit Debug Python in the command line:

PCBuild\build.bat -p x64 -d

Compile Python in the IDE: open the PCbuild\pcbuild.sln solution in Visual Studio.

See also: PCbuild\readme.txt.

Compile CPython 2.7

Python 2.7 is stuck forever on Visual Studio 2008 to not break the ABI, to keep the backward compatibility with all built extensions on the Python cheeseshop (PyPI). Obtaining VS 2008 is not nearly as simple or straightforward as it used to be and Python 2.7 is rapidly approaching the end of its support period. If you don’t absolutely have to, we recommend not bothering to set things up to build 2.7!

Compile CPython 2.7 on Windows using Visual Studio 2008 and 2010

While Visual Studio 2008 alone is enough to build a full Python 2.7 binary with all standard extension modules, the standard method used to build 2.7 now requires installing both Visual Studio 2008 and Visual Studio 2010.

Requirements:

Compile 64-bit Debug Python in the command line:

PCBuild\build.bat -p x64 -d

Compile Python in the IDE: open the PCbuild\pcbuild.sln solution in Visual Studio.

See also: PCbuild\readme.txt.

Compile CPython 2.7 on Windows using only Visual Studio 2008

Similar to the previous section, but don’t install Visual Studio 2010: only install Visual Studio 2008.

Compile 64-bit Debug Python in the command line:

PC\VS9.0\build.bat -p x64 -d -e

Compile Python in the IDE: open the PC\VS9.0\pcbuild.sln solution in Visual Studio.

See also: PC\VS9.0\readme.txt.

Note that this configuration is not well tested. Everything should work, but if it does not, please feel free to submit a patch! Also, if you use both methods and notice significant differences between them, we’d like to hear about those as well.

Windows Subsystem for Linux: WSL

Ubuntu running on Windows 10 using a thin layer to emulate the Linux kernel on top of the Windows kernel. Building Python in this environment is just the same as building on any other UNIXy system.