Skip to content

Commit 2a4a982

Browse files
bpo-37283: Ensure command-line and unattend.xml setting override previously detected states in Windows installer (GH-15759)
(cherry picked from commit 3a0ddbc) Co-authored-by: Steve Dower <[email protected]>
1 parent 12acb5b commit 2a4a982

File tree

3 files changed

+27
-8
lines changed

3 files changed

+27
-8
lines changed
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
Ensure command-line and unattend.xml setting override previously detected
2+
states in Windows installer.

Tools/msi/bundle/bootstrap/PythonBootstrapperApplication.cpp

Lines changed: 24 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -727,9 +727,13 @@ class PythonBootstrapperApplication : public CBalBaseBootstrapperApplication {
727727
BalLog(BOOTSTRAPPER_LOG_LEVEL_ERROR, "Failed to load AssociateFiles state: error code 0x%08X", hr);
728728
}
729729

730-
_engine->SetVariableNumeric(L"Include_launcher", 1);
730+
LONGLONG includeLauncher;
731+
if (FAILED(BalGetNumericVariable(L"Include_launcher", &includeLauncher))
732+
|| includeLauncher == -1) {
733+
_engine->SetVariableNumeric(L"Include_launcher", 1);
734+
_engine->SetVariableNumeric(L"InstallLauncherAllUsers", fPerMachine ? 1 : 0);
735+
}
731736
_engine->SetVariableNumeric(L"DetectedOldLauncher", 1);
732-
_engine->SetVariableNumeric(L"InstallLauncherAllUsers", fPerMachine ? 1 : 0);
733737
}
734738
return CheckCanceled() ? IDCANCEL : IDNOACTION;
735739
}
@@ -796,6 +800,12 @@ class PythonBootstrapperApplication : public CBalBaseBootstrapperApplication {
796800
}
797801
}
798802

803+
LONGLONG includeLauncher;
804+
if (SUCCEEDED(BalGetNumericVariable(L"Include_launcher", &includeLauncher))
805+
&& includeLauncher != -1) {
806+
detectedLauncher = FALSE;
807+
}
808+
799809
if (detectedLauncher) {
800810
/* When we detect the current version of the launcher. */
801811
_engine->SetVariableNumeric(L"Include_launcher", 1);
@@ -819,6 +829,14 @@ class PythonBootstrapperApplication : public CBalBaseBootstrapperApplication {
819829
_baFunction->OnDetectComplete();
820830
}
821831

832+
if (SUCCEEDED(hrStatus)) {
833+
LONGLONG includeLauncher;
834+
if (SUCCEEDED(BalGetNumericVariable(L"Include_launcher", &includeLauncher))
835+
&& includeLauncher == -1) {
836+
_engine->SetVariableNumeric(L"Include_launcher", 1);
837+
}
838+
}
839+
822840
if (SUCCEEDED(hrStatus)) {
823841
hrStatus = EvaluateConditions();
824842
}
@@ -1451,6 +1469,10 @@ class PythonBootstrapperApplication : public CBalBaseBootstrapperApplication {
14511469
hr = ParseOverridableVariablesFromXml(pixdManifest);
14521470
BalExitOnFailure(hr, "Failed to read overridable variables.");
14531471

1472+
if (_command.action == BOOTSTRAPPER_ACTION_MODIFY) {
1473+
LoadOptionalFeatureStates(_engine);
1474+
}
1475+
14541476
hr = ParseVariablesFromUnattendXml();
14551477
ExitOnFailure(hr, "Failed to read unattend.ini file.");
14561478

@@ -1478,10 +1500,6 @@ class PythonBootstrapperApplication : public CBalBaseBootstrapperApplication {
14781500
hr = UpdateUIStrings(_command.action);
14791501
BalExitOnFailure(hr, "Failed to load UI strings.");
14801502

1481-
if (_command.action == BOOTSTRAPPER_ACTION_MODIFY) {
1482-
LoadOptionalFeatureStates(_engine);
1483-
}
1484-
14851503
GetBundleFileVersion();
14861504
// don't fail if we couldn't get the version info; best-effort only
14871505
LExit:

Tools/msi/bundle/bundle.wxs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -71,11 +71,10 @@
7171
<Variable Name="Include_tools" Value="1" bal:Overridable="yes" />
7272
<Variable Name="Include_tcltk" Value="1" bal:Overridable="yes" />
7373
<Variable Name="Include_pip" Value="1" bal:Overridable="yes" />
74+
<Variable Name="Include_launcher" Value="-1" bal:Overridable="yes" />
7475
<?if "$(var.PyTestExt)"="" ?>
75-
<Variable Name="Include_launcher" Value="1" bal:Overridable="yes" />
7676
<Variable Name="Include_launcherState" Value="enabled" bal:Overridable="yes" />
7777
<?else ?>
78-
<Variable Name="Include_launcher" Value="0" />
7978
<Variable Name="Include_launcherState" Value="disable" />
8079
<?endif ?>
8180
<Variable Name="Include_symbols" Value="0" bal:Overridable="yes" />

0 commit comments

Comments
 (0)