diff --git a/Misc/NEWS b/Misc/NEWS index 08c72c38903..9252a723f1e 100644 --- a/Misc/NEWS +++ b/Misc/NEWS @@ -308,6 +308,9 @@ Build Windows ------- +- Issue #25163: Display correct directory in installer when using non-default + settings. + - Issue #25361: Disables use of SSE2 instructions in Windows 32-bit build - Issue #25089: Adds logging to installer for case where launcher is not diff --git a/Tools/msi/bundle/Default.thm b/Tools/msi/bundle/Default.thm index f575a98fa24..e223112f212 100644 --- a/Tools/msi/bundle/Default.thm +++ b/Tools/msi/bundle/Default.thm @@ -24,8 +24,8 @@ - #(loc.ShortPrependPathLabel) #(loc.ShortInstallLauncherAllUsersLabel) + #(loc.ShortPrependPathLabel) diff --git a/Tools/msi/bundle/Default.wxl b/Tools/msi/bundle/Default.wxl index f3d89d9348c..7357649fe0b 100644 --- a/Tools/msi/bundle/Default.wxl +++ b/Tools/msi/bundle/Default.wxl @@ -42,7 +42,7 @@ Continue? [WixBundleName] <a href="#">license terms</a>. I &agree to the license terms and conditions &Install Now - [DefaultJustForMeTargetDir] + [TargetDir] Includes IDLE, pip and documentation Creates shortcuts and file associations diff --git a/Tools/msi/bundle/bootstrap/PythonBootstrapperApplication.cpp b/Tools/msi/bundle/bootstrap/PythonBootstrapperApplication.cpp index bc418e0014f..43f30175078 100644 --- a/Tools/msi/bundle/bootstrap/PythonBootstrapperApplication.cpp +++ b/Tools/msi/bundle/bootstrap/PythonBootstrapperApplication.cpp @@ -293,28 +293,8 @@ class PythonBootstrapperApplication : public CBalBaseBootstrapperApplication { hr = _engine->SetVariableNumeric(L"CompileAll", installAllUsers); ExitOnFailure(hr, L"Failed to update CompileAll"); - hr = BalGetStringVariable(L"TargetDir", &targetDir); - if (FAILED(hr) || !targetDir || !targetDir[0]) { - ReleaseStr(targetDir); - targetDir = nullptr; - - hr = BalGetStringVariable( - installAllUsers ? L"DefaultAllUsersTargetDir" : L"DefaultJustForMeTargetDir", - &defaultDir - ); - BalExitOnFailure(hr, "Failed to get the default install directory"); - - if (!defaultDir || !defaultDir[0]) { - BalLogError(E_INVALIDARG, "Default install directory is blank"); - } - - hr = BalFormatString(defaultDir, &targetDir); - BalExitOnFailure1(hr, "Failed to format '%ls'", defaultDir); - - hr = _engine->SetVariableString(L"TargetDir", targetDir); - BalExitOnFailure(hr, "Failed to set install target directory"); - } - ReleaseStr(targetDir); + hr = EnsureTargetDir(); + ExitOnFailure(hr, L"Failed to set TargetDir"); OnPlan(BOOTSTRAPPER_ACTION_INSTALL); break; @@ -2972,6 +2952,39 @@ private: return; } + HRESULT EnsureTargetDir() { + LONGLONG installAllUsers; + LPWSTR targetDir = nullptr, defaultDir = nullptr; + HRESULT hr = BalGetStringVariable(L"TargetDir", &targetDir); + if (FAILED(hr) || !targetDir || !targetDir[0]) { + ReleaseStr(targetDir); + targetDir = nullptr; + + hr = BalGetNumericVariable(L"InstallAllUsers", &installAllUsers); + ExitOnFailure(hr, L"Failed to get install scope"); + + hr = BalGetStringVariable( + installAllUsers ? L"DefaultAllUsersTargetDir" : L"DefaultJustForMeTargetDir", + &defaultDir + ); + BalExitOnFailure(hr, "Failed to get the default install directory"); + + if (!defaultDir || !defaultDir[0]) { + BalLogError(E_INVALIDARG, "Default install directory is blank"); + } + + hr = BalFormatString(defaultDir, &targetDir); + BalExitOnFailure1(hr, "Failed to format '%ls'", defaultDir); + + hr = _engine->SetVariableString(L"TargetDir", targetDir); + BalExitOnFailure(hr, "Failed to set install target directory"); + } + LExit: + ReleaseStr(defaultDir); + ReleaseStr(targetDir); + return hr; + } + public: // // Constructor - initialize member variables. @@ -3057,6 +3070,7 @@ public: _baFunction = nullptr; LoadOptionalFeatureStates(pEngine); + EnsureTargetDir(); }