Skip to content

Commit 4943749

Browse files
committed
Issue python#24585: Enables build-to-build upgrades that preserve settings.
Rather than using Burn "Persisted" variables we now add registry keys for each added feature. These can be detected by the installer regardless of which version installed them, and we use this for Modify and Upgrade. In particular, Upgrades can't access the Persisted variables, but can find well-known registry keys. There are also some changes to the bootstrap app to properly handle upgrades. Finally, a few minor improvements to the Windows build to keep things tidier.
1 parent 9e7a046 commit 4943749

33 files changed

+456
-135
lines changed

PCbuild/build.bat

Lines changed: 17 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -25,16 +25,17 @@ set verbose=/nologo /v:m
2525
set kill=
2626

2727
:CheckOpts
28-
if '%1'=='-c' (set conf=%2) & shift & shift & goto CheckOpts
29-
if '%1'=='-p' (set platf=%2) & shift & shift & goto CheckOpts
30-
if '%1'=='-r' (set target=Rebuild) & shift & goto CheckOpts
31-
if '%1'=='-t' (set target=%2) & shift & shift & goto CheckOpts
32-
if '%1'=='-d' (set conf=Debug) & shift & goto CheckOpts
33-
if '%1'=='-e' call "%dir%get_externals.bat" & shift & goto CheckOpts
34-
if '%1'=='-m' (set parallel=/m) & shift & goto CheckOpts
35-
if '%1'=='-M' (set parallel=) & shift & goto CheckOpts
36-
if '%1'=='-v' (set verbose=/v:n) & shift & goto CheckOpts
37-
if '%1'=='-k' (set kill=true) & shift & goto CheckOpts
28+
if '%~1'=='-c' (set conf=%2) & shift & shift & goto CheckOpts
29+
if '%~1'=='-p' (set platf=%2) & shift & shift & goto CheckOpts
30+
if '%~1'=='-r' (set target=Rebuild) & shift & goto CheckOpts
31+
if '%~1'=='-t' (set target=%2) & shift & shift & goto CheckOpts
32+
if '%~1'=='-d' (set conf=Debug) & shift & goto CheckOpts
33+
if '%~1'=='-e' call "%dir%get_externals.bat" & shift & goto CheckOpts
34+
if '%~1'=='-m' (set parallel=/m) & shift & goto CheckOpts
35+
if '%~1'=='-M' (set parallel=) & shift & goto CheckOpts
36+
if '%~1'=='-v' (set verbose=/v:n) & shift & goto CheckOpts
37+
if '%~1'=='-k' (set kill=true) & shift & goto CheckOpts
38+
if '%~1'=='-V' shift & goto Version
3839

3940
if '%platf%'=='x64' (set vs_platf=x86_amd64)
4041

@@ -50,3 +51,9 @@ rem Passing %1-9 is not the preferred option, but argument parsing in
5051
rem batch is, shall we say, "lackluster"
5152
echo on
5253
msbuild "%dir%pcbuild.proj" /t:%target% %parallel% %verbose% /p:Configuration=%conf% /p:Platform=%platf% %1 %2 %3 %4 %5 %6 %7 %8 %9
54+
55+
@goto :eof
56+
57+
:Version
58+
rem Display the current build version information
59+
msbuild "%dir%python.props" /t:ShowVersionInfo /v:m /nologo %1 %2 %3 %4 %5 %6 %7 %8 %9

PCbuild/python.props

Lines changed: 37 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,9 @@
4242

4343
<!-- Full path of the resulting python.exe binary -->
4444
<PythonExe Condition="'$(PythonExe)' == ''">$(BuildPath)python$(PyDebugExt).exe</PythonExe>
45-
45+
</PropertyGroup>
46+
47+
<PropertyGroup Condition="'$(OverrideVersion)' == ''">
4648
<!--
4749
Read version information from Include\patchlevel.h. The following properties are set:
4850
@@ -70,7 +72,40 @@
7072
<ReleaseLevelName Condition="$(_ReleaseLevel) == 'ALPHA'">a$(ReleaseSerial)</ReleaseLevelName>
7173
<ReleaseLevelName Condition="$(_ReleaseLevel) == 'BETA'">b$(ReleaseSerial)</ReleaseLevelName>
7274
<ReleaseLevelName Condition="$(_ReleaseLevel) == 'GAMMA'">rc$(ReleaseSerial)</ReleaseLevelName>
75+
</PropertyGroup>
76+
77+
<PropertyGroup Condition="'$(OverrideVersion)' != ''">
78+
<!--
79+
Override the version number when building by specifying OverrideVersion.
80+
For example:
81+
82+
PCBuild\build.bat "/p:OverrideVersion=3.5.2a1"
7383
84+
Use the -V option to check your version is valid:
85+
86+
PCBuild\build.bat -V "/p:OverrideVersion=3.5.2a1"
87+
PythonVersionNumber: 3.5.2
88+
PythonVersion: 3.5.2a1
89+
PythonVersionHex: 0x030502A1
90+
Field3Value: 2101
91+
92+
Note that this only affects the version numbers embedded in resources and
93+
installers, but not sys.version.
94+
-->
95+
<MajorVersionNumber>$([System.Text.RegularExpressions.Regex]::Match($(OverrideVersion), `(\d+)\.(\d+)\.(\d+)((a|b|rc)(\d))?`).Groups[1].Value)</MajorVersionNumber>
96+
<MinorVersionNumber>$([System.Text.RegularExpressions.Regex]::Match($(OverrideVersion), `(\d+)\.(\d+)\.(\d+)((a|b|rc)(\d))?`).Groups[2].Value)</MinorVersionNumber>
97+
<MicroVersionNumber>$([System.Text.RegularExpressions.Regex]::Match($(OverrideVersion), `(\d+)\.(\d+)\.(\d+)((a|b|rc)(\d))?`).Groups[3].Value)</MicroVersionNumber>
98+
<ReleaseLevelName>$([System.Text.RegularExpressions.Regex]::Match($(OverrideVersion), `(\d+)\.(\d+)\.(\d+)((a|b|rc)(\d))?`).Groups[4].Value)</ReleaseLevelName>
99+
<_ReleaseLevel>$([System.Text.RegularExpressions.Regex]::Match($(OverrideVersion), `(\d+)\.(\d+)\.(\d+)((a|b|rc)(\d))?`).Groups[5].Value)</_ReleaseLevel>
100+
<ReleaseSerial>$([System.Text.RegularExpressions.Regex]::Match($(OverrideVersion), `(\d+)\.(\d+)\.(\d+)((a|b|rc)(\d))?`).Groups[6].Value)</ReleaseSerial>
101+
<ReleaseSerial Condition="'$(ReleaseSerial)' == ''">0</ReleaseSerial>
102+
<ReleaseLevelNumber>15</ReleaseLevelNumber>
103+
<ReleaseLevelNumber Condition="$(_ReleaseLevel) == 'a'">10</ReleaseLevelNumber>
104+
<ReleaseLevelNumber Condition="$(_ReleaseLevel) == 'b'">11</ReleaseLevelNumber>
105+
<ReleaseLevelNumber Condition="$(_ReleaseLevel) == 'rc'">12</ReleaseLevelNumber>
106+
</PropertyGroup>
107+
108+
<PropertyGroup>
74109
<PythonVersionNumber>$(MajorVersionNumber).$(MinorVersionNumber).$(MicroVersionNumber)</PythonVersionNumber>
75110
<PythonVersion>$(MajorVersionNumber).$(MinorVersionNumber).$(MicroVersionNumber)$(ReleaseLevelName)</PythonVersion>
76111
<PythonVersionHex>$([msbuild]::BitwiseOr(
@@ -110,7 +145,7 @@
110145
<Target Name="ShowVersionInfo">
111146
<Message Importance="high" Text="PythonVersionNumber: $(PythonVersionNumber)" />
112147
<Message Importance="high" Text="PythonVersion: $(PythonVersion)" />
113-
<Message Importance="high" Text="$([System.String]::Format(`PythonVersionHex: 0x{0:x}`, $([System.UInt32]::Parse($(PythonVersionHex)))))" />
148+
<Message Importance="high" Text="PythonVersionHex: 0x$([System.UInt32]::Parse($(PythonVersionHex)).ToString(`X08`))" />
114149
<Message Importance="high" Text="Field3Value: $(Field3Value)" />
115150
</Target>
116151
</Project>

Tools/msi/build.bat

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,10 +8,10 @@ set BUILDX64=
88
set BUILDDOC=
99

1010
:CheckOpts
11-
if "%1" EQU "-h" goto Help
12-
if "%1" EQU "-x86" (set BUILDX86=1) && shift && goto CheckOpts
13-
if "%1" EQU "-x64" (set BUILDX64=1) && shift && goto CheckOpts
14-
if "%1" EQU "--doc" (set BUILDDOC=1) && shift && goto CheckOpts
11+
if "%~1" EQU "-h" goto Help
12+
if "%~1" EQU "-x86" (set BUILDX86=1) && shift && goto CheckOpts
13+
if "%~1" EQU "-x64" (set BUILDX64=1) && shift && goto CheckOpts
14+
if "%~1" EQU "--doc" (set BUILDDOC=1) && shift && goto CheckOpts
1515

1616
if not defined BUILDX86 if not defined BUILDX64 (set BUILDX86=1) && (set BUILDX64=1)
1717

Tools/msi/bundle/Default.thm

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,13 +21,24 @@
2121

2222
<Text X="185" Y="50" Width="-11" Height="50" FontId="3" TabStop="yes">#(loc.InstallMessage)</Text>
2323

24-
<Button Name="InstallJustForMeButton" X="175" Y="101" Width="-11" Height="129" TabStop="yes" FontId="3" HexStyle="0xE">#(loc.InstallJustForMeButton)</Button>
24+
<Button Name="InstallButton" X="175" Y="101" Width="-11" Height="129" TabStop="yes" FontId="3" HexStyle="0xE">#(loc.InstallButton)</Button>
2525
<Button Name="InstallCustomButton" X="175" Y="241" Width="-11" Height="59" TabStop="yes" FontId="3" HexStyle="0xE">#(loc.InstallCustomButton)</Button>
2626

2727
<Checkbox Name="PrependPath" X="185" Y="-13" Width="-100" Height="20" TabStop="yes" FontId="3">#(loc.ShortPrependPathLabel)</Checkbox>
2828

2929
<Button Name="InstallCancelButton" X="-11" Y="-11" Width="75" Height="23" TabStop="yes" FontId="0">#(loc.CancelButton)</Button>
3030
</Page>
31+
<Page Name="Upgrade">
32+
<Text X="185" Y="11" Width="-11" Height="32" FontId="1" DisablePrefix="yes">#(loc.InstallUpgradeHeader)</Text>
33+
<Image X="0" Y="0" Width="162" Height="352" ImageFile="SideBar.png"/>
34+
35+
<Text X="185" Y="50" Width="-11" Height="50" FontId="3" TabStop="yes">#(loc.InstallUpgradeMessage)</Text>
36+
37+
<Button Name="InstallUpgradeButton" X="175" Y="101" Width="-11" Height="129" TabStop="yes" FontId="3" HexStyle="0xE">#(loc.InstallUpgradeButton)</Button>
38+
<Button Name="InstallUpgradeCustomButton" X="175" Y="241" Width="-11" Height="59" TabStop="yes" FontId="3" HexStyle="0xE">#(loc.InstallUpgradeCustomButton)</Button>
39+
40+
<Button Name="InstallCancelButton" X="-11" Y="-11" Width="75" Height="23" TabStop="yes" FontId="0">#(loc.CancelButton)</Button>
41+
</Page>
3142
<Page Name="SimpleInstall">
3243
<Text X="185" Y="11" Width="-11" Height="32" FontId="1" DisablePrefix="yes">#(loc.InstallHeader)</Text>
3344
<Image X="0" Y="0" Width="162" Height="352" ImageFile="SideBar.png"/>

Tools/msi/bundle/Default.wxl

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,8 @@ Continue?</String>
2121
<String Id="InstallHeader">Install [WixBundleName]</String>
2222
<String Id="InstallMessage">Select Install Now to install Python with default settings, or choose Customize to enable or disable features.</String>
2323
<String Id="InstallVersion">Version [WixBundleVersion]</String>
24+
<String Id="InstallUpgradeHeader">Upgrade to [WixBundleName]</String>
25+
<String Id="InstallUpgradeMessage">Select Upgrade Now to keep your current settings, or choose Customize to enable or disable features.</String>
2426
<String Id="ConfirmCancelMessage">Are you sure you want to cancel?</String>
2527
<String Id="ExecuteUpgradeRelatedBundleMessage">Previous version</String>
2628
<String Id="HelpHeader">Setup Help</String>
@@ -40,15 +42,22 @@ Continue?</String>
4042
Logs to a specific file. By default, log files are created in %TEMP%.</String>
4143
<String Id="InstallLicenseLinkText">[WixBundleName] &lt;a href="#"&gt;license terms&lt;/a&gt;.</String>
4244
<String Id="InstallAcceptCheckbox">I &amp;agree to the license terms and conditions</String>
43-
<String Id="InstallJustForMeButton">&amp;Install Now</String>
44-
<String Id="InstallJustForMeButtonNote">[DefaultJustForMeTargetDir]
45+
<String Id="InstallButton">&amp;Install Now</String>
46+
<String Id="InstallButtonNote">[DefaultJustForMeTargetDir]
4547

4648
Includes IDLE, pip and documentation
4749
Creates shortcuts and file associations</String>
4850
<String Id="InstallCustomButton">C&amp;ustomize installation</String>
4951
<String Id="InstallCustomButtonNote">Choose location and features</String>
5052
<String Id="InstallSimpleButton">&amp;Install</String>
5153
<String Id="InstallSimpleButtonNote">Uses setting preselected by your administrator</String>
54+
<String Id="InstallUpgradeButton">&amp;Upgrade Now</String>
55+
<String Id="InstallUpgradeButtonNote">[TargetDir]
56+
57+
Replaces your existing installation without changing settings.
58+
Select Customize to review current options.</String>
59+
<String Id="InstallUpgradeCustomButton">C&amp;ustomize installation</String>
60+
<String Id="InstallUpgradeCustomButtonNote">Choose location and features</String>
5261
<String Id="Custom1Header">Optional Features</String>
5362
<String Id="Custom2Header">Advanced Options</String>
5463
<String Id="CustomLocationLabel">Customize install location</String>
@@ -107,4 +116,5 @@ Feel free to email &lt;a href="mailto:python-list@python.org"&gt;python-list@pyt
107116
<String Id="FailureHyperlinkLogText">One or more issues caused the setup to fail. Please fix the issues and then retry setup. For more information see the &lt;a href="#"&gt;log file&lt;/a&gt;.</String>
108117
<String Id="FailureRestartText">You must restart your computer to complete the rollback of the software.</String>
109118
<String Id="FailureRestartButton">&amp;Restart</String>
119+
<String Id="FailureExistingInstall">Unable to install [WixBundleName] due to an existing install. Use Programs and Features to modify, repair or remove [WixBundleName].</String>
110120
</WixLocalization>

0 commit comments

Comments
 (0)