mirror of https://github.com/python/cpython.git
Two changes:
(1) Use Py_GetPythonHome() instead of getenv("PYTHONHOME"); (2) Mark Hammond's patch to search for .pyc/.pyo landmark as well.
This commit is contained in:
parent
76310fcc47
commit
8b2b3ce4be
|
@ -307,7 +307,7 @@ calculate_path()
|
||||||
char argv0_path[MAXPATHLEN+1];
|
char argv0_path[MAXPATHLEN+1];
|
||||||
char *buf;
|
char *buf;
|
||||||
int bufsz;
|
int bufsz;
|
||||||
char *pythonhome = getenv("PYTHONHOME");
|
char *pythonhome = Py_GetPythonHome();
|
||||||
char *envpath = getenv("PYTHONPATH");
|
char *envpath = getenv("PYTHONPATH");
|
||||||
#ifdef MS_WIN32
|
#ifdef MS_WIN32
|
||||||
char *machinepath, *userpath;
|
char *machinepath, *userpath;
|
||||||
|
@ -329,9 +329,20 @@ calculate_path()
|
||||||
if (pythonhome == NULL || *pythonhome == '\0') {
|
if (pythonhome == NULL || *pythonhome == '\0') {
|
||||||
if (search_for_prefix(argv0_path, LANDMARK))
|
if (search_for_prefix(argv0_path, LANDMARK))
|
||||||
pythonhome = prefix;
|
pythonhome = prefix;
|
||||||
|
else {
|
||||||
|
/* Couldnt find a source version - lets see if a compiled version exists. */
|
||||||
|
char LANDMARK_Look[MAX_PATH+1];
|
||||||
|
strcpy(LANDMARK_Look, LANDMARK);
|
||||||
|
/* Turn it into ".pyc" or ".pyc" depending on the current mode. */
|
||||||
|
strcat(LANDMARK_Look, Py_OptimizeFlag ? "o": "c");
|
||||||
|
/* And search again */
|
||||||
|
if (search_for_prefix(argv0_path, LANDMARK_Look))
|
||||||
|
pythonhome = prefix;
|
||||||
else
|
else
|
||||||
|
/* Give up in disgust - just use the default! */
|
||||||
pythonhome = NULL;
|
pythonhome = NULL;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
else
|
else
|
||||||
strcpy(prefix, pythonhome);
|
strcpy(prefix, pythonhome);
|
||||||
|
|
||||||
|
@ -478,3 +489,4 @@ Py_GetProgramFullPath()
|
||||||
calculate_path();
|
calculate_path();
|
||||||
return progpath;
|
return progpath;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue