8000 bpo-31340: Change to building with MSVC v141 (included with Visual St… · python/cpython@5fcd5e6 · GitHub
[go: up one dir, main page]

Skip to content

Commit 5fcd5e6

Browse files
authored
bpo-31340: Change to building with MSVC v141 (included with Visual Studio 2017) (#3311)
1 parent bcaac81 commit 5fcd5e6

File tree

10 files changed

+86
-13
lines changed

10 files changed

+86
-13
lines changed

.github/appveyor.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,8 @@ test_script:
1414
- cmd: PCbuild\rt.bat -q -uall -u-cpu -rwW --slowest --timeout=1200 --fail-env-changed -j0
1515
environment:
1616
HOST_PYTHON: C:\Python36\python.exe
17+
image:
18+
- Visual Studio 2017
1719

1820
# Only trigger AppVeyor if actual code or its configuration changes
1921
only_commits:

Doc/make.bat

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,19 @@ if not defined SPHINXBUILD if defined PYTHON (
1616
set SPHINXBUILD=%PYTHON% -c "import sphinx, sys; sys.argv[0] = 'sphinx-build'; sphinx.main()"
1717
)
1818

19+
if not defined BLURB if defined PYTHON (
20+
%PYTHON% -c "import blurb" > nul 2> nul
21+
if errorlevel 1 (
22+
echo Installing blurb with %PYTHON%
23+
%PYTHON% -m pip install blurb
24+
if errorlevel 1 exit /B
25+
)
26+
set BLURB=%PYTHON% -m blurb
27+
)
28+
1929
if not defined PYTHON set PYTHON=py
2030
if not defined SPHINXBUILD set SPHINXBUILD=sphinx-build
31+
if not defined BLURB set BLURB=blurb
2132

2233
if "%1" NEQ "htmlhelp" goto :skiphhcsearch
2334
if exist "%HTMLHELP%" goto :skiphhcsearch
@@ -96,6 +107,19 @@ echo.be passed by setting the SPHINXOPTS environment variable.
96107
goto end
97108

98109
:build
110+
if exist ..\Misc\NEWS (
111+
echo.Copying Misc\NEWS to build\NEWS
112+
copy ..\Misc\NEWS build\NEWS > nul
113+
) else if exist ..\Misc\NEWS.D (
114+
if defined BLURB (
115+
echo.Merging Misc/NEWS with %BLURB%
116+
%BLURB% merge -f build\NEWS
117+
) else (
118+
echo.No Misc/NEWS file and Blurb is not available.
119+
exit /B 1
120+
)
121+
)
122+
99123
if NOT "%PAPER%" == "" (
100124
set SPHINXOPTS=-D latex_elements.papersize=%PAPER% %SPHINXOPTS%
101125
)

Lib/distutils/command/bdist_wininst.py

Lines changed: 13 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -318,26 +318,30 @@ def get_exe_bytes(self):
318318
# string compares seem wrong, but are what sysconfig.py itself uses
319319
if self.target_version and self.target_version < cur_version:
320320
if self.target_version < "2.4":
321-
bv = 6.0
321+
bv = '6.0'
322322
elif self.target_version == "2.4":
323-
bv = 7.1
323+
bv = '7.1'
324324
elif self.target_version == "2.5":
325-
bv = 8.0
325+
bv = '8.0'
326326
elif self.target_version <= "3.2":
327-
bv = 9.0
327+
bv = '9.0'
328328
elif self.target_version <= "3.4":
329-
bv = 10.0
329+
bv = '10.0'
330330
else:
331-
bv = 14.0
331+
bv = '14.0'
332332
else:
333333
# for current version - use authoritative check.
334334
try:
335335
from msvcrt import CRT_ASSEMBLY_VERSION
336336
except ImportError:
337337
# cross-building, so assume the latest version
338-
bv = 14.0
338+
bv = '14.0'
339339
else:
340-
bv = float('.'.join(CRT_ASSEMBLY_VERSION.split('.', 2)[:2]))
340+
bv = '.'.join(CRT_ASSEMBLY_VERSION.split('.', 2)[:2])
341+
if bv == '14.11':
342+
# v141 and v140 are binary compatible,
343+
# so keep using the 14.0 stub.
344+
bv = '14.0'
341345

342346

343347
# wininst-x.y.exe is in the same directory as this file
@@ -353,7 +357,7 @@ def get_exe_bytes(self):
353357
else:
354358
sfix = ''
355359

356-
filename = os.path.join(directory, "wininst-%.1f%s.exe" % (bv, sfix))
360+
filename = os.path.join(directory, "wininst-%s%s.exe" % (bv, sfix))
357361
f = open(filename, "rb")
358362
try:
359363
return f.read()
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Change to building with MSVC v141 (included with Visual Studio 2017)

PCbuild/pyproject.props

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -147,8 +147,24 @@ foreach (System.Diagnostics.Process p in System.Diagnostics.Process.GetProcesses
147147
Targets="CleanAll" />
148148
</Target>
149149

150+
<Target Name="CopyPGCFiles" BeforeTargets="PrepareForBuild" Condition="$(Configuration) == 'PGUpdate'">
151+
<ItemGroup>
152+
<_PGCFiles Include="$(OutDir)instrumented\$(TargetName)!*.pgc" />
153+
<_PGDFile Include="$(OutDir)instrumented\$(TargetName).pgd" />
154+
<_CopyFiles Include="@(_PGCFiles);@(_PGDFile)" Condition="Exists(%(FullPath))" />
155+
</ItemGroup>
156+
<Delete Files="@(_CopyFiles->'$(OutDir)%(Filename)%(Extension)')" />
157+
<Error Text="PGO run did not succeed (no $(TargetName)!*.pgc files) and there is no data to merge"
158+
Condition="$(RequirePGCFiles) == 'true' and @(_PGCFiles) == ''" />
159+
<Copy SourceFiles="@(_CopyFiles)"
160+
DestinationFolder="$(OutDir)"
161+
UseHardLinksIfPossible="true"
162+
OverwriteReadOnlyFiles="true" />
163+
</Target>
164+
150165
<PropertyGroup>
151-
<SdkBinPath Condition="'$(SdkBinPath)' == '' or !Exists($(SdkBinPath))">$(registry:HKEY_LOCAL_MACHINE\Software\Microsoft\Windows Kits\Installed Roots@KitsRoot10)\bin\x86</SdkBinPath>
166+
<SdkBinPath Condition="'$(SdkBinPath)' == '' or !Exists($(SdkBinPath))">$(registry:HKEY_LOCAL_MACHINE\Software\Microsoft\Windows Kits\Installed Roots@KitsRoot10)\bin\$(DefaultWindowsSDKVersion)\x86</SdkBinPath>
167+
<SdkBinPath Condition="!Exists($(SdkBinPath))">$(registry:HKEY_LOCAL_MACHINE\Software\Microsoft\Windows Kits\Installed Roots@KitsRoot10)\bin\x86</SdkBinPath>
152168
<SdkBinPath Condition="!Exists($(SdkBinPath))">$(registry:HKEY_LOCAL_MACHINE\Software\Microsoft\Windows Kits\Installed Roots@KitsRoot81)\bin\x86</SdkBinPath>
153169
<SdkBinPath Condition="!Exists($(SdkBinPath))">$(registry:HKEY_LOCAL_MACHINE\Software\Microsoft\Windows Kits\Installed Roots@KitsRoot)\bin\x86</SdkBinPath>
154170
<SdkBinPath Condition="!Exists($(SdkBinPath))">$(registry:HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Microsoft SDKs\Windows\v7.1A@InstallationFolder)\Bin\</SdkBinPath>

PCbuild/python.props

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
1111
We set BasePlatformToolset for ICC's benefit, it's otherwise ignored.
1212
-->
13+
<BasePlatformToolset Condition="'$(BasePlatformToolset)' == '' and ('$(MSBuildToolsVersion)' == '15.0' or '$(VisualStudioVersion)' == '15.0')">v141</BasePlatformToolset>
1314
<BasePlatformToolset Condition="'$(BasePlatformToolset)' == '' and '$(VCTargetsPath14)' != ''">v140</BasePlatformToolset>
1415
<BasePlatformToolset Condition="'$(BasePlatformToolset)' == '' and '$(VCTargetsPath12)' != ''">v120</BasePlatformToolset>
1516
<BasePlatformToolset Condition="'$(BasePlatformToolset)' == '' and '$(VCTargetsPath11)' != ''">v110</BasePlatformToolset>
@@ -39,6 +40,7 @@
3940
<BuildPath Condition="'$(ArchName)' == 'amd64'">$(BuildPath64)</BuildPath>
4041
<BuildPath Condition="'$(BuildPath)' == ''">$(PySourcePath)PCBuild\$(ArchName)\</BuildPath>
4142
<BuildPath Condition="!HasTrailingSlash($(BuildPath))">$(BuildPath)\</BuildPath>
43+
<BuildPath Condition="$(Configuration) == 'PGInstrument'">$(BuildPath)instrumented\</BuildPath>
4244

4345
<!-- Directories of external projects. tcltk is handled in tcltk.props -->
4446
<ExternalsDir>$([System.IO.Path]::GetFullPath(`$(PySourcePath)externals\`))</ExternalsDir>

PCbuild/python.vcxproj

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -96,6 +96,7 @@ set PYTHONPATH=$(PySourcePath)Lib
9696
<PropertyGroup>
9797
<_PGOPath Condition="$(Configuration) == 'PGInstrument' and $(Platform) == 'Win32'">@set PATH=%PATH%%3B$(VCInstallDir)bin</_PGOPath>
9898
<_PGOPath Condition="$(Configuration) == 'PGInstrument' and $(Platform) == 'x64'">@set PATH=%PATH%%3B$(VCInstallDir)bin\amd64</_PGOPath>
99+
<_PGOPath Condition="$(Configuration) == 'PGInstrument' and $(VC_PGO_RunTime_Dir) != ''">@set PATH=%PATH%%3B$(VC_PGO_RunTime_Dir)</_PGOPath>
99100
<_Content>@rem This script invokes the most recently built Python with all arguments
100101
@rem passed through to the interpreter. This file is generated by the
101102
@rem build process and any changes *will* be thrown away by the next

PCbuild/pythoncore.vcxproj

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,7 @@
4949
</ImportGroup>
5050
<PropertyGroup>
5151
<KillPython>true</KillPython>
52+
<RequirePGCFiles>true</RequirePGCFiles>
5253
</PropertyGroup>
5354
<ImportGroup Label="PropertySheets">
5455
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
@@ -429,7 +430,7 @@
429430
</ClCompile>
430431
</ItemGroup>
431432
</Target>
432-
<Target Name="_WarnAboutToolset" BeforeTargets="PrepareForBuild" Condition="$(PlatformToolset) != 'v140'">
433+
<Target Name="_WarnAboutToolset" BeforeTargets="PrepareForBuild" Condition="$(PlatformToolset) != 'v140' and $(PlatformToolset) != 'v141'">
433434
<Warning Text="Toolset $(PlatformToolset) is not used for official builds. Your build may have errors or incompatibilities." />
434435
</Target>
435436
</Project>

Tools/msi/exe/exe.wixproj

Lines changed: 23 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,28 @@
3939
Overwrite="true"
4040
Lines="@(_LicenseFiles->'%(Content)')" />
4141
</Target>
42-
42+
43+
<Target Name="_CopyMiscNews" AfterTargets="PrepareForBuild" Condition="Exists('$(PySourcePath)Misc\NEWS')">
44+
<Copy SourceFiles="$(PySourcePath)Misc\NEWS" DestinationFiles="$(BuildPath)NEWS.txt" />
45+
</Target>
46+
47+
<Target Name="_MergeMiscNewsWithBlurb" AfterTargets="PrepareForBuild" Condition="$(Blurb) != '' and !Exists('$(PySourcePath)Misc\NEWS')">
48+
<Exec Command="$(Blurb) merge -f &quot;$(BuildPath)NEWS.txt&quot;" WorkingDirectory="$(PCBuild)" />
49+
</Target>
50+
51+
<Target Name="_MergeMiscNewsWithPython" AfterTargets="PrepareForBuild" Condition="$(Blurb) == '' and !Exists('$(PySourcePath)Misc\NEWS')">
52+
<ItemGroup>
53+
<HostPython Include="$(ExternalsDir)python*\tools\python.exe" />
54+
<HostPython Include="@(HostPython)" Condition="Exists(%(FullPath))" />
55+
<HostPython Include="py" Condition="@(HostPython) == ''" />
56+
</ItemGroup>
57+
<PropertyGroup>
58+
<HostPython>@(HostPython)</HostPython>
59+
<HostPython Condition="$(HostPython.Contains(';'))">$(HostPython.Remove($(HostPython.IndexOf(';'))))</HostPython>
60+
</PropertyGroup>
61+
<Exec Command="&quot;$(HostPython)&quot; -m pip install -U blurb" WorkingDirectory="$(PCBuild)" />
62+
<Exec Command="&quot;$(HostPython)&quot; -m blurb merge -f &quot;$(BuildPath)NEWS.txt&quot;" WorkingDirectory="$(PCBuild)" />
63+
</Target>
64+
4365
<Import Project="..\msi.targets" />
4466
</Project>

Tools/msi/exe/exe_files.wxs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
<File Name="LICENSE.txt" Source="LICENSE" KeyPath="yes" />
77
</Component>
88
<Component Id="NEWS.txt" Directory="InstallDirectory" Guid="*">
9-
<File Name="NEWS.txt" Source="!(bindpath.src)Misc\NEWS" KeyPath="yes" />
9+
<File Name="NEWS.txt" KeyPath="yes" />
1010
</Component>
1111
</ComponentGroup>
1212
</Fragment>

0 commit comments

Comments
 (0)
0