Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 731f4a2

Browse files
committed
Issue #25163: Display correct directory in installer when using non-default settings.
1 parent 5700ae8 commit 731f4a2

4 files changed

Lines changed: 41 additions & 24 deletions

File tree

Misc/NEWS

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -308,6 +308,9 @@ Build
308308
Windows
309309
-------
310310

311+
- Issue #25163: Display correct directory in installer when using non-default
312+
settings.
313+
311314
- Issue #25361: Disables use of SSE2 instructions in Windows 32-bit build
312315

313316
- Issue #25089: Adds logging to installer for case where launcher is not

Tools/msi/bundle/Default.thm

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,8 +24,8 @@
2424
<Button Name="InstallButton" X="185" Y="101" Width="-11" Height="109" TabStop="yes" FontId="3" HexStyle="0xE">#(loc.InstallButton)</Button>
2525
<Button Name="InstallCustomButton" X="185" Y="221" Width="-11" Height="59" TabStop="yes" FontId="3" HexStyle="0xE">#(loc.InstallCustomButton)</Button>
2626

27-
<Checkbox Name="PrependPath" X="185" Y="-13" Width="-100" Height="24" TabStop="yes" FontId="3">#(loc.ShortPrependPathLabel)</Checkbox>
2827
<Checkbox Name="InstallLauncherAllUsers" X="185" Y="-37" Width="-100" Height="24" TabStop="yes" FontId="3" HideWhenDisabled="yes">#(loc.ShortInstallLauncherAllUsersLabel)</Checkbox>
28+
<Checkbox Name="PrependPath" X="185" Y="-13" Width="-100" Height="24" TabStop="yes" FontId="3">#(loc.ShortPrependPathLabel)</Checkbox>
2929

3030
<Button Name="InstallCancelButton" X="-11" Y="-11" Width="85" Height="27" TabStop="yes" FontId="0">#(loc.CancelButton)</Button>
3131
</Page>

Tools/msi/bundle/Default.wxl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ Continue?</String>
4242
<String Id="InstallLicenseLinkText">[WixBundleName] &lt;a href="#"&gt;license terms&lt;/a&gt;.</String>
4343
<String Id="InstallAcceptCheckbox">I &amp;agree to the license terms and conditions</String>
4444
<String Id="InstallButton">&amp;Install Now</String>
45-
<String Id="InstallButtonNote">[DefaultJustForMeTargetDir]
45+
<String Id="InstallButtonNote">[TargetDir]
4646

4747
Includes IDLE, pip and documentation
4848
Creates shortcuts and file associations</String>

Tools/msi/bundle/bootstrap/PythonBootstrapperApplication.cpp

Lines changed: 36 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -293,28 +293,8 @@ class PythonBootstrapperApplication : public CBalBaseBootstrapperApplication {
293293
hr = _engine->SetVariableNumeric(L"CompileAll", installAllUsers);
294294
ExitOnFailure(hr, L"Failed to update CompileAll");
295295

296-
hr = BalGetStringVariable(L"TargetDir", &targetDir);
297-
if (FAILED(hr) || !targetDir || !targetDir[0]) {
298-
ReleaseStr(targetDir);
299-
targetDir = nullptr;
300-
301-
hr = BalGetStringVariable(
302-
installAllUsers ? L"DefaultAllUsersTargetDir" : L"DefaultJustForMeTargetDir",
303-
&defaultDir
304-
);
305-
BalExitOnFailure(hr, "Failed to get the default install directory");
306-
307-
if (!defaultDir || !defaultDir[0]) {
308-
BalLogError(E_INVALIDARG, "Default install directory is blank");
309-
}
310-
311-
hr = BalFormatString(defaultDir, &targetDir);
312-
BalExitOnFailure1(hr, "Failed to format '%ls'", defaultDir);
313-
314-
hr = _engine->SetVariableString(L"TargetDir", targetDir);
315-
BalExitOnFailure(hr, "Failed to set install target directory");
316-
}
317-
ReleaseStr(targetDir);
296+
hr = EnsureTargetDir();
297+
ExitOnFailure(hr, L"Failed to set TargetDir");
318298

319299
OnPlan(BOOTSTRAPPER_ACTION_INSTALL);
320300
break;
@@ -2972,6 +2952,39 @@ class PythonBootstrapperApplication : public CBalBaseBootstrapperApplication {
29722952
return;
29732953
}
29742954

2955+
HRESULT EnsureTargetDir() {
2956+
LONGLONG installAllUsers;
2957+
LPWSTR targetDir = nullptr, defaultDir = nullptr;
2958+
HRESULT hr = BalGetStringVariable(L"TargetDir", &targetDir);
2959+
if (FAILED(hr) || !targetDir || !targetDir[0]) {
2960+
ReleaseStr(targetDir);
2961+
targetDir = nullptr;
2962+
2963+
hr = BalGetNumericVariable(L"InstallAllUsers", &installAllUsers);
2964+
ExitOnFailure(hr, L"Failed to get install scope");
2965+
2966+
hr = BalGetStringVariable(
2967+
installAllUsers ? L"DefaultAllUsersTargetDir" : L"DefaultJustForMeTargetDir",
2968+
&defaultDir
2969+
);
2970+
BalExitOnFailure(hr, "Failed to get the default install directory");
2971+
2972+
if (!defaultDir || !defaultDir[0]) {
2973+
BalLogError(E_INVALIDARG, "Default install directory is blank");
2974+
}
2975+
2976+
hr = BalFormatString(defaultDir, &targetDir);
2977+
BalExitOnFailure1(hr, "Failed to format '%ls'", defaultDir);
2978+
2979+
hr = _engine->SetVariableString(L"TargetDir", targetDir);
2980+
BalExitOnFailure(hr, "Failed to set install target directory");
2981+
}
2982+
LExit:
2983+
ReleaseStr(defaultDir);
2984+
ReleaseStr(targetDir);
2985+
return hr;
2986+
}
2987+
29752988
public:
29762989
//
29772990
// Constructor - initialize member variables.
@@ -3057,6 +3070,7 @@ class PythonBootstrapperApplication : public CBalBaseBootstrapperApplication {
30573070
_baFunction = nullptr;
30583071

30593072
LoadOptionalFeatureStates(pEngine);
3073+
EnsureTargetDir();
30603074
}
30613075

30623076

0 commit comments

Comments
 (0)