[Python-checkins] python/dist/src/PC/bdist_wininst install.c, 1.1, 1.1.14.1

theller at users.sourceforge.net theller at users.sourceforge.net
Thu Apr 15 13:50:45 EDT 2004


Update of /cvsroot/python/python/dist/src/PC/bdist_wininst
In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv10767

Modified Files:
      Tag: release23-maint
	install.c 
Log Message:
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

Will port to the trunk later.


Index: install.c
===================================================================
RCS file: /cvsroot/python/python/dist/src/PC/bdist_wininst/install.c,v
retrieving revision 1.1
retrieving revision 1.1.14.1
diff -C2 -d -r1.1 -r1.1.14.1
*** install.c	22 Nov 2002 20:39:33 -0000	1.1
--- install.c	15 Apr 2004 17:50:42 -0000	1.1.14.1
***************
*** 1353,1364 ****
  						result = sscanf(pbuf, "Python Version %d.%d",
  								 &py_major, &py_minor);
! 						if (result == 2)
  #ifdef _DEBUG
! 							wsprintf(pythondll, "c:\\python22\\PCBuild\\python%d%d_d.dll",
! 								  py_major, py_minor);
  #else
! 						wsprintf(pythondll, "python%d%d.dll",
! 							  py_major, py_minor);
  #endif
  						free(pbuf);
  					} else
--- 1353,1365 ----
  						result = sscanf(pbuf, "Python Version %d.%d",
  								 &py_major, &py_minor);
! 						if (result == 2) {
  #ifdef _DEBUG
! 							wsprintf(pythondll, "python%d%d_d.dll",
! 								 py_major, py_minor);
  #else
! 							wsprintf(pythondll, "python%d%d.dll",
! 								 py_major, py_minor);
  #endif
+ 						}
  						free(pbuf);
  					} else
***************
*** 1524,1527 ****
--- 1525,1544 ----
  }
  
+ 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);
+ }
+ 
  BOOL CALLBACK
  InstallFilesDlgProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam)
***************
*** 1617,1621 ****
  
  				SetDlgItemText(hDialog, IDC_INFO, "Loading python...");
! 				hPython = LoadLibrary(pythondll);
  				if (hPython) {
  					errors = compile_filelist(hPython, FALSE);
--- 1634,1638 ----
  
  				SetDlgItemText(hDialog, IDC_INFO, "Loading python...");
! 				hPython = LoadPythonDll(pythondll);
  				if (hPython) {
  					errors = compile_filelist(hPython, FALSE);
***************
*** 1636,1640 ****
  
  				SetDlgItemText(hDialog, IDC_INFO, "Loading python...");
! 				hPython = LoadLibrary(pythondll);
  				if (hPython) {
  					errors = compile_filelist(hPython, TRUE);
--- 1653,1657 ----
  
  				SetDlgItemText(hDialog, IDC_INFO, "Loading python...");
! 				hPython = LoadPythonDll(pythondll);
  				if (hPython) {
  					errors = compile_filelist(hPython, TRUE);
***************
*** 1712,1716 ****
  			argv[0] = fname;
  
! 			hPython = LoadLibrary(pythondll);
  			if (hPython) {
  				int result;
--- 1729,1733 ----
  			argv[0] = fname;
  
! 			hPython = LoadPythonDll(pythondll);
  			if (hPython) {
  				int result;




More information about the Python-checkins mailing list