blob: 0330b84e7f910296c53034b7ef36ed4e61b6d828 [file] [log] [blame]
Guido van Rossum582646a1996-05-28 22:30:17 +00001/***********************************************************
2Copyright 1991-1995 by Stichting Mathematisch Centrum, Amsterdam,
3The Netherlands.
4
5 All Rights Reserved
6
Guido van Rossumd266eb41996-10-25 14:44:06 +00007Permission to use, copy, modify, and distribute this software and its
8documentation for any purpose and without fee is hereby granted,
Guido van Rossum582646a1996-05-28 22:30:17 +00009provided that the above copyright notice appear in all copies and that
Guido van Rossumd266eb41996-10-25 14:44:06 +000010both that copyright notice and this permission notice appear in
Guido van Rossum582646a1996-05-28 22:30:17 +000011supporting documentation, and that the names of Stichting Mathematisch
Guido van Rossumd266eb41996-10-25 14:44:06 +000012Centrum or CWI or Corporation for National Research Initiatives or
13CNRI not be used in advertising or publicity pertaining to
14distribution of the software without specific, written prior
15permission.
Guido van Rossum582646a1996-05-28 22:30:17 +000016
Guido van Rossumd266eb41996-10-25 14:44:06 +000017While CWI is the initial source for this software, a modified version
18is made available by the Corporation for National Research Initiatives
19(CNRI) at the Internet address ftp://ftp.python.org.
20
21STICHTING MATHEMATISCH CENTRUM AND CNRI DISCLAIM ALL WARRANTIES WITH
22REGARD TO THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF
23MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL STICHTING MATHEMATISCH
24CENTRUM OR CNRI BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL
25DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR
26PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
27TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
28PERFORMANCE OF THIS SOFTWARE.
Guido van Rossum582646a1996-05-28 22:30:17 +000029
30******************************************************************/
31
32/* Return the initial module search path. */
33
Guido van Rossum667d7041995-08-04 04:20:48 +000034#include "Python.h"
35#include "osdefs.h"
36
Guido van Rossum305e5d01997-04-11 17:18:45 +000037#include <sys/types.h>
38#include <sys/stat.h>
Guido van Rossum21f84971997-06-02 22:18:31 +000039#include <string.h>
Guido van Rossum667d7041995-08-04 04:20:48 +000040
Guido van Rossum305e5d01997-04-11 17:18:45 +000041#if HAVE_UNISTD_H
42#include <unistd.h>
43#endif /* HAVE_UNISTD_H */
44
45/* Search in some common locations for the associated Python libraries.
46 *
47 * Two directories must be found, the platform independent directory
Barry Warsaw90126031997-04-11 20:27:03 +000048 * (prefix), containing the common .py and .pyc files, and the platform
49 * dependent directory (exec_prefix), containing the shared library
50 * modules. Note that prefix and exec_prefix can be the same directory,
51 * but for some installations, they are different.
Guido van Rossum305e5d01997-04-11 17:18:45 +000052 *
Barry Warsaw90126031997-04-11 20:27:03 +000053 * Py_GetPath() carries out separate searches for prefix and exec_prefix.
54 * Each search tries a number of different locations until a ``landmark''
55 * file or directory is found. If no prefix or exec_prefix is found, a
56 * warning message is issued and the preprocessor defined PREFIX and
57 * EXEC_PREFIX are used (even though they will not work); python carries on
58 * as best as is possible, but most imports will fail.
Guido van Rossum305e5d01997-04-11 17:18:45 +000059 *
60 * Before any searches are done, the location of the executable is
Barry Warsaw90126031997-04-11 20:27:03 +000061 * determined. If argv[0] has one or more slashs in it, it is used
62 * unchanged. Otherwise, it must have been invoked from the shell's path,
63 * so we search $PATH for the named executable and use that. If the
64 * executable was not found on $PATH (or there was no $PATH environment
65 * variable), the original argv[0] string is used.
Guido van Rossum305e5d01997-04-11 17:18:45 +000066 *
Barry Warsaw90126031997-04-11 20:27:03 +000067 * Next, the executable location is examined to see if it is a symbolic
68 * link. If so, the link is chased (correctly interpreting a relative
69 * pathname if one is found) and the directory of the link target is used.
Guido van Rossum305e5d01997-04-11 17:18:45 +000070 *
Barry Warsaw90126031997-04-11 20:27:03 +000071 * Finally, argv0_path is set to the directory containing the executable
72 * (i.e. the last component is stripped).
Guido van Rossum305e5d01997-04-11 17:18:45 +000073 *
Barry Warsaw90126031997-04-11 20:27:03 +000074 * With argv0_path in hand, we perform a number of steps. The same steps
75 * are performed for prefix and for exec_prefix, but with a different
76 * landmark.
Guido van Rossum305e5d01997-04-11 17:18:45 +000077 *
78 * Step 1. Are we running python out of the build directory? This is
79 * checked by looking for a different kind of landmark relative to
Barry Warsaw90126031997-04-11 20:27:03 +000080 * argv0_path. For prefix, the landmark's path is derived from the VPATH
81 * preprocessor variable (taking into account that its value is almost, but
82 * not quite, what we need). For exec_prefix, the landmark is
83 * Modules/Setup. If the landmark is found, we're done.
Guido van Rossum305e5d01997-04-11 17:18:45 +000084 *
85 * For the remaining steps, the prefix landmark will always be
86 * lib/python$VERSION/string.py and the exec_prefix will always be
Guido van Rossum266033e1997-10-20 23:20:32 +000087 * lib/python$VERSION/lib-dynload, where $VERSION is Python's version
Barry Warsaw90126031997-04-11 20:27:03 +000088 * number as supplied by the Makefile. Note that this means that no more
89 * build directory checking is performed; if the first step did not find
90 * the landmarks, the assumption is that python is running from an
91 * installed setup.
Guido van Rossum305e5d01997-04-11 17:18:45 +000092 *
93 * Step 2. See if the $PYTHONHOME environment variable points to the
Barry Warsaw90126031997-04-11 20:27:03 +000094 * installed location of the Python libraries. If $PYTHONHOME is set, then
95 * it points to prefix and exec_prefix. $PYTHONHOME can be a single
96 * directory, which is used for both, or the prefix and exec_prefix
97 * directories separated by a colon.
Guido van Rossum305e5d01997-04-11 17:18:45 +000098 *
99 * Step 3. Try to find prefix and exec_prefix relative to argv0_path,
Barry Warsaw90126031997-04-11 20:27:03 +0000100 * backtracking up the path until it is exhausted. This is the most common
101 * step to succeed. Note that if prefix and exec_prefix are different,
102 * exec_prefix is more likely to be found; however if exec_prefix is a
103 * subdirectory of prefix, both will be found.
Guido van Rossum305e5d01997-04-11 17:18:45 +0000104 *
Barry Warsaw90126031997-04-11 20:27:03 +0000105 * Step 4. Search the directories pointed to by the preprocessor variables
106 * PREFIX and EXEC_PREFIX. These are supplied by the Makefile but can be
107 * passed in as options to the configure script.
Guido van Rossum305e5d01997-04-11 17:18:45 +0000108 *
Barry Warsaw90126031997-04-11 20:27:03 +0000109 * That's it!
110 *
111 * Well, almost. Once we have determined prefix and exec_prefix, the
112 * preprocesor variable PYTHONPATH is used to construct a path. Each
113 * relative path on PYTHONPATH is prefixed with prefix. Then the directory
114 * containing the shared library modules is appended. The environment
115 * variable $PYTHONPATH is inserted in front of it all. Finally, the
116 * prefix and exec_prefix globals are tweaked so they reflect the values
117 * expected by other code, by stripping the "lib/python$VERSION/..." stuff
118 * off. If either points to the build directory, the globals are reset to
119 * the corresponding preprocessor variables (so sys.prefix will reflect the
120 * installation location, even though sys.path points into the build
121 * directory). This seems to make more sense given that currently the only
122 * known use of sys.prefix and sys.exec_prefix is for the ILU installation
123 * process to find the installed Python tree.
124 */
Guido van Rossum305e5d01997-04-11 17:18:45 +0000125
126#ifndef VERSION
127#define VERSION "1.5"
128#endif
129
130#ifndef VPATH
131#define VPATH "."
Guido van Rossum667d7041995-08-04 04:20:48 +0000132#endif
133
Guido van Rossumc34c9a51996-06-12 04:20:27 +0000134#ifndef PREFIX
135#define PREFIX "/usr/local"
136#endif
137
138#ifndef EXEC_PREFIX
Guido van Rossum6e12d561996-07-30 20:36:12 +0000139#define EXEC_PREFIX PREFIX
Guido van Rossumc34c9a51996-06-12 04:20:27 +0000140#endif
141
Guido van Rossum305e5d01997-04-11 17:18:45 +0000142#ifndef PYTHONPATH
143/* I know this isn't K&R C, but the Makefile specifies it anyway */
144#define PYTHONPATH PREFIX "/lib/python" VERSION ":" \
Guido van Rossum266033e1997-10-20 23:20:32 +0000145 EXEC_PREFIX "/lib/python" VERSION "/lib-dynload"
Guido van Rossum305e5d01997-04-11 17:18:45 +0000146#endif
Guido van Rossum667d7041995-08-04 04:20:48 +0000147
Guido van Rossum305e5d01997-04-11 17:18:45 +0000148#ifndef LANDMARK
149#define LANDMARK "string.py"
150#endif
151
Guido van Rossum305e5d01997-04-11 17:18:45 +0000152static char prefix[MAXPATHLEN+1];
153static char exec_prefix[MAXPATHLEN+1];
Guido van Rossum7929c6f1997-05-20 22:38:21 +0000154static char progpath[MAXPATHLEN+1];
Guido van Rossum305e5d01997-04-11 17:18:45 +0000155static char *module_search_path = NULL;
156static char lib_python[20]; /* Dynamically set to "lib/python" VERSION */
157
158static void
159reduce(dir)
160 char *dir;
161{
162 int i = strlen(dir);
163 while (i > 0 && dir[i] != SEP)
164 --i;
165 dir[i] = '\0';
166}
167
168
169static int
170exists(filename)
171 char *filename;
172{
173 struct stat buf;
174 return stat(filename, &buf) == 0;
175}
176
177
178static void
Guido van Rossum6b9fdf51997-08-20 23:48:16 +0000179joinpath(buffer, stuff)
Guido van Rossum305e5d01997-04-11 17:18:45 +0000180 char *buffer;
181 char *stuff;
182{
183 int n, k;
184 if (stuff[0] == SEP)
185 n = 0;
186 else {
187 n = strlen(buffer);
188 if (n > 0 && buffer[n-1] != SEP && n < MAXPATHLEN)
189 buffer[n++] = SEP;
190 }
191 k = strlen(stuff);
192 if (n + k > MAXPATHLEN)
193 k = MAXPATHLEN - n;
194 strncpy(buffer+n, stuff, k);
195 buffer[n+k] = '\0';
196}
197
198
Guido van Rossum305e5d01997-04-11 17:18:45 +0000199static int
200search_for_prefix(argv0_path, home)
201 char *argv0_path;
202 char *home;
203{
Guido van Rossum7d3246d1997-05-13 19:19:41 +0000204 int n;
Guido van Rossum305e5d01997-04-11 17:18:45 +0000205 char *vpath;
206
Guido van Rossum573a24a1997-05-12 20:49:39 +0000207 /* Check to see if argv[0] is in the build directory */
Guido van Rossum305e5d01997-04-11 17:18:45 +0000208 strcpy(prefix, argv0_path);
Guido van Rossum6b9fdf51997-08-20 23:48:16 +0000209 joinpath(prefix, "Modules/Setup");
Guido van Rossum573a24a1997-05-12 20:49:39 +0000210 if (exists(prefix)) {
211 /* Check VPATH to see if argv0_path is in the build directory.
212 * Complication: the VPATH passed in is relative to the
213 * Modules build directory and points to the Modules source
214 * directory; we need it relative to the build tree and
215 * pointing to the source tree. Solution: chop off a leading
216 * ".." (but only if it's there -- it could be an absolute
217 * path) and chop off the final component (assuming it's
218 * "Modules").
219 */
220 vpath = VPATH;
221 if (vpath[0] == '.' && vpath[1] == '.' && vpath[2] == '/')
222 vpath += 3;
223 strcpy(prefix, argv0_path);
Guido van Rossum6b9fdf51997-08-20 23:48:16 +0000224 joinpath(prefix, vpath);
Guido van Rossum573a24a1997-05-12 20:49:39 +0000225 reduce(prefix);
Guido van Rossum6b9fdf51997-08-20 23:48:16 +0000226 joinpath(prefix, "Lib");
227 joinpath(prefix, LANDMARK);
Guido van Rossum573a24a1997-05-12 20:49:39 +0000228 if (exists(prefix))
229 return -1;
230 }
Guido van Rossum305e5d01997-04-11 17:18:45 +0000231
232 if (home) {
233 /* Check $PYTHONHOME */
234 char *delim;
235 strcpy(prefix, home);
236 delim = strchr(prefix, DELIM);
237 if (delim)
238 *delim = '\0';
Guido van Rossum6b9fdf51997-08-20 23:48:16 +0000239 joinpath(prefix, lib_python);
240 joinpath(prefix, LANDMARK);
Guido van Rossum305e5d01997-04-11 17:18:45 +0000241 if (exists(prefix))
242 return 1;
243 }
244
245 /* Search from argv0_path, until root is found */
246 strcpy(prefix, argv0_path);
247 do {
248 n = strlen(prefix);
Guido van Rossum6b9fdf51997-08-20 23:48:16 +0000249 joinpath(prefix, lib_python);
250 joinpath(prefix, LANDMARK);
Guido van Rossum305e5d01997-04-11 17:18:45 +0000251 if (exists(prefix))
252 return 1;
253 prefix[n] = '\0';
254 reduce(prefix);
255 } while (prefix[0]);
256
257 /* Look at configure's PREFIX */
258 strcpy(prefix, PREFIX);
Guido van Rossum6b9fdf51997-08-20 23:48:16 +0000259 joinpath(prefix, lib_python);
260 joinpath(prefix, LANDMARK);
Guido van Rossum305e5d01997-04-11 17:18:45 +0000261 if (exists(prefix))
262 return 1;
263
Guido van Rossumd7763621997-05-12 20:53:23 +0000264 /* Fail */
Guido van Rossum305e5d01997-04-11 17:18:45 +0000265 return 0;
266}
267
268
269static int
270search_for_exec_prefix(argv0_path, home)
271 char *argv0_path;
272 char *home;
273{
Guido van Rossum7d3246d1997-05-13 19:19:41 +0000274 int n;
Guido van Rossum305e5d01997-04-11 17:18:45 +0000275
276 /* Check to see if argv[0] is in the build directory */
277 strcpy(exec_prefix, argv0_path);
Guido van Rossum6b9fdf51997-08-20 23:48:16 +0000278 joinpath(exec_prefix, "Modules/Setup");
Guido van Rossum305e5d01997-04-11 17:18:45 +0000279 if (exists(exec_prefix)) {
280 reduce(exec_prefix);
281 return -1;
282 }
283
284 if (home) {
285 /* Check $PYTHONHOME */
286 char *delim;
287 delim = strchr(home, DELIM);
288 if (delim)
289 strcpy(exec_prefix, delim+1);
290 else
291 strcpy(exec_prefix, home);
Guido van Rossum6b9fdf51997-08-20 23:48:16 +0000292 joinpath(exec_prefix, lib_python);
Guido van Rossum266033e1997-10-20 23:20:32 +0000293 joinpath(exec_prefix, "lib-dynload");
Guido van Rossum305e5d01997-04-11 17:18:45 +0000294 if (exists(exec_prefix))
295 return 1;
296 }
297
298 /* Search from argv0_path, until root is found */
299 strcpy(exec_prefix, argv0_path);
300 do {
301 n = strlen(exec_prefix);
Guido van Rossum6b9fdf51997-08-20 23:48:16 +0000302 joinpath(exec_prefix, lib_python);
Guido van Rossum266033e1997-10-20 23:20:32 +0000303 joinpath(exec_prefix, "lib-dynload");
Guido van Rossum305e5d01997-04-11 17:18:45 +0000304 if (exists(exec_prefix))
305 return 1;
306 exec_prefix[n] = '\0';
307 reduce(exec_prefix);
308 } while (exec_prefix[0]);
309
310 /* Look at configure's EXEC_PREFIX */
311 strcpy(exec_prefix, EXEC_PREFIX);
Guido van Rossum6b9fdf51997-08-20 23:48:16 +0000312 joinpath(exec_prefix, lib_python);
Guido van Rossum266033e1997-10-20 23:20:32 +0000313 joinpath(exec_prefix, "lib-dynload");
Guido van Rossum305e5d01997-04-11 17:18:45 +0000314 if (exists(exec_prefix))
315 return 1;
316
Guido van Rossumd7763621997-05-12 20:53:23 +0000317 /* Fail */
Guido van Rossum305e5d01997-04-11 17:18:45 +0000318 return 0;
319}
320
321
322static void
323calculate_path()
324{
325 extern char *Py_GetProgramName();
326
Guido van Rossum7929c6f1997-05-20 22:38:21 +0000327 static char delimiter[2] = {DELIM, '\0'};
328 static char separator[2] = {SEP, '\0'};
Guido van Rossum305e5d01997-04-11 17:18:45 +0000329 char *pythonpath = PYTHONPATH;
330 char *rtpypath = getenv("PYTHONPATH");
331 char *home = getenv("PYTHONHOME");
332 char *path = getenv("PATH");
333 char *prog = Py_GetProgramName();
334 char argv0_path[MAXPATHLEN+1];
Guido van Rossum305e5d01997-04-11 17:18:45 +0000335 int pfound, efound; /* 1 if found; -1 if found build directory */
336 char *buf;
337 int bufsz;
338 int prefixsz;
339 char *defpath = pythonpath;
340
341 /* Initialize this dynamically for K&R C */
342 sprintf(lib_python, "lib/python%s", VERSION);
343
344 /* If there is no slash in the argv0 path, then we have to
345 * assume python is on the user's $PATH, since there's no
346 * other way to find a directory to start the search from. If
347 * $PATH isn't exported, you lose.
348 */
349 if (strchr(prog, SEP))
350 strcpy(progpath, prog);
351 else if (path) {
352 while (1) {
353 char *delim = strchr(path, DELIM);
354
355 if (delim) {
356 int len = delim - path;
357 strncpy(progpath, path, len);
358 *(progpath + len) = '\0';
359 }
360 else
361 strcpy(progpath, path);
362
Guido van Rossum6b9fdf51997-08-20 23:48:16 +0000363 joinpath(progpath, prog);
Guido van Rossum305e5d01997-04-11 17:18:45 +0000364 if (exists(progpath))
365 break;
366
367 if (!delim) {
368 progpath[0] = '\0';
369 break;
370 }
371 path = delim + 1;
372 }
373 }
374 else
375 progpath[0] = '\0';
376
377 strcpy(argv0_path, progpath);
378
379#if HAVE_READLINK
380 {
381 char tmpbuffer[MAXPATHLEN+1];
382 int linklen = readlink(progpath, tmpbuffer, MAXPATHLEN);
383 if (linklen != -1) {
384 /* It's not null terminated! */
385 tmpbuffer[linklen] = '\0';
386 if (tmpbuffer[0] == SEP)
387 strcpy(argv0_path, tmpbuffer);
388 else {
389 /* Interpret relative to progpath */
390 reduce(argv0_path);
Guido van Rossum6b9fdf51997-08-20 23:48:16 +0000391 joinpath(argv0_path, tmpbuffer);
Guido van Rossum305e5d01997-04-11 17:18:45 +0000392 }
393 }
394 }
395#endif /* HAVE_READLINK */
396
397 reduce(argv0_path);
398
399 if (!(pfound = search_for_prefix(argv0_path, home))) {
400 fprintf(stderr,
401 "Could not find platform independent libraries <prefix>\n");
402 strcpy(prefix, PREFIX);
Guido van Rossum6b9fdf51997-08-20 23:48:16 +0000403 joinpath(prefix, lib_python);
Guido van Rossum305e5d01997-04-11 17:18:45 +0000404 }
405 else
406 reduce(prefix);
407
408 if (!(efound = search_for_exec_prefix(argv0_path, home))) {
409 fprintf(stderr,
410 "Could not find platform dependent libraries <exec_prefix>\n");
411 strcpy(exec_prefix, EXEC_PREFIX);
Guido van Rossum266033e1997-10-20 23:20:32 +0000412 joinpath(exec_prefix, "lib/lib-dynload");
Guido van Rossum305e5d01997-04-11 17:18:45 +0000413 }
414 /* If we found EXEC_PREFIX do *not* reduce it! (Yet.) */
415
416 if (!pfound || !efound)
417 fprintf(stderr,
418 "Consider setting $PYTHONHOME to <prefix>[:<exec_prefix>]\n");
419
420 /* Calculate size of return buffer.
421 */
422 bufsz = 0;
423
424 if (rtpypath)
425 bufsz += strlen(rtpypath) + 1;
426
427 prefixsz = strlen(prefix) + 1;
428
429 while (1) {
430 char *delim = strchr(defpath, DELIM);
431
432 if (defpath[0] != SEP)
433 /* Paths are relative to prefix */
434 bufsz += prefixsz;
435
436 if (delim)
437 bufsz += delim - defpath + 1;
438 else {
439 bufsz += strlen(defpath) + 1;
440 break;
441 }
442 defpath = delim + 1;
443 }
444
445 bufsz += strlen(exec_prefix) + 1;
446
447 /* This is the only malloc call in this file */
448 buf = malloc(bufsz);
449
450 if (buf == NULL) {
451 /* We can't exit, so print a warning and limp along */
452 fprintf(stderr, "Not enough memory for dynamic PYTHONPATH.\n");
453 fprintf(stderr, "Using default static PYTHONPATH.\n");
454 module_search_path = PYTHONPATH;
455 }
456 else {
457 /* Run-time value of $PYTHONPATH goes first */
458 if (rtpypath) {
459 strcpy(buf, rtpypath);
460 strcat(buf, delimiter);
461 }
Guido van Rossum573a24a1997-05-12 20:49:39 +0000462 else
463 buf[0] = '\0';
Guido van Rossum305e5d01997-04-11 17:18:45 +0000464
465 /* Next goes merge of compile-time $PYTHONPATH with
466 * dynamically located prefix.
467 */
468 defpath = pythonpath;
469 while (1) {
470 char *delim = strchr(defpath, DELIM);
471
472 if (defpath[0] != SEP) {
473 strcat(buf, prefix);
474 strcat(buf, separator);
475 }
476
477 if (delim) {
478 int len = delim - defpath + 1;
479 int end = strlen(buf) + len;
480 strncat(buf, defpath, len);
481 *(buf + end) = '\0';
482 }
483 else {
484 strcat(buf, defpath);
485 break;
486 }
487 defpath = delim + 1;
488 }
489 strcat(buf, delimiter);
490
491 /* Finally, on goes the directory for dynamic-load modules */
492 strcat(buf, exec_prefix);
493
494 /* And publish the results */
495 module_search_path = buf;
496 }
497
498 /* Reduce prefix and exec_prefix to their essence,
499 * e.g. /usr/local/lib/python1.5 is reduced to /usr/local.
500 * If we're loading relative to the build directory,
501 * return the compiled-in defaults instead.
502 */
503 if (pfound > 0) {
504 reduce(prefix);
505 reduce(prefix);
506 }
507 else
508 strcpy(prefix, PREFIX);
509
510 if (efound > 0) {
511 reduce(exec_prefix);
512 reduce(exec_prefix);
513 reduce(exec_prefix);
514 }
515 else
516 strcpy(exec_prefix, EXEC_PREFIX);
517}
518
519
520/* External interface */
Guido van Rossum667d7041995-08-04 04:20:48 +0000521
522char *
Guido van Rossum582646a1996-05-28 22:30:17 +0000523Py_GetPath()
Guido van Rossum667d7041995-08-04 04:20:48 +0000524{
Guido van Rossum305e5d01997-04-11 17:18:45 +0000525 if (!module_search_path)
526 calculate_path();
527 return module_search_path;
Guido van Rossum667d7041995-08-04 04:20:48 +0000528}
Guido van Rossumc34c9a51996-06-12 04:20:27 +0000529
Guido van Rossumc34c9a51996-06-12 04:20:27 +0000530char *
531Py_GetPrefix()
532{
Guido van Rossum305e5d01997-04-11 17:18:45 +0000533 if (!module_search_path)
534 calculate_path();
535 return prefix;
Guido van Rossumc34c9a51996-06-12 04:20:27 +0000536}
537
538char *
539Py_GetExecPrefix()
540{
Guido van Rossum305e5d01997-04-11 17:18:45 +0000541 if (!module_search_path)
542 calculate_path();
543 return exec_prefix;
Guido van Rossumc34c9a51996-06-12 04:20:27 +0000544}
Guido van Rossum7929c6f1997-05-20 22:38:21 +0000545
546char *
547Py_GetProgramFullPath()
548{
549 if (!module_search_path)
550 calculate_path();
551 return progpath;
552}