blob: 7582b173067a42673953be1aa2ee0f9a33780821 [file] [log] [blame]
Guido van Rossum228d8072001-03-02 05:58:11 +00001#include "Python.h"
2#include "osdefs.h"
3
4static char *prefix,*exec_prefix,*progpath,*module_search_path=0;
5
6static void
7calculate_path()
8{ char *pypath=getenv("Python$Path");
9 if(pypath)
10 { module_search_path=malloc(strlen(pypath)+1);
11 if (module_search_path) sprintf(module_search_path,"%s",pypath);
12 else
13 { /* We can't exit, so print a warning and limp along */
14 fprintf(stderr, "Not enough memory for dynamic PYTHONPATH.\n");
15 fprintf(stderr, "Using default static PYTHONPATH.\n");
16 }
17 }
18 if(!module_search_path) module_search_path = "<Python$Dir>.Lib";
19 prefix="";
20 exec_prefix=prefix;
21 progpath="<Python$Dir>";
22}
23
24/* External interface */
25
26char *
27Py_GetPath()
28{
29 if (!module_search_path)
30 calculate_path();
31 return module_search_path;
32}
33
34char *
35Py_GetPrefix()
36{
37 if (!module_search_path)
38 calculate_path();
39 return prefix;
40}
41
42char *
43Py_GetExecPrefix()
44{
45 if (!module_search_path)
46 calculate_path();
47 return exec_prefix;
48}
49
50char *
51Py_GetProgramFullPath()
52{
53 if (!module_search_path)
54 calculate_path();
55 return progpath;
56}