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: Using VS2019 to automatically build Python3 and it failed to build
Type: compile error Stage: resolved
Components: Build, Windows Versions: Python 3.6
process
Status: closed Resolution: out of date
Dependencies: Superseder:
Assigned To: Nosy List: Lin, iritkatriel, paul.moore, steve.dower, tim.golden, zach.ware
Priority: normal Keywords:

Created on 2020-03-13 03:46 by Lin, last changed 2022-04-11 14:59 by admin. This issue is now closed.

Files
File name Uploaded Description Edit
build.log Lin, 2020-03-13 03:46 Python3_vs2019_build.log
Messages (7)
msg364072 - (view) Author: Lin Gao (Lin) Date: 2020-03-13 03:46
We (the MSVC ++ team) is trying to use VS2019 to replace VS2017 to automatically build Python3(branch 3.6)on Windows. First build failed with error MSB8036: The Windows SDK version 10.0.10586.0 was not found. So we modified the build command line to 'build -e -r -v "/p:PlatformToolset=v142" "/p:WindowsTargetPlatformVersion=10.0.18362.0"' , error MSB8036 has disappeared, but triggers another error 'C:\Program Files (x86)\Windows Kits\10\Include\10.0.18362.0\um\winnt.h(173,1): fatal error C1189: #error:  "No Target Architecture"'. After investigation, this error is reported whenever the F:\gitP\python\cpython\Modules\_io\_iomodule.c file is compiled. And this error will disappear when we add #include <windows.h> to the _iomodule.c file.But when I rebuilt again, I encountered many errors.

Does Python3 currently support VS2019 automated builds? If support Could you please help to take a look? Thank you so much!

Here is repro steps:
1. git clone -b "3.6" -c core.autocrlf=true https://github.com/python/cpython.git F:\gitP\python\cpython
2. Open a VS 2019 16.4.5 x86 command prompt and browse to F:\gitP\python\cpython
3. checkout the revision to f1f9c0c.
4. Add #include <windows.h> to the _iomodule.c.
5. cd F:\gitP\python\cpython\PCBuild
6. devenv /upgrade pcbuild.sln
7. build -e -r -v "/p:PlatformToolset=v142" "/p:WindowsTargetPlatformVersion=10.0.18362.0"

Error:
19>LINK : fatal error LNK1181: cannot open input file 'Microsoft.VisualStudio.Setup.Configuration.Native.lib' 
40>C:\Program Files (x86)\Windows Kits\10\Include\10.0.18362.0\um\winnt.h(20779): error C2059: syntax error: 'constant' [F:\gitP\python\cpython\PCbuild\tk.vcxproj]
    40>C:\Program Files (x86)\Windows Kits\10\Include\10.0.18362.0\um\winnt.h(20791): error C2059: syntax error: '}' [F:\gitP\python\cpython\PCbuild\tk.vcxproj]
    40>C:\Program Files (x86)\Windows Kits\10\Include\10.0.18362.0\um\winnt.h(20792): error C2059: syntax error: '}' [F:\gitP\python\cpython\PCbuild\tk.vcxproj]
    40>C:\Program Files (x86)\Windows Kits\10\Include\10.0.18362.0\um\winnt.h(20793): error C2143: syntax error: missing '{' before '*' [F:\gitP\python\cpython\PCbuild\tk.vcxproj]
    40>C:\Program Files (x86)\Windows Kits\10\Include\10.0.18362.0\um\winnt.h(20801): error C2061: syntax error: identifier 'IMAGE_POLICY_ENTRY' [F:\gitP\python\cpython\PCbuild\tk.vcxproj]
    40>C:\Program Files (x86)\Windows Kits\10\Include\10.0.18362.0\um\winnt.h(20802): error C2059: syntax error: '}' [F:\gitP\python\cpython\PCbuild\tk.vcxproj]
    40>C:\Program Files (x86)\Windows Kits\10\Include\10.0.18362.0\um\winnt.h(20803): error C2143: syntax error: missing '{' before '*' [F:\gitP\python\cpython\PCbuild\tk.vcxproj]
    40>C:\Program Files (x86)\Windows Kits\10\Include\10.0.18362.0\um\processthreadsapi.h(1032): error C2059: syntax error: 'constant' [F:\gitP\python\cpython\PCbuild\tk.vcxproj]
    40>C:\Program Files (x86)\Windows Kits\10\Include\10.0.18362.0\um\processthreadsapi.h(1034): error C2059: syntax error: '}' [F:\gitP\python\cpython\PCbuild\tk.vcxproj]
    40>C:\Program Files (x86)\Windows Kits\10\Include\10.0.18362.0\um\processthreadsapi.h(1151): error C2059: syntax error: 'constant' [F:\gitP\python\cpython\PCbuild\tk.vcxproj]
    40>C:\Program Files (x86)\Windows Kits\10\Include\10.0.18362.0\um\processthreadsapi.h(1153): error C2059: syntax error: '}' [F:\gitP\python\cpython\PCbuild\tk.vcxproj]
40>C:\Program Files (x86)\Windows Kits\10\Include\10.0.18362.0\um\processthreadsapi.h(1032): error C2059: syntax error: 'constant' [F:\gitP\python\cpython\PCbuild\tk.vcxproj]
    40>C:\Program Files (x86)\Windows Kits\10\Include\10.0.18362.0\um\processthreadsapi.h(1034): error C2059: syntax error: '}' [F:\gitP\python\cpython\PCbuild\tk.vcxproj]
    40>C:\Program Files (x86)\Windows Kits\10\Include\10.0.18362.0\um\processthreadsapi.h(1151): error C2059: syntax error: 'constant' [F:\gitP\python\cpython\PCbuild\tk.vcxproj]
    40>C:\Program Files (x86)\Windows Kits\10\Include\10.0.18362.0\um\processthreadsapi.h(1153): error C2059: syntax error: '}' [F:\gitP\python\cpython\PCbuild\tk.vcxproj]
40>NMAKE : fatal error U1077: '"C:\Program Files (x86)\Microsoft Visual Studio\2019\Enterprise\VC\Tools\MSVC\14.24.28314\bin\HostX86\x86\cl.EXE"' : return code '0x2' [F:\gitP\python\cpython\PCbuild\tk.vcxproj]
40>NMAKE : fatal error U1077: 'xcopy' : return code '0x4' [F:\gitP\python\cpython\PCbuild\tk.vcxproj]
         Stop.
    40>C:\Program Files (x86)\Microsoft Visual Studio\2019\Enterprise\MSBuild\Microsoft\VC\v160\Microsoft.MakeFile.Targets(44,5): error MSB3073: The command "setlocal [F:\gitP\python\cpython\PCbuild\tk.vcxproj]
C:\Program Files (x86)\Microsoft Visual Studio\2019\Enterprise\MSBuild\Microsoft\VC\v160\Microsoft.MakeFile.Targets(44,5): error MSB3073: if not exist "F:\gitP\python\cpython\externals\tcltk\bin\tk86t.dll" goto build [F:\gitP\python\cpython\PCbuild\tk.vcxproj]
C:\Program Files (x86)\Microsoft Visual Studio\2019\Enterprise\MSBuild\Microsoft\VC\v160\Microsoft.MakeFile.Targets(44,5): error MSB3073: if not exist "F:\gitP\python\cpython\externals\tcltk\include\tk.h" goto build [F:\gitP\python\cpython\PCbuild\tk.vcxproj]
C:\Program Files (x86)\Microsoft Visual Studio\2019\Enterprise\MSBuild\Microsoft\VC\v160\Microsoft.MakeFile.Targets(44,5): error MSB3073: if not exist "F:\gitP\python\cpython\externals\tcltk\lib\tk86t.lib" goto build [F:\gitP\python\cpython\PCbuild\tk.vcxproj]
C:\Program Files (x86)\Microsoft Visual Studio\2019\Enterprise\MSBuild\Microsoft\VC\v160\Microsoft.MakeFile.Targets(44,5): error MSB3073: if not exist "F:\gitP\python\cpython\externals\tcltk\lib\tk8.6" goto build [F:\gitP\python\cpython\PCbuild\tk.vcxproj]
C:\Program Files (x86)\Microsoft Visual Studio\2019\Enterprise\MSBuild\Microsoft\VC\v160\Microsoft.MakeFile.Targets(44,5): error MSB3073: goto :eof [F:\gitP\python\cpython\PCbuild\tk.vcxproj]
C:\Program Files (x86)\Microsoft Visual Studio\2019\Enterprise\MSBuild\Microsoft\VC\v160\Microsoft.MakeFile.Targets(44,5): error MSB3073: :build [F:\gitP\python\cpython\PCbuild\tk.vcxproj]
C:\Program Files (x86)\Microsoft Visual Studio\2019\Enterprise\MSBuild\Microsoft\VC\v160\Microsoft.MakeFile.Targets(44,5): error MSB3073: set VCINSTALLDIR=C:\Program Files (x86)\Microsoft Visual Studio\2019\Enterprise\VC\ [F:\gitP\python\cpython\PCbuild\tk.vcxproj]
C:\Program Files (x86)\Microsoft Visual Studio\2019\Enterprise\MSBuild\Microsoft\VC\v160\Microsoft.MakeFile.Targets(44,5): error MSB3073: cd /D "F:\gitP\python\cpython\externals\tk-8.6.6.0\win" [F:\gitP\python\cpython\PCbuild\tk.vcxproj]
C:\Program Files (x86)\Microsoft Visual Studio\2019\Enterprise\MSBuild\Microsoft\VC\v160\Microsoft.MakeFile.Targets(44,5): error MSB3073: nmake /nologo -f makefile.vc RC=rc MACHINE=IX86 OPTS=msvcrt BUILDDIRTOP="Release" TCLDIR="F:\gitP\python\cpython\externals\tcl-core-8.6.6.0" INSTALLDIR="F:\gitP\python\cpython\externals\tcltk"  all [F:\gitP\python\cpython\PCbuild\tk.vcxproj]
C:\Program Files (x86)\Microsoft Visual Studio\2019\Enterprise\MSBuild\Microsoft\VC\v160\Microsoft.MakeFile.Targets(44,5): error MSB3073: nmake /nologo -f makefile.vc RC=rc MACHINE=IX86 OPTS=msvcrt BUILDDIRTOP="Release" TCLDIR="F:\gitP\python\cpython\externals\tcl-core-8.6.6.0" INSTALLDIR="F:\gitP\python\cpython\externals\tcltk"  install-binaries install-libraries [F:\gitP\python\cpython\PCbuild\tk.vcxproj]
C:\Program Files (x86)\Microsoft Visual Studio\2019\Enterprise\MSBuild\Microsoft\VC\v160\Microsoft.MakeFile.Targets(44,5): error MSB3073: " exited with code 2. [F:\gitP\python\cpython\PCbuild\tk.vcxproj]
msg364110 - (view) Author: Zachary Ware (zach.ware) * (Python committer) Date: 2020-03-13 16:47
(FTR, removing yourself from the "nosy list" means you won't get any responses to your issue, so I've added you back :))

This appears to be a problem with building Tcl/Tk.  If you don't need the tkinter module, you can try adding the `--no-tkinter` flag to your `build.bat` invocation.  We have an open issue to upgrade Tcl/Tk to 8.6.10 (which is more likely to support VS2019) in Python 3.9, but that is not going to be backported to 3.6, which is now in security-fix-only mode.
msg364298 - (view) Author: Lin Gao (Lin) Date: 2020-03-16 08:57
Hi,

Thanks for your reply and info!

I've tried to use you provided --no-tkinter to re-build python3.6. And now There is only one error left. Have you encountered this problem? 

build -e -r --no-tkinter -v "/p:PlatformToolset=v142" "/p:WindowsTargetPlatformVersion=10.0.18362.0"

Error:
LINK : fatal error LNK1181: cannot open input file 'Microsoft.VisualStudio.Setup.Configuration.Native.lib' [F:
       \gitP\python\cpython\PCbuild\_distutils_findvs.vcxproj]
msg364409 - (view) Author: Steve Dower (steve.dower) * (Python committer) Date: 2020-03-17 10:56
Hi Lin, please look me up on Teams and we can chat about this. I haven't heard about this effort and I'd love to know what you're working on.

---

The last error is because the VS Setup team has never updated their package to include v142 libs (https://www.nuget.org/packages/Microsoft.VisualStudio.Setup.Configuration.Native/)

If you're prepared to make modifications, then it's probably easiest to backport the change we made in Python 3.7 to shell out to vswhere.exe instead of directly enumerating installs. See Lib/distutils/_msvccompiler.py (it's probably safe to take the entire file and just remove the _distutils_findvs.vcxproj project).

Or if you know that the .lib format is compatible, you could update the AdditionalLibraryDirectories value in _distutils_findvs.vcxproj to not use $(PlatformToolset) and just specify v141.
msg365682 - (view) Author: Lin Gao (Lin) Date: 2020-04-03 08:13
Hi Steve,

Sorry for the delay.

Thanks for your information and help. We mainly use open source projects to test the vs compiler backend. Now is the migration for testing and need to replace vs2017 with vs2019. 

Currently we used the second work around you provided,it works. 

Thanks,
Lin
msg411162 - (view) Author: Irit Katriel (iritkatriel) * (Python committer) Date: 2022-01-21 17:36
3.6 is no longer maintained. Can we close this now, or is this a problem on newer versions as well?
msg411163 - (view) Author: Steve Dower (steve.dower) * (Python committer) Date: 2022-01-21 17:38
I think we can close it.
History
Date User Action Args
2022-04-11 14:59:28adminsetgithub: 84133
2022-01-21 17:38:44steve.dowersetstatus: pending -> closed

messages: + msg411163
stage: resolved
2022-01-21 17:36:40iritkatrielsetstatus: open -> pending

nosy: + iritkatriel
messages: + msg411162

resolution: out of date
2020-04-03 08:13:21Linsetmessages: + msg365682
2020-03-17 10:56:07steve.dowersetmessages: + msg364409
2020-03-16 08:57:16Linsetmessages: + msg364298
2020-03-13 16:47:12zach.waresetnosy: + paul.moore, tim.golden, steve.dower, zach.ware, Lin
messages: + msg364110
components: + Windows
2020-03-13 03:50:31Linsetnosy: - Lin
-> (no value)
2020-03-13 03:46:39Lincreate