Skip to content

Commit 2084b30

Browse files
authored
bpo-31523: Reliability improvements to the Windows build files (python#3900)
1 parent 36c1d1f commit 2084b30

File tree

5 files changed

+56
-27
lines changed

5 files changed

+56
-27
lines changed

PCbuild/pyproject.props

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
<OutDir>$(BuildPath)</OutDir>
77
<OutDir Condition="!HasTrailingSlash($(OutDir))">$(OutDir)\</OutDir>
88
<Py_IntDir Condition="'$(Py_IntDir)' == ''">$(MSBuildThisFileDirectory)obj\</Py_IntDir>
9-
<IntDir>$(Py_IntDir)\$(ArchName)_$(Configuration)\$(ProjectName)\</IntDir>
9+
<IntDir>$(Py_IntDir)\$(MajorVersionNumber)$(MinorVersionNumber)$(ArchName)_$(Configuration)\$(ProjectName)\</IntDir>
1010
<TargetName Condition="'$(TargetName)' == ''">$(ProjectName)</TargetName>
1111
<TargetName>$(TargetName)$(PyDebugExt)</TargetName>
1212
<GenerateManifest>false</GenerateManifest>

Tools/msi/msi.props

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@
4848
</ItemGroup>
4949

5050
<PropertyGroup>
51-
<IntermediateOutputPath>$(Py_IntDir)\$(Configuration)_$(Platform)_Setup\$(OutputName)</IntermediateOutputPath>
51+
<IntermediateOutputPath>$(Py_IntDir)\$(MajorVersionNumber)$(MinorVersionNumber)$(ArchName)_$(Configuration)\msi_$(OutputName)</IntermediateOutputPath>
5252
<IntermediateOutputPath Condition="'$(OutputSuffix)' != ''">$(IntermediateOutputPath)_$(OutputSuffix)</IntermediateOutputPath>
5353
<OutputPath Condition="'$(OutputPath)' == ''">$(BuildPath)</OutputPath>
5454
<OutputPath Condition="!HasTrailingSlash($(OutputPath))">$(OutputPath)\</OutputPath>

Tools/msi/purge.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@
2525
sys.exit(1)
2626

2727
URL = "https://www.python.org/ftp/python/{}/".format(m.group(1))
28-
28+
REL = m.group(2) or ''
2929

3030
FILES = [
3131
"core.msi",
@@ -64,7 +64,7 @@
6464
"python-{}-webinstall.exe".format(m.group(0)),
6565
"python-{}-amd64.exe".format(m.group(0)),
6666
"python-{}-amd64-webinstall.exe".format(m.group(0)),
67-
] + ["win32{}/{}".format(m.group(2), f) for f in FILES] + ["amd64{}/{}".format(m.group(2), f) for f in FILES]
67+
] + ["win32{}/{}".format(REL, f) for f in FILES] + ["amd64{}/{}".format(REL, f) for f in FILES]
6868

6969
print('Purged:')
7070
for n in PATHS:

Tools/msi/uploadrelease.bat

Lines changed: 34 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,9 @@ set HOST=
88
set USER=
99
set TARGET=
1010
set DRYRUN=false
11+
set NOUPLOAD=
1112
set NOGPG=
12-
set PURGE_OPTION=/p:Purge=true
13+
set NOPURGE=
1314
set NOTEST=
1415

1516
:CheckOpts
@@ -21,8 +22,9 @@ if "%1" EQU "--user" (set USER=%~2) && shift && shift && goto CheckOpts
2122
if "%1" EQU "-t" (set TARGET=%~2) && shift && shift && goto CheckOpts
2223
if "%1" EQU "--target" (set TARGET=%~2) && shift && shift && goto CheckOpts
2324
if "%1" EQU "--dry-run" (set DRYRUN=true) && shift && goto CheckOpts
25+
if "%1" EQU "--skip-upload" (set NOUPLOAD=true) && shift && goto CheckOpts
2426
if "%1" EQU "--skip-gpg" (set NOGPG=true) && shift && goto CheckOpts
25-
if "%1" EQU "--skip-purge" (set PURGE_OPTION=) && shift && goto CheckOpts
27+
if "%1" EQU "--skip-purge" (set NOPURGE=true) && shift && goto CheckOpts
2628
if "%1" EQU "--skip-test" (set NOTEST=true) && shift && goto CheckOpts
2729
if "%1" EQU "-T" (set NOTEST=true) && shift && goto CheckOpts
2830
if "%1" NEQ "" echo Unexpected argument "%1" & exit /B 1
@@ -52,17 +54,43 @@ if defined NOGPG (
5254
call "%PCBUILD%find_msbuild.bat" %MSBUILD%
5355
if ERRORLEVEL 1 (echo Cannot locate MSBuild.exe on PATH or as MSBUILD variable & exit /b 2)
5456
pushd "%D%"
55-
%MSBUILD% /v:m /nologo uploadrelease.proj /t:Upload /p:Platform=x86 %PURGE_OPTION%
56-
%MSBUILD% /v:m /nologo uploadrelease.proj /t:Upload /p:Platform=x64 /p:IncludeDoc=false %PURGE_OPTION%
57+
if not defined NOUPLOAD (
58+
%MSBUILD% /v:m /nologo uploadrelease.proj /t:Upload /p:Platform=x86
59+
if errorlevel 1 goto :failed
60+
%MSBUILD% /v:m /nologo uploadrelease.proj /t:Upload /p:Platform=x64 /p:IncludeDoc=false
61+
if errorlevel 1 goto :failed
62+
)
63+
if not defined NOPURGE (
64+
%MSBUILD% /v:m /nologo uploadrelease.proj /t:Purge
65+
)
5766
if not defined NOTEST (
58-
%MSBUILD% /v:m /nologo uploadrelease.proj /t:Test /p:Platform=x86
59-
%MSBUILD% /v:m /nologo uploadrelease.proj /t:Test /p:Platform=x64
67+
call :test x86
68+
if errorlevel 1 goto :failed
69+
call :test x64
70+
if errorlevel 1 goto :failed
6071
)
6172
%MSBUILD% /v:m /nologo uploadrelease.proj /t:ShowHashes /p:Platform=x86
73+
if errorlevel 1 goto :failed
6274
%MSBUILD% /v:m /nologo uploadrelease.proj /t:ShowHashes /p:Platform=x64 /p:IncludeDoc=false
75+
if errorlevel 1 goto :failed
76+
6377
popd
6478
exit /B 0
6579

80+
:test
81+
%MSBUILD% /v:m /nologo uploadrelease.proj /t:Test /p:Platform=%1
82+
if errorlevel 1 (
83+
echo Test failed - purging and retrying
84+
%MSBUILD% /v:m /nologo uploadrelease.proj /t:Purge
85+
if errorlevel 1 exit /B
86+
%MSBUILD% /v:m /nologo uploadrelease.proj /t:Test /p:Platform=%1
87+
)
88+
exit /B
89+
90+
:failed
91+
popd
92+
exit /B
93+
6694
:Help
6795
echo uploadrelease.bat --host HOST --user USERNAME [--target TARGET] [--dry-run] [-h]
6896
echo.

Tools/msi/uploadrelease.proj

Lines changed: 18 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@
1010
<IncludeDoc Condition="'$(IncludeDoc)' == ''">true</IncludeDoc>
1111
<BuildForRelease Condition="'$(BuildForRelease)' == ''">true</BuildForRelease>
1212
<DryRun Condition="'$(DryRun)' == ''">false</DryRun>
13-
<Purge Condition="'$(Purge)' == ''">false</Purge>
1413
</PropertyGroup>
1514

1615
<Import Project="msi.props" />
@@ -43,7 +42,8 @@
4342
<Target Name="_RunGpg" Condition="'$(GPG)' != ''" Inputs="@(File)" Outputs="$(IntermediateOutputPath)\gpg\%(FileName)%(Extension).asc">
4443
<MakeDir Directories="$(IntermediateOutputPath)gpg" />
4544
<Delete Files="$(IntermediateOutputPath)\gpg\%(File.FileName)%(File.Extension).asc" Condition="Exists('$(IntermediateOutputPath)\gpg\%(File.FileName)%(File.Extension).asc')" />
46-
<Exec Command="&quot;$(GPG)&quot; -ba -o &quot;$(IntermediateOutputPath)\gpg\%(File.FileName)%(File.Extension).asc&quot; &quot;%(File.FullPath)&quot;" />
45+
<Exec Command="&quot;$(GPG)&quot; -ba -o &quot;$(IntermediateOutputPath)\gpg\%(File.FileName)%(File.Extension).asc&quot; &quot;%(File.FullPath)&quot;"
46+
IgnoreExitCode="false" />
4747
<ItemGroup>
4848
<File Include="$(IntermediateOutputPath)\gpg\%(File.FileName)%(File.Extension).asc">
4949
<CopyTo>%(File.CopyTo)</CopyTo>
@@ -52,23 +52,15 @@
5252
</Target>
5353

5454
<Target Name="_Upload" Condition="!$(DryRun)">
55-
<Exec Command="&quot;$(PLINK)&quot; $(User)@$(Host) mkdir %(File.CopyTo) ^&amp;^&amp; chgrp downloads %(File.CopyTo) ^&amp;^&amp; chmod g-w,o+rx %(File.CopyTo)
56-
&quot;$(PSCP)&quot; @(File,' ') $(User)@$(Host):%(File.CopyTo)
57-
&quot;$(PLINK)&quot; $(User)@$(Host) chgrp downloads %(File.CopyTo)/*; chmod g-w,o+r %(File.CopyTo)/*
58-
" />
55+
<Exec Command="&quot;$(PLINK)&quot; $(User)@$(Host) mkdir %(File.CopyTo) ^&amp;^&amp; chgrp downloads %(File.CopyTo) ^&amp;^&amp; chmod g-w,o+rx %(File.CopyTo)" />
56+
<Exec Command="&quot;$(PSCP)&quot; @(File,' ') $(User)@$(Host):%(File.CopyTo)" />
57+
<Exec Command="&quot;$(PLINK)&quot; $(User)@$(Host) chgrp downloads %(File.CopyTo)/*; chmod g-w,o+r %(File.CopyTo)/*" />
5958
</Target>
6059

6160
<Target Name="_PrintNames" Condition="$(DryRun)">
62-
<Exec Command="echo &quot;$(PLINK)&quot; $(User)@$(Host) mkdir %(File.CopyTo) ^&amp;^&amp; chgrp downloads %(File.CopyTo) ^&amp;^&amp; chmod g-w,o+rx %(File.CopyTo)
63-
echo &quot;$(PSCP)&quot; @(File,' ') $(User)@$(Host):%(File.CopyTo)
64-
echo &quot;$(PLINK)&quot; $(User)@$(Host) chgrp downloads %(File.CopyTo)/*; chmod g-w,o+r %(File.CopyTo)/*
65-
echo.
66-
echo." />
67-
</Target>
68-
69-
<Target Name="_Purge" Condition="$(Purge) and !$(DryRun)">
70-
<Error Condition="!Exists('$(PythonExe)')" Text="No Python executable available at $(PythonExe)" />
71-
<Exec Command="&quot;$(PythonExe)&quot; purge.py $(PythonVersion)" />
61+
<Exec Command="echo &quot;$(PLINK)&quot; $(User)@$(Host) mkdir %(File.CopyTo) ^&amp;^&amp; chgrp downloads %(File.CopyTo) ^&amp;^&amp; chmod g-w,o+rx %(File.CopyTo)" />
62+
<Exec Command="echo &quot;$(PSCP)&quot; @(File,' ') $(User)@$(Host):%(File.CopyTo)" />
63+
<Exec Command="echo &quot;$(PLINK)&quot; $(User)@$(Host) chgrp downloads %(File.CopyTo)/*; chmod g-w,o+r %(File.CopyTo)/*" />
7264
</Target>
7365

7466
<Target Name="_TestLayout">
@@ -82,6 +74,7 @@ echo." />
8274
<LogFile>$(OutputPath)\%(Filename)_layoutlog\%(Filename).log</LogFile>
8375
</WebInstaller>
8476
</ItemGroup>
77+
<Error Text="Could not find installer" Condition="@(WebInstaller) == ''" />
8578
<RemoveDir Directories="%(WebInstaller.SourceDir)" Condition="Exists('%(WebInstaller.SourceDir)')" />
8679
<RemoveDir Directories="%(WebInstaller.LayoutDir)" Condition="Exists('%(WebInstaller.LayoutDir)')" />
8780
<RemoveDir Directories="%(WebInstaller.LogDir)" Condition="Exists('%(WebInstaller.LogDir)')" />
@@ -95,14 +88,22 @@ echo." />
9588
<Message Text="Successfully downloaded %(WebInstaller.Filename)%(WebInstaller.Extension) layout" Importance="high" />
9689
</Target>
9790

98-
<Target Name="Upload" DependsOnTargets="_ValidateProperties;_RunGpg;_PrintNames;_Upload;_Purge" />
91+
<Target Name="Upload" DependsOnTargets="_ValidateProperties;_RunGpg;_PrintNames;_Upload" />
9992
<Target Name="Test" DependsOnTargets="_TestLayout" />
10093

94+
<Target Name="Purge">
95+
<Error Condition="!Exists('$(PythonExe)')" Text="No Python executable available at $(PythonExe)" />
96+
<Exec Command="echo &quot;$(PythonExe)&quot; purge.py $(PythonVersion)" Condition="$(DryRun)" />
97+
<Exec Command="&quot;$(PythonExe)&quot; purge.py $(PythonVersion)" Condition="!$(DryRun)" />
98+
<Message Text="Purged uploaded files" Importance="high" />
99+
</Target>
100+
101101
<Target Name="ShowHashes">
102102
<ItemGroup>
103103
<UserFiles Include="@(File)" Condition="'%(File.CopyTo)' == '$(EXETarget)'" />
104104
</ItemGroup>
105105

106+
<Error Text="No files generated" Condition="@(UserFiles) == ''" />
106107
<Exec Command="&quot;$(PythonExe)&quot; generate_md5.py @(UserFiles->'&quot;%(FullPath)&quot;',' ')" />
107108
</Target>
108109

0 commit comments

Comments
 (0)