Skip to content

Compile Python on Windows 11 w/Visual Studio 2019

I was extremely curious about how to build a version of Python 3.9.x {x64/x86} on a Windows 10/11 machine for the longest time. Finally, I've found an hour to learn how to pursue this system engineering topic (System build process aka Build Engineering) on compiling my unique version of Python 3.9.x on windows.

Thanks to All the Opensource Contributors on writing scripts to automate most of this process, I was able to follow instructions when building a version of Python 3.9.x.

First, one must install the following tools from Microsoft: Visual Studio 2019.

Visual Studio

We then would require the necessary packages in our VS 2019.

VS Packages

After installing Additional Packages for VS 2019, we would now need to use the CMD Prompt to generate some additional files after downloading the tgz compressed file python v.3.9.10 source code from Python.org. After decompressing this tarball file, we now have Python-3.9.10 Directory, where all the files have been extruded from this tarball.

compiling AMD x64 bit version

There are options when comes to compiling, I took the recommended approach. It is likely not to follow recommended instructions when compiling initially, but on generating a debug version first to test a custom compiled version of Python v3.9.10 is appropriate. The goal was to test whether SSL was included upon compiling.

build.bat -e -d -p x64
build.bat -e -d -p x86
build.bat -e -p x86
build.bat -e -p x64

As shown above, one can certainly build the debug version to test then build the actual non-debug version of Python.

Once the above process has been completed, we must then look for a file called pcbuild.sln to compile either the 32 or 64 bit version of our python software once we had executed the build.bat configuration file.

BInary python Debug

Once the final process has been completed, we can execute the python_d.exe file in our CMD prompt to see if it was compiled successfully. it is now working perfectly, we can then reconfigure the build.bat switch to remove the -d switch and recompiled a final product of python.exe.

Leave a Reply

Your email address will not be published.