File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -307,7 +307,7 @@ calculate_path()
307307 char argv0_path [MAXPATHLEN + 1 ];
308308 char * buf ;
309309 int bufsz ;
310- char * pythonhome = getenv ( "PYTHONHOME" );
310+ char * pythonhome = Py_GetPythonHome ( );
311311 char * envpath = getenv ("PYTHONPATH" );
312312#ifdef MS_WIN32
313313 char * machinepath , * userpath ;
@@ -329,8 +329,19 @@ calculate_path()
329329 if (pythonhome == NULL || * pythonhome == '\0' ) {
330330 if (search_for_prefix (argv0_path , LANDMARK ))
331331 pythonhome = prefix ;
332- else
333- pythonhome = NULL ;
332+ else {
333+ /* Couldnt find a source version - lets see if a compiled version exists. */
334+ char LANDMARK_Look [MAX_PATH + 1 ];
335+ strcpy (LANDMARK_Look , LANDMARK );
336+ /* Turn it into ".pyc" or ".pyc" depending on the current mode. */
337+ strcat (LANDMARK_Look , Py_OptimizeFlag ? "o" : "c" );
338+ /* And search again */
339+ if (search_for_prefix (argv0_path , LANDMARK_Look ))
340+ pythonhome = prefix ;
341+ else
342+ /* Give up in disgust - just use the default! */
343+ pythonhome = NULL ;
344+ }
334345 }
335346 else
336347 strcpy (prefix , pythonhome );
@@ -478,3 +489,4 @@ Py_GetProgramFullPath()
478489 calculate_path ();
479490 return progpath ;
480491}
492+
You can’t perform that action at this time.
0 commit comments