[Python-checkins] cpython (3.5): Issue #26071: bdist_wininst created binaries fail to start and find 32bit Python

steve.dower python-checkins at python.org
Sat Jan 16 16:55:28 EST 2016


https://hg.python.org/cpython/rev/daa6fdaf9835
changeset:   99942:daa6fdaf9835
branch:      3.5
parent:      99940:1a2cfa52f749
user:        Steve Dower <steve.dower at microsoft.com>
date:        Sat Jan 16 13:54:53 2016 -0800
summary:
  Issue #26071: bdist_wininst created binaries fail to start and find 32bit Python

files:
  Lib/distutils/command/wininst-14.0-amd64.exe |  Bin 
  Lib/distutils/command/wininst-14.0.exe       |  Bin 
  Misc/NEWS                                    |    3 +
  PC/bdist_wininst/bdist_wininst.vcxproj       |    2 +
  PC/bdist_wininst/install.c                   |   17 ++++++++-
  5 files changed, 19 insertions(+), 3 deletions(-)


diff --git a/Lib/distutils/command/wininst-14.0-amd64.exe b/Lib/distutils/command/wininst-14.0-amd64.exe
index 7a5e78d52bcc5db0be1baff6cdad41e172a5b81f..22299543a97ffc1525a3b1c778cb158d6c6430ad
GIT binary patch
[stripped]
diff --git a/Lib/distutils/command/wininst-14.0.exe b/Lib/distutils/command/wininst-14.0.exe
index cc43296b677a5b995899bb60bbe0e632163e64ae..0dac1103d98db0af1e9027c41fe921136c5f6396
GIT binary patch
[stripped]
diff --git a/Misc/NEWS b/Misc/NEWS
--- a/Misc/NEWS
+++ b/Misc/NEWS
@@ -173,6 +173,9 @@
 Windows
 -------
 
+- Issue #26071: bdist_wininst created binaries fail to start and find
+  32bit Python
+
 - Issue #26073: Update the list of magic numbers in launcher
 
 - Issue #26065: Excludes venv from library when generating embeddable
diff --git a/PC/bdist_wininst/bdist_wininst.vcxproj b/PC/bdist_wininst/bdist_wininst.vcxproj
--- a/PC/bdist_wininst/bdist_wininst.vcxproj
+++ b/PC/bdist_wininst/bdist_wininst.vcxproj
@@ -70,6 +70,8 @@
       <Optimization>MinSpace</Optimization>
       <AdditionalIncludeDirectories>$(PySourcePath)Modules\zlib;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
       <PreprocessorDefinitions>_CRT_SECURE_NO_DEPRECATE;_CRT_NONSTDC_NO_DEPRECATE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
+      <RuntimeLibrary Condition="'$(Configuration)'=='Debug'">MultiThreadedDebug</RuntimeLibrary>
+      <RuntimeLibrary Condition="'$(Configuration)'=='Release'">MultiThreaded</RuntimeLibrary>
     </ClCompile>
     <ResourceCompile>
       <AdditionalIncludeDirectories>$(PySourcePath)PC\bdist_wininst;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
diff --git a/PC/bdist_wininst/install.c b/PC/bdist_wininst/install.c
--- a/PC/bdist_wininst/install.c
+++ b/PC/bdist_wininst/install.c
@@ -153,6 +153,13 @@
 HANDLE hBitmap;
 char *bitmap_bytes;
 
+static const char *REGISTRY_SUFFIX_6432 =
+#ifdef MS_WIN64
+                                          "";
+#else
+                                          "-32";
+#endif
+
 
 #define WM_NUMFILES WM_USER+1
 /* wParam: 0, lParam: total number of files */
@@ -657,8 +664,8 @@
     if (h)
         return h;
     wsprintf(subkey_name,
-             "SOFTWARE\\Python\\PythonCore\\%d.%d\\InstallPath",
-             py_major, py_minor);
+             "SOFTWARE\\Python\\PythonCore\\%d.%d%s\\InstallPath",
+             py_major, py_minor, REGISTRY_SUFFIX_6432);
     if (ERROR_SUCCESS != RegQueryValue(HKEY_CURRENT_USER, subkey_name,
                                        fullpath, &size) &&
         ERROR_SUCCESS != RegQueryValue(HKEY_LOCAL_MACHINE, subkey_name,
@@ -666,7 +673,9 @@
         return NULL;
     strcat(fullpath, "\\");
     strcat(fullpath, fname);
-    return LoadLibrary(fullpath);
+    // We use LOAD_WITH_ALTERED_SEARCH_PATH to ensure any dependent DLLs
+    // next to the Python DLL (eg, the CRT DLL) are also loaded.
+    return LoadLibraryEx(fullpath, NULL, LOAD_WITH_ALTERED_SEARCH_PATH);
 }
 
 static int prepare_script_environment(HINSTANCE hPython)
@@ -2250,6 +2259,8 @@
     GetPrivateProfileString("Setup", "user_access_control", "",
                              user_access_control, sizeof(user_access_control), ini_file);
 
+    strcat(target_version, REGISTRY_SUFFIX_6432);
+
     // See if we need to do the Vista UAC magic.
     if (strcmp(user_access_control, "force")==0) {
         if (!MyIsUserAnAdmin()) {

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


More information about the Python-checkins mailing list