summaryrefslogtreecommitdiffstats
path: root/PC/bdist_wininst
diff options
context:
space:
mode:
authorThomas Heller <theller@ctypes.org>2004-06-18 17:03:38 (GMT)
committerThomas Heller <theller@ctypes.org>2004-06-18 17:03:38 (GMT)
commit48340390ac23a66cc2251a12d8690207726b85be (patch)
tree5d3d2bfd4cb9242784fedc770396a4f218730293 /PC/bdist_wininst
parenta42bc21ef8017f1ea6d6fc1ce3db8333ee70a267 (diff)
downloadcpython-48340390ac23a66cc2251a12d8690207726b85be.zip
cpython-48340390ac23a66cc2251a12d8690207726b85be.tar.gz
cpython-48340390ac23a66cc2251a12d8690207726b85be.tar.bz2
When loading the Python dll to run the postinstall script, try to load
it from the install directory (as reported by the registry) in case it is not found on the default Loadlibrary search path. Fixes SF 935091: bdist_winist post-install script fails on non-admin Python Already backported.
Diffstat (limited to 'PC/bdist_wininst')
-rw-r--r--PC/bdist_wininst/install.c24
1 files changed, 20 insertions, 4 deletions
diff --git a/PC/bdist_wininst/install.c b/PC/bdist_wininst/install.c
index 64e213e..a715528 100644
--- a/PC/bdist_wininst/install.c
+++ b/PC/bdist_wininst/install.c
@@ -590,6 +590,22 @@ PyMethodDef meth[] = {
{"message_box", PyMessageBox, METH_VARARGS, NULL},
};
+static HINSTANCE LoadPythonDll(char *fname)
+{
+ char fullpath[_MAX_PATH];
+ LONG size = sizeof(fullpath);
+ HINSTANCE h = LoadLibrary(fname);
+ if (h)
+ return h;
+ if (ERROR_SUCCESS != RegQueryValue(HKEY_CURRENT_USER,
+ "SOFTWARE\\Python\\PythonCore\\2.3\\InstallPath",
+ fullpath, &size))
+ return NULL;
+ strcat(fullpath, "\\");
+ strcat(fullpath, fname);
+ return LoadLibrary(fullpath);
+}
+
static int prepare_script_environment(HINSTANCE hPython)
{
PyObject *mod;
@@ -715,7 +731,7 @@ static int run_simple_script(char *script)
freopen(tempname, "a", stderr);
freopen(tempname, "a", stdout);
- hPython = LoadLibrary (pythondll);
+ hPython = LoadPythonDll(pythondll);
if (!hPython) {
set_failure_reason("Can't load Python for pre-install script");
return -1;
@@ -1745,7 +1761,7 @@ InstallFilesDlgProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam)
"Compiling files to .pyc...");
SetDlgItemText(hDialog, IDC_INFO, "Loading python...");
- hPython = LoadLibrary(pythondll);
+ hPython = LoadPythonDll(pythondll);
if (hPython) {
errors = compile_filelist(hPython, FALSE);
FreeLibrary(hPython);
@@ -1764,7 +1780,7 @@ InstallFilesDlgProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam)
"Compiling files to .pyo...");
SetDlgItemText(hDialog, IDC_INFO, "Loading python...");
- hPython = LoadLibrary(pythondll);
+ hPython = LoadPythonDll(pythondll);
if (hPython) {
errors = compile_filelist(hPython, TRUE);
FreeLibrary(hPython);
@@ -1840,7 +1856,7 @@ FinishedDlgProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam)
argv[0] = fname;
- hPython = LoadLibrary(pythondll);
+ hPython = LoadPythonDll(pythondll);
if (hPython) {
int result;
result = run_installscript(hPython, fname, 2, argv);