Python and C++ on Windows10
I’ve installed many things, now you don’t have to…

I recently went through a painful exercise which underlined why, before Windows 10 with WSL1+, MacOS “just works”. I didn’t enjoy this experience, so here I am cutting through the unanswered questions on stackoverflow, quora questions and yes, turning it off and on again.
This started with the ‘simple’ need to get pre-commit hooks working in vscode. Sure, I’ve got 56 versions of Python running on my Windows 10, but who doesn’t, right? After making it work on my Windows 10 VM, I had to make it repeatable — so here we are.
Install Stuff
You’re going to need Visual Studio Build Tools 2019 from here.
The stub installer is 3.6mb, the whole tools package is the size of Luxembourg; classic Microsoft. From the installer, you’ll need to select ‘Workloads’: C++ Build Tools.
Ensure this includes a version of the Windows 10 SDK (10.0.18362.0 as I type). Helpfully, the Build Tools do very little in the way of Environment Variables, or playing nicely with cmd.exe or Powershell, so if you’re trying to trying to integrate the tooling with vsCode or any other command-line functionality.. well.. good luck! (luck included in sections below).
Install Python. Ideally a 64-bit version. My requirements are ‘simple’ so I stripped out 55 other versions and just have Python 3.8 installed. Remember that Windows favours %PATH% Environment Variables both for User and System, and I’ll capture this below. There’s further pain if you’re compiling between x64 architecture and x86 Python, which I’ve ignored/dodged as much as possible, because I’m an idiot.
Environment Variables
Now you’ve got your tools installed, time to make them to talk to one another, via Windows Environment variables; so check PATH, (LIB and INCLUDE (create if missing)) as follows, ensuring that LIB points towards your Windows10SDK ucrt and um x64 (and x86 if required) folders.
LIB
C:\Program Files (x86)\Windows Kits\10\Lib\10.0.XXXXX.0\ucrt\x64;
C:\Program Files (x86)\Windows Kits\10\Lib\10.0.XXXXX.0\um\x64
INCLUDE
C:\Program Files (x86)\Windows Kits\10\Include\10.0.XXXXX.0\ucrt;
C:\Program Files (x86)\Windows Kits\10\Include\10.0.XXXXX.0\um;
C:\Program Files (x86)\Windows Kits\10\Include\10.0.XXXXX.0\shared
USER Path
%PYTHON_HOME%\;
%PYTHON_HOME%\Scripts\;
C:\Program Files (x86)\Microsoft Visual Studio 14.0\vc\bin;
C:\Users\%USERNAME%\AppData\Local\Microsoft\WindowsApps;
C:\Program Files (x86)\Windows Kits\10\Include;
C:\Program Files (x86)\Microsoft Visual Studio\2019\BuildTools\Common7\Tools;
C:\Program Files (x86)\Microsoft Visual Studio\Shared;
C:\Program Files (x86)\Windows Kits\10\Include\10.0.XXXXX.0\ucrt;
C:\Program Files (x86)\Windows Kits\10\bin\10.0.XXXXX.0\ucrt;
SYSTEM Path
C:\Program Files (x86)\Microsoft Visual Studio 14.0\vc\bin\;
C:\Python38\;
C:\Python38\Scripts\;
%SystemRoot%\system32;
%SystemRoot%;
%SystemRoot%\System32\Wbem;
%SYSTEMROOT%\System32\WindowsPowerShell\v1.0\;
C:\Program Files\Amazon\cfn-bootstrap\;
C:\Program Files\Amazon\AWSCLI\bin\;
C:\Program Files\Amazon\AWSCLI;
C:\Program Files\Java\jdk1.8.0_211\bin;
C:\Program Files (x86)\Microsoft Visual Studio\2019\BuildTools;
C:\Program Files (x86)\Windows Kits\10\Include\10.0.XXXXX.0\ucrt;
C:\Program Files (x86)\Windows Kits\10\Include\10.0.XXXXX.0\um;
C:\Program Files\nodejs\;
C:\Program Files (x86)\Microsoft Visual Studio\2019\BuildTools\Common7\Tools;
C:\Program Files (x86)\Microsoft Visual Studio\Shared;
C:\Program Files (x86)\Windows Kits\10\Include\10.0.XXXXX.0\shared;
C:\Program Files (x86)\Windows Kits\10\bin\10.0.XXXXX.0\ucrt;
Visual Studio Tools inside Terminal
VS bundles vcvarsall.bat with switches for your environment (x64, x86; both; neither, etc. ) Full details here.
Broadly, to get your Visual Studio tools working in your terminal (I prefer Powershell because of plugins like posh-git, pscx, others), you need to pull in your VS variables, edit your $profile with the following script so it loads every time:
pushd "C:\Program Files (x86)\Microsoft Visual Studio\2019\BuildTools\VC\Auxiliary\Build\"cmd /c "vcvars64.bat&set" |foreach {if ($_ -match "=") {$v = $_.split("="); set-item -force -path "ENV:\$($v[0])" -value "$($v[1])"}}popdWrite-Host "`nVisual Studio Command Prompt variables set." -ForegroundColor Yellow
For cmd, the following ‘should’ work
%comspec% /k ""C:\Program Files (x86)\Microsoft Visual Studio\2019\BuildTools\VC\Auxiliary\Build\vcvars64.bat""
Now when you run your pre-commit hooks, any additional pip packages should now install properly.