Is there something I can do, (either by setting an environment variable, running a command before running Python, or adding some code to my setup.py) to tell Python I want setup.py to use a different version of the compiler.
I can see that distutils on this Windows machine (a Github runner on Azure) is using version 14.35.32215 of the compiler and linker.
>>> import distutils.ccompiler as cc
>>> compiler = cc.new_compiler()
>>> compiler.initialize()
>>> compiler.cc
'C:\\Program Files\\Microsoft Visual Studio\\2022\\Enterprise\\VC\\Tools\\MSVC\\14.35.32215\\bin\\HostX86\\x64\\cl.exe'
>>> compiler.linker
'C:\\Program Files\\Microsoft Visual Studio\\2022\\Enterprise\\VC\\Tools\\MSVC\\14.35.32215\\bin\\HostX86\\x64\\link.exe'
I can also see that this machine has multiple compiler versions available.
C:\Users\fyellin>dir "C:\Program Files\Microsoft Visual Studio\2022\Enterprise\VC\Tools\MSVC\"
Volume in drive C is Windows
...
12/20/2023 08:29 AM <DIR> .
10/10/2023 10:41 PM <DIR> ..
10/10/2023 11:04 PM <DIR> 14.16.27023
10/10/2023 11:05 PM <DIR> 14.29.30133
10/10/2023 10:47 PM <DIR> 14.35.32215
10/10/2023 11:09 PM <DIR> 14.37.32822
When I look at the file msvccompiler.py, I find myself completely lost as to how it found this particular MSVC directory and why it decided to use version 14.35.32215 in this directory. It seems to go deeper into Windows internals than I expected.
Is there some way of changing the compiler version? Where does this version number come from?