[Python-checkins] cpython (3.5): Issue #25163: Display correct directory in installer when using non-default

steve.dower python-checkins at python.org
Sun Oct 11 18:38:01 EDT 2015


https://hg.python.org/cpython/rev/919b1dffa741
changeset:   98693:919b1dffa741
branch:      3.5
parent:      98691:15f6bbe944fa
user:        Steve Dower <steve.dower at microsoft.com>
date:        Sun Oct 11 15:37:22 2015 -0700
summary:
  Issue #25163: Display correct directory in installer when using non-default settings.

files:
  Misc/NEWS                                                    |   3 +
  Tools/msi/bundle/Default.thm                                 |   2 +-
  Tools/msi/bundle/Default.wxl                                 |   2 +-
  Tools/msi/bundle/bootstrap/PythonBootstrapperApplication.cpp |  58 ++++++---
  4 files changed, 41 insertions(+), 24 deletions(-)


diff --git a/Misc/NEWS b/Misc/NEWS
--- a/Misc/NEWS
+++ b/Misc/NEWS
@@ -308,6 +308,9 @@
 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
--- a/Tools/msi/bundle/Default.thm
+++ b/Tools/msi/bundle/Default.thm
@@ -24,8 +24,8 @@
         <Button Name="InstallButton" X="185" Y="101" Width="-11" Height="109" TabStop="yes" FontId="3" HexStyle="0xE">#(loc.InstallButton)</Button>
         <Button Name="InstallCustomButton" X="185" Y="221" Width="-11" Height="59" TabStop="yes" FontId="3" HexStyle="0xE">#(loc.InstallCustomButton)</Button>
 
+        <Checkbox Name="InstallLauncherAllUsers" X="185" Y="-37" Width="-100" Height="24" TabStop="yes" FontId="3" HideWhenDisabled="yes">#(loc.ShortInstallLauncherAllUsersLabel)</Checkbox>
         <Checkbox Name="PrependPath" X="185" Y="-13" Width="-100" Height="24" TabStop="yes" FontId="3">#(loc.ShortPrependPathLabel)</Checkbox>
-        <Checkbox Name="InstallLauncherAllUsers" X="185" Y="-37" Width="-100" Height="24" TabStop="yes" FontId="3" HideWhenDisabled="yes">#(loc.ShortInstallLauncherAllUsersLabel)</Checkbox>
 
         <Button Name="InstallCancelButton" X="-11" Y="-11" Width="85" Height="27" TabStop="yes" FontId="0">#(loc.CancelButton)</Button>
     </Page>
diff --git a/Tools/msi/bundle/Default.wxl b/Tools/msi/bundle/Default.wxl
--- a/Tools/msi/bundle/Default.wxl
+++ b/Tools/msi/bundle/Default.wxl
@@ -42,7 +42,7 @@
   <String Id="InstallLicenseLinkText">[WixBundleName] <a href="#">license terms</a>.</String>
   <String Id="InstallAcceptCheckbox">I &agree to the license terms and conditions</String>
   <String Id="InstallButton">&Install Now</String>
-  <String Id="InstallButtonNote">[DefaultJustForMeTargetDir]
+  <String Id="InstallButtonNote">[TargetDir]
 
 Includes IDLE, pip and documentation
 Creates shortcuts and file associations</String>
diff --git a/Tools/msi/bundle/bootstrap/PythonBootstrapperApplication.cpp b/Tools/msi/bundle/bootstrap/PythonBootstrapperApplication.cpp
--- a/Tools/msi/bundle/bootstrap/PythonBootstrapperApplication.cpp
+++ b/Tools/msi/bundle/bootstrap/PythonBootstrapperApplication.cpp
@@ -293,28 +293,8 @@
             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 @@
         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 @@
         _baFunction = nullptr;
 
         LoadOptionalFeatureStates(pEngine);
+        EnsureTargetDir();
     }
 
 

-- 
Repository URL: https://hg.python.org/cpython


More information about the Python-checkins mailing list