Some changes to make it work on NT; add the directory where the binary
lives to the end of the path. (Still to do: add $PYTHONPATH to the front instead of using it as is; add the Win32 registry paths as in getpath_nt.c (which can then retire).)
This commit is contained in:
parent
0e6ae93894
commit
8f1b651980
|
@ -35,6 +35,10 @@ PERFORMANCE OF THIS SOFTWARE.
|
||||||
#include "Python.h"
|
#include "Python.h"
|
||||||
#include "osdefs.h"
|
#include "osdefs.h"
|
||||||
|
|
||||||
|
#ifdef MS_WIN32
|
||||||
|
#include <windows.h>
|
||||||
|
#endif
|
||||||
|
|
||||||
#include <sys/types.h>
|
#include <sys/types.h>
|
||||||
#include <sys/stat.h>
|
#include <sys/stat.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
|
@ -149,7 +153,6 @@ static void
|
||||||
get_progpath()
|
get_progpath()
|
||||||
{
|
{
|
||||||
#ifdef MS_WIN32
|
#ifdef MS_WIN32
|
||||||
#include <windows.h>
|
|
||||||
if (!GetModuleFileName(NULL, progpath, MAXPATHLEN))
|
if (!GetModuleFileName(NULL, progpath, MAXPATHLEN))
|
||||||
progpath[0] = '\0'; /* failure */
|
progpath[0] = '\0'; /* failure */
|
||||||
#else
|
#else
|
||||||
|
@ -239,6 +242,7 @@ calculate_path()
|
||||||
if (*pt == DELIM)
|
if (*pt == DELIM)
|
||||||
bufsz++; /* number of DELIM plus one */
|
bufsz++; /* number of DELIM plus one */
|
||||||
bufsz *= strlen(PYTHONPATH) + strlen(prefix); /* high estimate */
|
bufsz *= strlen(PYTHONPATH) + strlen(prefix); /* high estimate */
|
||||||
|
bufsz += strlen(argv0_path) + 1;
|
||||||
|
|
||||||
module_search_path = buf = malloc(bufsz);
|
module_search_path = buf = malloc(bufsz);
|
||||||
|
|
||||||
|
@ -251,7 +255,7 @@ calculate_path()
|
||||||
}
|
}
|
||||||
for (pt = PYTHONPATH; *pt; pt++) {
|
for (pt = PYTHONPATH; *pt; pt++) {
|
||||||
if (!strncmp(pt, ".\\lib", 5) &&
|
if (!strncmp(pt, ".\\lib", 5) &&
|
||||||
((ch = *(pt + 5)) == '\\' || ch == DELIM || !ch)){
|
((ch = *(pt + 5)) == '\\' || ch == DELIM || !ch)) {
|
||||||
pt += 4;
|
pt += 4;
|
||||||
for (pt2 = prefix; *pt2; pt2++)
|
for (pt2 = prefix; *pt2; pt2++)
|
||||||
*buf++ = *pt2;
|
*buf++ = *pt2;
|
||||||
|
@ -259,6 +263,9 @@ calculate_path()
|
||||||
else
|
else
|
||||||
*buf++ = *pt;
|
*buf++ = *pt;
|
||||||
}
|
}
|
||||||
|
*buf++ = DELIM;
|
||||||
|
strcpy(buf, argv0_path);
|
||||||
|
buf += strlen(buf);
|
||||||
*buf = '\0';
|
*buf = '\0';
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue