equal
deleted
inserted
replaced
65 /* file pyscript isn't there, take <pyscript>exe.py */ |
65 /* file pyscript isn't there, take <pyscript>exe.py */ |
66 strcat_s(pyscript, sizeof(pyscript), "exe.py"); |
66 strcat_s(pyscript, sizeof(pyscript), "exe.py"); |
67 } |
67 } |
68 |
68 |
69 pydll = NULL; |
69 pydll = NULL; |
|
70 /* |
|
71 We first check, that environment variable PYTHONHOME is *not* set. |
|
72 This just mimicks the behavior of the regular python.exe, which uses |
|
73 PYTHONHOME to find its installation directory (if it has been set). |
|
74 Note: Users of HackableMercurial are expected to *not* set PYTHONHOME! |
|
75 */ |
70 if (GetEnvironmentVariable("PYTHONHOME", envpyhome, |
76 if (GetEnvironmentVariable("PYTHONHOME", envpyhome, |
71 sizeof(envpyhome)) == 0) |
77 sizeof(envpyhome)) == 0) |
72 { |
78 { |
73 /* environment var PYTHONHOME is not set */ |
79 /* |
|
80 Environment var PYTHONHOME is *not* set. Let's see if we are |
|
81 running inside a HackableMercurial. |
|
82 */ |
74 |
83 |
75 p = strrchr(pyhome, '\\'); |
84 p = strrchr(pyhome, '\\'); |
76 if (p == NULL) { |
85 if (p == NULL) { |
77 err = "can't find backslash in module filename"; |
86 err = "can't find backslash in module filename"; |
78 goto bail; |
87 goto bail; |
88 FindClose(hfind); |
97 FindClose(hfind); |
89 strcpy_s(pydllfile, sizeof(pydllfile), pyhome); |
98 strcpy_s(pydllfile, sizeof(pydllfile), pyhome); |
90 strcat_s(pydllfile, sizeof(pydllfile), "\\" HGPYTHONLIB); |
99 strcat_s(pydllfile, sizeof(pydllfile), "\\" HGPYTHONLIB); |
91 pydll = LoadLibrary(pydllfile); |
100 pydll = LoadLibrary(pydllfile); |
92 if (pydll == NULL) { |
101 if (pydll == NULL) { |
93 err = "failed to load private Python DLL"; |
102 err = "failed to load private Python DLL " |
|
103 HGPYTHONLIB ".dll"; |
94 goto bail; |
104 goto bail; |
95 } |
105 } |
96 Py_SetPythonHome = (void*)GetProcAddress(pydll, |
106 Py_SetPythonHome = (void*)GetProcAddress(pydll, |
97 "Py_SetPythonHome"); |
107 "Py_SetPythonHome"); |
98 if (Py_SetPythonHome == NULL) { |
108 if (Py_SetPythonHome == NULL) { |
104 } |
114 } |
105 |
115 |
106 if (pydll == NULL) { |
116 if (pydll == NULL) { |
107 pydll = LoadLibrary(HGPYTHONLIB); |
117 pydll = LoadLibrary(HGPYTHONLIB); |
108 if (pydll == NULL) { |
118 if (pydll == NULL) { |
109 err = "failed to load Python DLL"; |
119 err = "failed to load Python DLL " HGPYTHONLIB ".dll"; |
110 goto bail; |
120 goto bail; |
111 } |
121 } |
112 } |
122 } |
113 |
123 |
114 Py_Main = (void*)GetProcAddress(pydll, "Py_Main"); |
124 Py_Main = (void*)GetProcAddress(pydll, "Py_Main"); |