From d3fd43bc37209e37c73463f2b51686b97b367faf Mon Sep 17 00:00:00 2001 From: Steve Dower Date: Wed, 6 Sep 2017 10:01:38 -0700 Subject: [PATCH 1/2] bpo-31340: Change to building with MSVC v141 (included with Visual Studio 2017) (#3311) --- .github/appveyor.yml | 3 ++ Doc/make.bat | 39 ++++++++++++++++++- Lib/distutils/command/bdist_wininst.py | 22 ++++++----- .../2017-09-04-13-19-05.bpo-31340.MbkzLi.rst | 1 + PCbuild/pyproject.props | 18 ++++++++- PCbuild/python.props | 2 + PCbuild/python.vcxproj | 1 + PCbuild/pythoncore.vcxproj | 3 +- Tools/msi/exe/exe.wixproj | 24 +++++++++++- Tools/msi/exe/exe_files.wxs | 2 +- 10 files changed, 100 insertions(+), 15 deletions(-) create mode 100644 Misc/NEWS.d/next/Windows/2017-09-04-13-19-05.bpo-31340.MbkzLi.rst diff --git a/.github/appveyor.yml b/.github/appveyor.yml index 04566eafe58bfd..36971390c3042a 100644 --- a/.github/appveyor.yml +++ b/.github/appveyor.yml @@ -9,6 +9,9 @@ build_script: - cmd: PCbuild\build.bat -e test_script: - cmd: PCbuild\rt.bat -q -uall -u-cpu -rwW --slowest --timeout=1200 -j0 +image: +- Visual Studio 2015 +- Visual Studio 2017 # Only trigger AppVeyor if actual code or its configuration changes only_commits: diff --git a/Doc/make.bat b/Doc/make.bat index d9c0ad0adecfe6..0472a3de82f18f 100644 --- a/Doc/make.bat +++ b/Doc/make.bat @@ -5,8 +5,30 @@ pushd %~dp0 set this=%~n0 -if "%SPHINXBUILD%" EQU "" set SPHINXBUILD=sphinx-build -if "%PYTHON%" EQU "" set PYTHON=py +call ..\PCBuild\find_python.bat %PYTHON% +if not defined SPHINXBUILD if defined PYTHON ( + %PYTHON% -c "import sphinx" > nul 2> nul + if errorlevel 1 ( + echo Installing sphinx with %PYTHON% + %PYTHON% -m pip install sphinx + if errorlevel 1 exit /B + ) + set SPHINXBUILD=%PYTHON% -c "import sphinx, sys; sys.argv[0] = 'sphinx-build'; sphinx.main()" +) + +if not defined BLURB if defined PYTHON ( + %PYTHON% -c "import blurb" > nul 2> nul + if errorlevel 1 ( + echo Installing blurb with %PYTHON% + %PYTHON% -m pip install blurb + if errorlevel 1 exit /B + ) + set BLURB=%PYTHON% -m blurb +) + +if not defined PYTHON set PYTHON=py +if not defined SPHINXBUILD set SPHINXBUILD=sphinx-build +if not defined BLURB set BLURB=blurb if "%1" NEQ "htmlhelp" goto :skiphhcsearch if exist "%HTMLHELP%" goto :skiphhcsearch @@ -85,6 +107,19 @@ echo.be passed by setting the SPHINXOPTS environment variable. goto end :build +if exist ..\Misc\NEWS ( + echo.Copying Misc\NEWS to build\NEWS + copy ..\Misc\NEWS build\NEWS > nul +) else if exist ..\Misc\NEWS.D ( + if defined BLURB ( + echo.Merging Misc/NEWS with %BLURB% + %BLURB% merge -f build\NEWS + ) else ( + echo.No Misc/NEWS file and Blurb is not available. + exit /B 1 + ) +) + if NOT "%PAPER%" == "" ( set SPHINXOPTS=-D latex_elements.papersize=%PAPER% %SPHINXOPTS% ) diff --git a/Lib/distutils/command/bdist_wininst.py b/Lib/distutils/command/bdist_wininst.py index d3e1d3af22c051..6309c3e248c6fe 100644 --- a/Lib/distutils/command/bdist_wininst.py +++ b/Lib/distutils/command/bdist_wininst.py @@ -318,26 +318,30 @@ def get_exe_bytes(self): # string compares seem wrong, but are what sysconfig.py itself uses if self.target_version and self.target_version < cur_version: if self.target_version < "2.4": - bv = 6.0 + bv = '6.0' elif self.target_version == "2.4": - bv = 7.1 + bv = '7.1' elif self.target_version == "2.5": - bv = 8.0 + bv = '8.0' elif self.target_version <= "3.2": - bv = 9.0 + bv = '9.0' elif self.target_version <= "3.4": - bv = 10.0 + bv = '10.0' else: - bv = 14.0 + bv = '14.0' else: # for current version - use authoritative check. try: from msvcrt import CRT_ASSEMBLY_VERSION except ImportError: # cross-building, so assume the latest version - bv = 14.0 + bv = '14.0' else: - bv = float('.'.join(CRT_ASSEMBLY_VERSION.split('.', 2)[:2])) + bv = '.'.join(CRT_ASSEMBLY_VERSION.split('.', 2)[:2]) + if bv == '14.11': + # v141 and v140 are binary compatible, + # so keep using the 14.0 stub. + bv = '14.0' # wininst-x.y.exe is in the same directory as this file @@ -353,7 +357,7 @@ def get_exe_bytes(self): else: sfix = '' - filename = os.path.join(directory, "wininst-%.1f%s.exe" % (bv, sfix)) + filename = os.path.join(directory, "wininst-%s%s.exe" % (bv, sfix)) f = open(filename, "rb") try: return f.read() diff --git a/Misc/NEWS.d/next/Windows/2017-09-04-13-19-05.bpo-31340.MbkzLi.rst b/Misc/NEWS.d/next/Windows/2017-09-04-13-19-05.bpo-31340.MbkzLi.rst new file mode 100644 index 00000000000000..065596fcc859e4 --- /dev/null +++ b/Misc/NEWS.d/next/Windows/2017-09-04-13-19-05.bpo-31340.MbkzLi.rst @@ -0,0 +1 @@ +Change to building with MSVC v141 (included with Visual Studio 2017) diff --git a/PCbuild/pyproject.props b/PCbuild/pyproject.props index 7012170e0c7aa4..9122e53213692b 100644 --- a/PCbuild/pyproject.props +++ b/PCbuild/pyproject.props @@ -147,8 +147,24 @@ foreach (System.Diagnostics.Process p in System.Diagnostics.Process.GetProcesses Targets="CleanAll" /> + + + <_PGCFiles Include="$(OutDir)instrumented\$(TargetName)!*.pgc" /> + <_PGDFile Include="$(OutDir)instrumented\$(TargetName).pgd" /> + <_CopyFiles Include="@(_PGCFiles);@(_PGDFile)" Condition="Exists(%(FullPath))" /> + + + + + + - $(registry:HKEY_LOCAL_MACHINE\Software\Microsoft\Windows Kits\Installed Roots@KitsRoot10)\bin\x86 + $(registry:HKEY_LOCAL_MACHINE\Software\Microsoft\Windows Kits\Installed Roots@KitsRoot10)\bin\$(DefaultWindowsSDKVersion)\x86 + $(registry:HKEY_LOCAL_MACHINE\Software\Microsoft\Windows Kits\Installed Roots@KitsRoot10)\bin\x86 $(registry:HKEY_LOCAL_MACHINE\Software\Microsoft\Windows Kits\Installed Roots@KitsRoot81)\bin\x86 $(registry:HKEY_LOCAL_MACHINE\Software\Microsoft\Windows Kits\Installed Roots@KitsRoot)\bin\x86 $(registry:HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Microsoft SDKs\Windows\v7.1A@InstallationFolder)\Bin\ diff --git a/PCbuild/python.props b/PCbuild/python.props index d6bfd0877e09df..3ec0584f5c45a6 100644 --- a/PCbuild/python.props +++ b/PCbuild/python.props @@ -10,6 +10,7 @@ We set BasePlatformToolset for ICC's benefit, it's otherwise ignored. --> + v141 v140 v120 v110 @@ -39,6 +40,7 @@ $(BuildPath64) $(PySourcePath)PCBuild\$(ArchName)\ $(BuildPath)\ + $(BuildPath)instrumented\ $([System.IO.Path]::GetFullPath(`$(PySourcePath)externals\`)) diff --git a/PCbuild/python.vcxproj b/PCbuild/python.vcxproj index 2786ac2ebf7b6b..ab9fb05adead99 100644 --- a/PCbuild/python.vcxproj +++ b/PCbuild/python.vcxproj @@ -96,6 +96,7 @@ set PYTHONPATH=$(PySourcePath)Lib <_PGOPath Condition="$(Configuration) == 'PGInstrument' and $(Platform) == 'Win32'">@set PATH=%PATH%%3B$(VCInstallDir)bin <_PGOPath Condition="$(Configuration) == 'PGInstrument' and $(Platform) == 'x64'">@set PATH=%PATH%%3B$(VCInstallDir)bin\amd64 + <_PGOPath Condition="$(Configuration) == 'PGInstrument' and $(VC_PGO_RunTime_Dir) != ''">@set PATH=%PATH%%3B$(VC_PGO_RunTime_Dir) <_Content>@rem This script invokes the most recently built Python with all arguments @rem passed through to the interpreter. This file is generated by the @rem build process and any changes *will* be thrown away by the next diff --git a/PCbuild/pythoncore.vcxproj b/PCbuild/pythoncore.vcxproj index 6ea184877f99cd..6fd0440f4f911f 100644 --- a/PCbuild/pythoncore.vcxproj +++ b/PCbuild/pythoncore.vcxproj @@ -49,6 +49,7 @@ true + true @@ -428,7 +429,7 @@ - + diff --git a/Tools/msi/exe/exe.wixproj b/Tools/msi/exe/exe.wixproj index 24df0f5f7a3011..16ef6ac5b1d43e 100644 --- a/Tools/msi/exe/exe.wixproj +++ b/Tools/msi/exe/exe.wixproj @@ -39,6 +39,28 @@ Overwrite="true" Lines="@(_LicenseFiles->'%(Content)')" /> - + + + + + + + + + + + + + + + + + @(HostPython) + $(HostPython.Remove($(HostPython.IndexOf(';')))) + + + + + \ No newline at end of file diff --git a/Tools/msi/exe/exe_files.wxs b/Tools/msi/exe/exe_files.wxs index e675c21c8975ef..394b4de473547f 100644 --- a/Tools/msi/exe/exe_files.wxs +++ b/Tools/msi/exe/exe_files.wxs @@ -6,7 +6,7 @@ - + From 48e552d46274531827841b5782dea57b62f3d65c Mon Sep 17 00:00:00 2001 From: Steve Dower Date: Wed, 6 Sep 2017 10:26:33 -0700 Subject: [PATCH 2/2] Backport other changes needed for a successful build --- PCbuild/build.bat | 2 +- PCbuild/find_msbuild.bat | 15 ++++++++------- PCbuild/pyproject.props | 3 +-- PCbuild/python.props | 19 ++++++++++++++++++- 4 files changed, 28 insertions(+), 11 deletions(-) diff --git a/PCbuild/build.bat b/PCbuild/build.bat index 81e500d5544286..2e6b0a94bb59a1 100644 --- a/PCbuild/build.bat +++ b/PCbuild/build.bat @@ -104,7 +104,7 @@ if "%kill%"=="true" call :Kill if "%do_pgo%"=="true" ( set conf=PGInstrument - call :Build + call :Build %1 %2 %3 %4 %5 %6 %7 %8 %9 del /s "%dir%\*.pgc" del /s "%dir%\..\Lib\*.pyc" echo on diff --git a/PCbuild/find_msbuild.bat b/PCbuild/find_msbuild.bat index 1877906e00a55d..2b7413fbcde870 100644 --- a/PCbuild/find_msbuild.bat +++ b/PCbuild/find_msbuild.bat @@ -29,20 +29,21 @@ @where msbuild > "%TEMP%\msbuild.loc" 2> nul && set /P MSBUILD= < "%TEMP%\msbuild.loc" & del "%TEMP%\msbuild.loc" @if exist "%MSBUILD%" set MSBUILD="%MSBUILD%" & (set _Py_MSBuild_Source=PATH) & goto :found -@rem VS 2017 sets exactly one install as the "main" install, so we may find MSBuild in there. -@reg query "HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\VisualStudio\SxS\VS7" /v 15.0 /reg:32 >nul 2>nul -@if NOT ERRORLEVEL 1 @for /F "tokens=1,2*" %%i in ('reg query "HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\VisualStudio\SxS\VS7" /v 15.0 /reg:32') DO @( - @if "%%i"=="15.0" @if exist "%%k\MSBuild\15.0\Bin\msbuild.exe" @(set MSBUILD="%%k\MSBuild\15.0\Bin\msbuild.exe") -) -@if exist %MSBUILD% (set _Py_MSBuild_Source=Visual Studio 2017 registry) & goto :found - @rem VS 2015 and earlier register MSBuild separately, so we can find it. +@rem Prefer MSBuild 14.0 over MSBuild 15.0, since the latter may not be able to find a VC14 install. @reg query "HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\MSBuild\ToolsVersions\14.0" /v MSBuildToolsPath /reg:32 >nul 2>nul @if NOT ERRORLEVEL 1 @for /F "tokens=1,2*" %%i in ('reg query "HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\MSBuild\ToolsVersions\14.0" /v MSBuildToolsPath /reg:32') DO @( @if "%%i"=="MSBuildToolsPath" @if exist "%%k\msbuild.exe" @(set MSBUILD="%%k\msbuild.exe") ) @if exist %MSBUILD% (set _Py_MSBuild_Source=registry) & goto :found +@rem VS 2017 sets exactly one install as the "main" install, so we may find MSBuild in there. +@reg query "HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\VisualStudio\SxS\VS7" /v 15.0 /reg:32 >nul 2>nul +@if NOT ERRORLEVEL 1 @for /F "tokens=1,2*" %%i in ('reg query "HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\VisualStudio\SxS\VS7" /v 15.0 /reg:32') DO @( + @if "%%i"=="15.0" @if exist "%%k\MSBuild\15.0\Bin\msbuild.exe" @(set MSBUILD="%%k\MSBuild\15.0\Bin\msbuild.exe") +) +@if exist %MSBUILD% (set _Py_MSBuild_Source=Visual Studio 2017 registry) & goto :found + @exit /b 1 diff --git a/PCbuild/pyproject.props b/PCbuild/pyproject.props index 9122e53213692b..3d46a0fcba8fd7 100644 --- a/PCbuild/pyproject.props +++ b/PCbuild/pyproject.props @@ -168,8 +168,7 @@ foreach (System.Diagnostics.Process p in System.Diagnostics.Process.GetProcesses $(registry:HKEY_LOCAL_MACHINE\Software\Microsoft\Windows Kits\Installed Roots@KitsRoot81)\bin\x86 $(registry:HKEY_LOCAL_MACHINE\Software\Microsoft\Windows Kits\Installed Roots@KitsRoot)\bin\x86 $(registry:HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Microsoft SDKs\Windows\v7.1A@InstallationFolder)\Bin\ - <_SignCommand Condition="Exists($(SdkBinPath)) and '$(SigningCertificate)' != '' and $(SupportSigning)">"$(SdkBinPath)\signtool.exe" sign /q /n "$(SigningCertificate)" /fd sha256 /t http://timestamp.verisign.com/scripts/timestamp.dll /d "Python $(PythonVersion)" - <_MakeCatCommand Condition="Exists($(SdkBinPath))">"$(SdkBinPath)\makecat.exe" + <_SignCommand Condition="Exists($(SdkBinPath)) and '$(SigningCertificate)' != '' and $(SupportSigning)">"$(SdkBinPath)\signtool.exe" sign /q /a /n "$(SigningCertificate)" /fd sha256 /t http://timestamp.verisign.com/scripts/timestamp.dll /d "Python $(PythonVersion)" <_MakeCatCommand Condition="Exists($(SdkBinPath))">"$(SdkBinPath)\makecat.exe" diff --git a/PCbuild/python.props b/PCbuild/python.props index 3ec0584f5c45a6..c26f642a9533c1 100644 --- a/PCbuild/python.props +++ b/PCbuild/python.props @@ -64,7 +64,24 @@ $(BuildPath)python$(PyDebugExt).exe - + + + + 10.0.15063.0 + 10.0.15063.0 + 10.0.14393.0 + 10.0.14393.0 + 10.0.10586.0 + 10.0.10586.0 + 10.0.10240.0 + 10.0.10240.0 + +