This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

classification
Title: Python does not support standalone MSVC v143 (VS 2022) Build Tools
Type: Stage: resolved
Components: Build, Windows Versions: Python 3.11
process
Status: closed Resolution: fixed
Dependencies: Superseder:
Assigned To: Nosy List: Crowthebird, kumaraditya, malin, paul.moore, steve.dower, tim.golden, zach.ware
Priority: normal Keywords: patch

Created on 2021-11-16 14:35 by Crowthebird, last changed 2022-04-11 14:59 by admin. This issue is now closed.

Pull Requests
URL Status Linked Edit
PR 29577 merged Crowthebird, 2021-11-16 14:42
Messages (10)
msg406405 - (view) Author: Jeremiah Gabriel Pascual (Crowthebird) * Date: 2021-11-16 14:35
Python does not support building with Visual Studio 2022, which is the latest officially released stable version [1].

[1] https://devblogs.microsoft.com/visualstudio/visual-studio-2022-now-available/
msg406411 - (view) Author: Jeremiah Gabriel Pascual (Crowthebird) * Date: 2021-11-16 15:30
Rephrasing: Python does not support building with standalone MSVC v143 Build Tools, which is the version of MS Build Tools under Visual Studio 2022 (version 17.0). Visual Studio 2022 is the latest stable release of Visual Studio [1].

[1] https://devblogs.microsoft.com/visualstudio/visual-studio-2022-now-available/
msg406464 - (view) Author: Ma Lin (malin) * Date: 2021-11-17 10:07
There are 5 link errors when building the PGO build.
Command: build --pgo
msg406475 - (view) Author: Steve Dower (steve.dower) * (Python committer) Date: 2021-11-17 16:17
Could you post the errors?
msg406518 - (view) Author: Ma Lin (malin) * Date: 2021-11-18 04:20
They are LNK1268 error:

LINK : fatal error LNK1268: inconsistent option 'pdbthreads:5' specified with /USEPROFILE but not with /GENPROFILE [e:\dev\cpython\PCbuild\_queue.vcx
proj]

LINK : fatal error LNK1268: inconsistent option 'pdbthreads:1' specified with /USEPROFILE but not with /GENPROFILE [e:\dev\cpython\PCbuild\_asyncio.v
cxproj]

LINK : fatal error LNK1268: inconsistent option 'pdbthreads:5' specified with /USEPROFILE but not with /GENPROFILE [e:\dev\cpython\PCbuild\_elementtr
ee.vcxproj]

LINK : fatal error LNK1268: inconsistent option 'cgthreads:8' specified with /USEPROFILE but not with /GENPROFILE [e:\dev\cpython\PCbuild\_hashlib.vc
xproj]

...
msg406635 - (view) Author: Steve Dower (steve.dower) * (Python committer) Date: 2021-11-20 00:57
Looks like the fix for those errors is to specify the arguments to the linker in PCbuild/pyproject.props

 <AdditionalOptions Condition="$(Configuration) != 'Debug'">/OPT:REF,NOICF /CGTHREADS:1 /PDBTHREADS:1 %(AdditionalOptions)</AdditionalOptions>

I don't particularly know what a good number of threads is for this. One seems safe, but maybe we can get faster builds with more?
msg407356 - (view) Author: Kumar Aditya (kumaraditya) * (Python triager) Date: 2021-11-30 09:31
I have installed VS 2022 with v143 of MSVC.
I get this error when compiling 

```console
C:\Program Files\Microsoft Visual Studio\2022\Community\MSBuild\Microsoft\VC\v170\Microsoft.CppBuild.ta 
rgets(436,5): error MSB8020: The build tools for Visual Studio 2019 (Platform Toolset = 'v142') cannot  
be found. To build using the v142 build tools, please install Visual Studio 2019 build tools.  Alternat 
ively, you may upgrade to the current Visual Studio tools by selecting the Project menu or right-click  
the solution, and then selecting "Retarget solution". [D:\cpython\PCbuild\_freeze_module.vcxproj]       
    0 Warning(s)
    1 Error(s)
```
msg407382 - (view) Author: Steve Dower (steve.dower) * (Python committer) Date: 2021-11-30 15:39
An easy workaround for people encountering this is to set the PlatformToolset environment variable to v143 before building:

$env:PlatformToolset = "v143"

(or in CMD: set PlatformToolset=v143)

Alternatively, you should be able to install the v142 toolset through VS 2022. For now, it's still the official toolset, though we'll definitely move to v143 before 3.11.
msg407384 - (view) Author: Kumar Aditya (kumaraditya) * (Python triager) Date: 2021-11-30 16:42
Thanks Steve, installing v142 is indeed my current workaround but would be
great to support v143 as it is the latest version.

On Tue, Nov 30, 2021, 21:09 Steve Dower <report@bugs.python.org> wrote:

>
> Steve Dower <steve.dower@python.org> added the comment:
>
> An easy workaround for people encountering this is to set the
> PlatformToolset environment variable to v143 before building:
>
> $env:PlatformToolset = "v143"
>
> (or in CMD: set PlatformToolset=v143)
>
> Alternatively, you should be able to install the v142 toolset through VS
> 2022. For now, it's still the official toolset, though we'll definitely
> move to v143 before 3.11.
>
> ----------
>
> _______________________________________
> Python tracker <report@bugs.python.org>
> <https://bugs.python.org/issue45816>
> _______________________________________
>
msg407599 - (view) Author: Steve Dower (steve.dower) * (Python committer) Date: 2021-12-03 19:47
New changeset d9301703fb1086cafbd730c17e3d450a192485d6 by Crowthebird in branch 'main':
bpo-45816: Support building with VS 2022 (v143 toolset) on Windows (GH-29577)
https://github.com/python/cpython/commit/d9301703fb1086cafbd730c17e3d450a192485d6
History
Date User Action Args
2022-04-11 14:59:52adminsetgithub: 89974
2021-12-03 19:48:45steve.dowersetstatus: open -> closed
resolution: fixed
stage: patch review -> resolved
2021-12-03 19:47:48steve.dowersetmessages: + msg407599
2021-11-30 16:42:42kumaradityasetmessages: + msg407384
2021-11-30 15:39:25steve.dowersetmessages: + msg407382
2021-11-30 09:31:06kumaradityasetnosy: + kumaraditya
messages: + msg407356
2021-11-20 00:57:16steve.dowersetmessages: + msg406635
2021-11-18 04:20:36malinsetmessages: + msg406518
2021-11-17 16:17:03steve.dowersetmessages: + msg406475
2021-11-17 10:07:30malinsetnosy: + malin
messages: + msg406464
2021-11-16 15:30:18Crowthebirdsettitle: Python does not support building with Visual Studio 2022 -> Python does not support standalone MSVC v143 (VS 2022) Build Tools
nosy: + paul.moore, tim.golden, zach.ware, steve.dower

messages: + msg406411

components: + Windows
2021-11-16 14:42:29Crowthebirdsetkeywords: + patch
stage: patch review
pull_requests: + pull_request27821
2021-11-16 14:35:04Crowthebirdcreate