Guido van Rossum | 50d4cc2 | 1997-11-22 21:59:45 +0000 | [diff] [blame] | 1 | /*********************************************************** |
Guido van Rossum | fd71b9e | 2000-06-30 23:50:40 +0000 | [diff] [blame] | 2 | Copyright (c) 2000, BeOpen.com. |
| 3 | Copyright (c) 1995-2000, Corporation for National Research Initiatives. |
| 4 | Copyright (c) 1990-1995, Stichting Mathematisch Centrum. |
| 5 | All rights reserved. |
Guido van Rossum | 50d4cc2 | 1997-11-22 21:59:45 +0000 | [diff] [blame] | 6 | |
Guido van Rossum | fd71b9e | 2000-06-30 23:50:40 +0000 | [diff] [blame] | 7 | See the file "Misc/COPYRIGHT" for information on usage and |
| 8 | redistribution of this file, and for a DISCLAIMER OF ALL WARRANTIES. |
Guido van Rossum | 50d4cc2 | 1997-11-22 21:59:45 +0000 | [diff] [blame] | 9 | ******************************************************************/ |
| 10 | |
| 11 | /* Return the initial module search path. */ |
| 12 | /* Used by DOS, OS/2, Windows 3.1. Works on NT too. */ |
| 13 | |
| 14 | #include "Python.h" |
| 15 | #include "osdefs.h" |
| 16 | |
| 17 | #ifdef MS_WIN32 |
| 18 | #include <windows.h> |
Thomas Wouters | a534594 | 2000-07-22 23:59:33 +0000 | [diff] [blame] | 19 | extern BOOL PyWin_IsWin32s(void); |
Guido van Rossum | 50d4cc2 | 1997-11-22 21:59:45 +0000 | [diff] [blame] | 20 | #endif |
| 21 | |
| 22 | #include <sys/types.h> |
| 23 | #include <sys/stat.h> |
| 24 | #include <string.h> |
| 25 | |
| 26 | #if HAVE_UNISTD_H |
| 27 | #include <unistd.h> |
| 28 | #endif /* HAVE_UNISTD_H */ |
| 29 | |
| 30 | /* Search in some common locations for the associated Python libraries. |
| 31 | * |
Guido van Rossum | a34c313 | 1997-12-05 22:07:14 +0000 | [diff] [blame] | 32 | * Two directories must be found, the platform independent directory |
| 33 | * (prefix), containing the common .py and .pyc files, and the platform |
| 34 | * dependent directory (exec_prefix), containing the shared library |
| 35 | * modules. Note that prefix and exec_prefix can be the same directory, |
| 36 | * but for some installations, they are different. |
Guido van Rossum | 50d4cc2 | 1997-11-22 21:59:45 +0000 | [diff] [blame] | 37 | * |
| 38 | * Py_GetPath() tries to return a sensible Python module search path. |
| 39 | * |
| 40 | * First, we look to see if the executable is in a subdirectory of |
| 41 | * the Python build directory. We calculate the full path of the |
| 42 | * directory containing the executable as progpath. We work backwards |
| 43 | * along progpath and look for $dir/Modules/Setup.in, a distinctive |
| 44 | * landmark. If found, we use $dir/Lib as $root. The returned |
| 45 | * Python path is the compiled #define PYTHONPATH with all the initial |
| 46 | * "./lib" replaced by $root. |
| 47 | * |
| 48 | * Otherwise, if there is a PYTHONPATH environment variable, we return that. |
| 49 | * |
Jeremy Hylton | 847a996 | 2000-05-26 21:49:07 +0000 | [diff] [blame] | 50 | * Otherwise we try to find $progpath/lib/os.py, and if found, then |
Guido van Rossum | 50d4cc2 | 1997-11-22 21:59:45 +0000 | [diff] [blame] | 51 | * root is $progpath/lib, and we return Python path as compiled PYTHONPATH |
| 52 | * with all "./lib" replaced by $root (as above). |
| 53 | * |
| 54 | */ |
| 55 | |
| 56 | #ifndef LANDMARK |
Jeremy Hylton | 847a996 | 2000-05-26 21:49:07 +0000 | [diff] [blame] | 57 | #define LANDMARK "lib\\os.py" |
Guido van Rossum | 50d4cc2 | 1997-11-22 21:59:45 +0000 | [diff] [blame] | 58 | #endif |
| 59 | |
| 60 | static char prefix[MAXPATHLEN+1]; |
Guido van Rossum | a34c313 | 1997-12-05 22:07:14 +0000 | [diff] [blame] | 61 | static char exec_prefix[MAXPATHLEN+1]; |
Guido van Rossum | 50d4cc2 | 1997-11-22 21:59:45 +0000 | [diff] [blame] | 62 | static char progpath[MAXPATHLEN+1]; |
| 63 | static char *module_search_path = NULL; |
| 64 | |
| 65 | |
| 66 | static int |
Thomas Wouters | 7889010 | 2000-07-22 19:25:51 +0000 | [diff] [blame] | 67 | is_sep(char ch) /* determine if "ch" is a separator character */ |
Guido van Rossum | 50d4cc2 | 1997-11-22 21:59:45 +0000 | [diff] [blame] | 68 | { |
| 69 | #ifdef ALTSEP |
| 70 | return ch == SEP || ch == ALTSEP; |
| 71 | #else |
| 72 | return ch == SEP; |
| 73 | #endif |
| 74 | } |
| 75 | |
| 76 | |
| 77 | static void |
Thomas Wouters | 7889010 | 2000-07-22 19:25:51 +0000 | [diff] [blame] | 78 | reduce(char *dir) |
Guido van Rossum | 50d4cc2 | 1997-11-22 21:59:45 +0000 | [diff] [blame] | 79 | { |
| 80 | int i = strlen(dir); |
| 81 | while (i > 0 && !is_sep(dir[i])) |
| 82 | --i; |
| 83 | dir[i] = '\0'; |
| 84 | } |
| 85 | |
| 86 | |
| 87 | static int |
Thomas Wouters | 7889010 | 2000-07-22 19:25:51 +0000 | [diff] [blame] | 88 | exists(char *filename) |
Guido van Rossum | 50d4cc2 | 1997-11-22 21:59:45 +0000 | [diff] [blame] | 89 | { |
| 90 | struct stat buf; |
| 91 | return stat(filename, &buf) == 0; |
| 92 | } |
| 93 | |
| 94 | |
| 95 | static void |
Thomas Wouters | 7889010 | 2000-07-22 19:25:51 +0000 | [diff] [blame] | 96 | join(char *buffer, char *stuff) |
Guido van Rossum | 50d4cc2 | 1997-11-22 21:59:45 +0000 | [diff] [blame] | 97 | { |
| 98 | int n, k; |
| 99 | if (is_sep(stuff[0])) |
| 100 | n = 0; |
| 101 | else { |
| 102 | n = strlen(buffer); |
| 103 | if (n > 0 && !is_sep(buffer[n-1]) && n < MAXPATHLEN) |
| 104 | buffer[n++] = SEP; |
| 105 | } |
| 106 | k = strlen(stuff); |
| 107 | if (n + k > MAXPATHLEN) |
| 108 | k = MAXPATHLEN - n; |
| 109 | strncpy(buffer+n, stuff, k); |
| 110 | buffer[n+k] = '\0'; |
| 111 | } |
| 112 | |
| 113 | |
| 114 | static int |
Thomas Wouters | 7889010 | 2000-07-22 19:25:51 +0000 | [diff] [blame] | 115 | search_for_prefix(char *argv0_path, char *landmark) |
Guido van Rossum | 50d4cc2 | 1997-11-22 21:59:45 +0000 | [diff] [blame] | 116 | { |
| 117 | int n; |
| 118 | |
| 119 | /* Search from argv0_path, until root is found */ |
| 120 | strcpy(prefix, argv0_path); |
| 121 | do { |
| 122 | n = strlen(prefix); |
| 123 | join(prefix, landmark); |
| 124 | if (exists(prefix)) { |
| 125 | prefix[n] = '\0'; |
| 126 | return 1; |
| 127 | } |
| 128 | prefix[n] = '\0'; |
| 129 | reduce(prefix); |
| 130 | } while (prefix[0]); |
| 131 | return 0; |
| 132 | } |
| 133 | |
| 134 | #ifdef MS_WIN32 |
| 135 | #include "malloc.h" // for alloca - see comments below! |
| 136 | extern const char *PyWin_DLLVersionString; // a string loaded from the DLL at startup. |
| 137 | |
| 138 | |
| 139 | /* Load a PYTHONPATH value from the registry. |
| 140 | Load from either HKEY_LOCAL_MACHINE or HKEY_CURRENT_USER. |
| 141 | |
| 142 | Returns NULL, or a pointer that should be freed. |
| 143 | */ |
| 144 | |
| 145 | static char * |
| 146 | getpythonregpath(HKEY keyBase, BOOL bWin32s) |
| 147 | { |
| 148 | HKEY newKey = 0; |
| 149 | DWORD nameSize = 0; |
| 150 | DWORD dataSize = 0; |
| 151 | DWORD numEntries = 0; |
| 152 | LONG rc; |
| 153 | char *retval = NULL; |
| 154 | char *dataBuf; |
| 155 | const char keyPrefix[] = "Software\\Python\\PythonCore\\"; |
| 156 | const char keySuffix[] = "\\PythonPath"; |
| 157 | int versionLen; |
| 158 | char *keyBuf; |
| 159 | |
| 160 | // Tried to use sysget("winver") but here is too early :-( |
| 161 | versionLen = strlen(PyWin_DLLVersionString); |
| 162 | // alloca == no free required, but memory only local to fn. |
| 163 | // also no heap fragmentation! Am I being silly? |
| 164 | keyBuf = alloca(sizeof(keyPrefix)-1 + versionLen + sizeof(keySuffix)); // chars only, plus 1 NULL. |
| 165 | // lots of constants here for the compiler to optimize away :-) |
| 166 | memcpy(keyBuf, keyPrefix, sizeof(keyPrefix)-1); |
| 167 | memcpy(keyBuf+sizeof(keyPrefix)-1, PyWin_DLLVersionString, versionLen); |
| 168 | memcpy(keyBuf+sizeof(keyPrefix)-1+versionLen, keySuffix, sizeof(keySuffix)); // NULL comes with this one! |
| 169 | |
| 170 | rc=RegOpenKey(keyBase, |
| 171 | keyBuf, |
| 172 | &newKey); |
| 173 | if (rc==ERROR_SUCCESS) { |
| 174 | RegQueryInfoKey(newKey, NULL, NULL, NULL, NULL, NULL, NULL, |
| 175 | &numEntries, &nameSize, &dataSize, NULL, NULL); |
| 176 | } |
| 177 | if (bWin32s && numEntries==0 && dataSize==0) { |
| 178 | /* must hardcode for Win32s */ |
| 179 | numEntries = 1; |
| 180 | dataSize = 511; |
| 181 | } |
| 182 | if (numEntries) { |
| 183 | /* Loop over all subkeys. */ |
| 184 | /* Win32s doesnt know how many subkeys, so we do |
| 185 | it twice */ |
| 186 | char keyBuf[MAX_PATH+1]; |
| 187 | int index = 0; |
| 188 | int off = 0; |
| 189 | for(index=0;;index++) { |
| 190 | long reqdSize = 0; |
| 191 | DWORD rc = RegEnumKey(newKey, |
| 192 | index, keyBuf, MAX_PATH+1); |
| 193 | if (rc) break; |
| 194 | rc = RegQueryValue(newKey, keyBuf, NULL, &reqdSize); |
| 195 | if (rc) break; |
| 196 | if (bWin32s && reqdSize==0) reqdSize = 512; |
| 197 | dataSize += reqdSize + 1; /* 1 for the ";" */ |
| 198 | } |
| 199 | dataBuf = malloc(dataSize+1); |
| 200 | if (dataBuf==NULL) |
| 201 | return NULL; /* pretty serious? Raise error? */ |
| 202 | /* Now loop over, grabbing the paths. |
| 203 | Subkeys before main library */ |
| 204 | for(index=0;;index++) { |
| 205 | int adjust; |
| 206 | long reqdSize = dataSize; |
| 207 | DWORD rc = RegEnumKey(newKey, |
| 208 | index, keyBuf,MAX_PATH+1); |
| 209 | if (rc) break; |
| 210 | rc = RegQueryValue(newKey, |
| 211 | keyBuf, dataBuf+off, &reqdSize); |
| 212 | if (rc) break; |
| 213 | if (reqdSize>1) { |
| 214 | /* If Nothing, or only '\0' copied. */ |
| 215 | adjust = strlen(dataBuf+off); |
| 216 | dataSize -= adjust; |
| 217 | off += adjust; |
| 218 | dataBuf[off++] = ';'; |
| 219 | dataBuf[off] = '\0'; |
| 220 | dataSize--; |
| 221 | } |
| 222 | } |
| 223 | /* Additionally, win32s doesnt work as expected, so |
| 224 | the specific strlen() is required for 3.1. */ |
| 225 | rc = RegQueryValue(newKey, "", dataBuf+off, &dataSize); |
| 226 | if (rc==ERROR_SUCCESS) { |
| 227 | if (strlen(dataBuf)==0) |
| 228 | free(dataBuf); |
| 229 | else |
| 230 | retval = dataBuf; /* caller will free */ |
| 231 | } |
| 232 | else |
| 233 | free(dataBuf); |
| 234 | } |
| 235 | |
| 236 | if (newKey) |
| 237 | RegCloseKey(newKey); |
| 238 | return retval; |
| 239 | } |
| 240 | #endif /* MS_WIN32 */ |
| 241 | |
| 242 | static void |
Thomas Wouters | 7889010 | 2000-07-22 19:25:51 +0000 | [diff] [blame] | 243 | get_progpath(void) |
Guido van Rossum | 50d4cc2 | 1997-11-22 21:59:45 +0000 | [diff] [blame] | 244 | { |
Thomas Wouters | a534594 | 2000-07-22 23:59:33 +0000 | [diff] [blame] | 245 | extern char *Py_GetProgramName(void); |
Guido van Rossum | 50d4cc2 | 1997-11-22 21:59:45 +0000 | [diff] [blame] | 246 | char *path = getenv("PATH"); |
| 247 | char *prog = Py_GetProgramName(); |
| 248 | |
| 249 | #ifdef MS_WIN32 |
| 250 | if (GetModuleFileName(NULL, progpath, MAXPATHLEN)) |
| 251 | return; |
| 252 | #endif |
| 253 | if (prog == NULL || *prog == '\0') |
| 254 | prog = "python"; |
| 255 | |
| 256 | /* If there is no slash in the argv0 path, then we have to |
| 257 | * assume python is on the user's $PATH, since there's no |
| 258 | * other way to find a directory to start the search from. If |
| 259 | * $PATH isn't exported, you lose. |
| 260 | */ |
| 261 | #ifdef ALTSEP |
| 262 | if (strchr(prog, SEP) || strchr(prog, ALTSEP)) |
| 263 | #else |
| 264 | if (strchr(prog, SEP)) |
| 265 | #endif |
| 266 | strcpy(progpath, prog); |
| 267 | else if (path) { |
| 268 | while (1) { |
| 269 | char *delim = strchr(path, DELIM); |
| 270 | |
| 271 | if (delim) { |
| 272 | int len = delim - path; |
| 273 | strncpy(progpath, path, len); |
| 274 | *(progpath + len) = '\0'; |
| 275 | } |
| 276 | else |
| 277 | strcpy(progpath, path); |
| 278 | |
| 279 | join(progpath, prog); |
| 280 | if (exists(progpath)) |
| 281 | break; |
| 282 | |
| 283 | if (!delim) { |
| 284 | progpath[0] = '\0'; |
| 285 | break; |
| 286 | } |
| 287 | path = delim + 1; |
| 288 | } |
| 289 | } |
| 290 | else |
| 291 | progpath[0] = '\0'; |
| 292 | } |
| 293 | |
| 294 | static void |
Thomas Wouters | 7889010 | 2000-07-22 19:25:51 +0000 | [diff] [blame] | 295 | calculate_path(void) |
Guido van Rossum | 50d4cc2 | 1997-11-22 21:59:45 +0000 | [diff] [blame] | 296 | { |
| 297 | char argv0_path[MAXPATHLEN+1]; |
| 298 | char *buf; |
| 299 | int bufsz; |
Guido van Rossum | 28700c4 | 1998-07-27 13:49:04 +0000 | [diff] [blame] | 300 | char *pythonhome = Py_GetPythonHome(); |
Guido van Rossum | 50d4cc2 | 1997-11-22 21:59:45 +0000 | [diff] [blame] | 301 | char *envpath = getenv("PYTHONPATH"); |
| 302 | #ifdef MS_WIN32 |
| 303 | char *machinepath, *userpath; |
| 304 | |
| 305 | /* Are we running under Windows 3.1(1) Win32s? */ |
| 306 | if (PyWin_IsWin32s()) { |
| 307 | /* Only CLASSES_ROOT is supported */ |
| 308 | machinepath = getpythonregpath(HKEY_CLASSES_ROOT, TRUE); |
| 309 | userpath = NULL; |
| 310 | } else { |
| 311 | machinepath = getpythonregpath(HKEY_LOCAL_MACHINE, FALSE); |
| 312 | userpath = getpythonregpath(HKEY_CURRENT_USER, FALSE); |
| 313 | } |
| 314 | #endif |
| 315 | |
| 316 | get_progpath(); |
| 317 | strcpy(argv0_path, progpath); |
| 318 | reduce(argv0_path); |
| 319 | if (pythonhome == NULL || *pythonhome == '\0') { |
| 320 | if (search_for_prefix(argv0_path, LANDMARK)) |
| 321 | pythonhome = prefix; |
| 322 | else |
| 323 | pythonhome = NULL; |
| 324 | } |
Guido van Rossum | a34c313 | 1997-12-05 22:07:14 +0000 | [diff] [blame] | 325 | else { |
| 326 | char *delim; |
| 327 | |
Guido van Rossum | 50d4cc2 | 1997-11-22 21:59:45 +0000 | [diff] [blame] | 328 | strcpy(prefix, pythonhome); |
| 329 | |
Guido van Rossum | a34c313 | 1997-12-05 22:07:14 +0000 | [diff] [blame] | 330 | /* Extract Any Optional Trailing EXEC_PREFIX */ |
| 331 | /* e.g. PYTHONHOME=<prefix>:<exec_prefix> */ |
| 332 | delim = strchr(prefix, DELIM); |
| 333 | if (delim) { |
| 334 | *delim = '\0'; |
| 335 | strcpy(exec_prefix, delim+1); |
| 336 | } else |
| 337 | strcpy(exec_prefix, EXEC_PREFIX); |
| 338 | } |
| 339 | |
Guido van Rossum | 50d4cc2 | 1997-11-22 21:59:45 +0000 | [diff] [blame] | 340 | if (envpath && *envpath == '\0') |
| 341 | envpath = NULL; |
| 342 | |
| 343 | /* We need to construct a path from the following parts: |
| 344 | (1) the PYTHONPATH environment variable, if set; |
| 345 | (2) for Win32, the machinepath and userpath, if set; |
| 346 | (3) the PYTHONPATH config macro, with the leading "." |
| 347 | of each component replaced with pythonhome, if set; |
| 348 | (4) the directory containing the executable (argv0_path). |
| 349 | The length calculation calculates #3 first. |
| 350 | */ |
| 351 | |
| 352 | /* Calculate size of return buffer */ |
| 353 | if (pythonhome != NULL) { |
| 354 | char *p; |
| 355 | bufsz = 1; |
| 356 | for (p = PYTHONPATH; *p; p++) { |
| 357 | if (*p == DELIM) |
| 358 | bufsz++; /* number of DELIM plus one */ |
| 359 | } |
| 360 | bufsz *= strlen(pythonhome); |
| 361 | } |
| 362 | else |
| 363 | bufsz = 0; |
Guido van Rossum | d0ec761 | 1997-12-11 15:21:33 +0000 | [diff] [blame] | 364 | bufsz += strlen(PYTHONPATH) + 1; |
Guido van Rossum | 50d4cc2 | 1997-11-22 21:59:45 +0000 | [diff] [blame] | 365 | if (envpath != NULL) |
| 366 | bufsz += strlen(envpath) + 1; |
| 367 | bufsz += strlen(argv0_path) + 1; |
| 368 | #ifdef MS_WIN32 |
| 369 | if (machinepath) |
| 370 | bufsz += strlen(machinepath) + 1; |
| 371 | if (userpath) |
| 372 | bufsz += strlen(userpath) + 1; |
| 373 | #endif |
| 374 | |
| 375 | module_search_path = buf = malloc(bufsz); |
| 376 | if (buf == NULL) { |
| 377 | /* We can't exit, so print a warning and limp along */ |
| 378 | fprintf(stderr, "Can't malloc dynamic PYTHONPATH.\n"); |
| 379 | if (envpath) { |
| 380 | fprintf(stderr, "Using default static $PYTHONPATH.\n"); |
| 381 | module_search_path = envpath; |
| 382 | } |
| 383 | else { |
| 384 | fprintf(stderr, "Using environment $PYTHONPATH.\n"); |
| 385 | module_search_path = PYTHONPATH; |
| 386 | } |
| 387 | return; |
| 388 | } |
| 389 | |
| 390 | if (envpath) { |
| 391 | strcpy(buf, envpath); |
| 392 | buf = strchr(buf, '\0'); |
| 393 | *buf++ = DELIM; |
| 394 | } |
| 395 | #ifdef MS_WIN32 |
| 396 | if (machinepath) { |
| 397 | strcpy(buf, machinepath); |
| 398 | buf = strchr(buf, '\0'); |
| 399 | *buf++ = DELIM; |
| 400 | } |
| 401 | if (userpath) { |
| 402 | strcpy(buf, userpath); |
| 403 | buf = strchr(buf, '\0'); |
| 404 | *buf++ = DELIM; |
| 405 | } |
| 406 | #endif |
| 407 | if (pythonhome == NULL) { |
| 408 | strcpy(buf, PYTHONPATH); |
| 409 | buf = strchr(buf, '\0'); |
| 410 | } |
| 411 | else { |
| 412 | char *p = PYTHONPATH; |
| 413 | char *q; |
| 414 | int n; |
| 415 | for (;;) { |
| 416 | q = strchr(p, DELIM); |
| 417 | if (q == NULL) |
| 418 | n = strlen(p); |
| 419 | else |
| 420 | n = q-p; |
| 421 | if (p[0] == '.' && is_sep(p[1])) { |
| 422 | strcpy(buf, pythonhome); |
| 423 | buf = strchr(buf, '\0'); |
| 424 | p++; |
| 425 | n--; |
| 426 | } |
| 427 | strncpy(buf, p, n); |
| 428 | buf += n; |
| 429 | if (q == NULL) |
| 430 | break; |
| 431 | *buf++ = DELIM; |
| 432 | p = q+1; |
| 433 | } |
| 434 | } |
| 435 | if (argv0_path) { |
| 436 | *buf++ = DELIM; |
| 437 | strcpy(buf, argv0_path); |
| 438 | buf = strchr(buf, '\0'); |
| 439 | } |
| 440 | *buf = '\0'; |
| 441 | } |
| 442 | |
| 443 | |
| 444 | /* External interface */ |
| 445 | |
| 446 | char * |
Thomas Wouters | 7889010 | 2000-07-22 19:25:51 +0000 | [diff] [blame] | 447 | Py_GetPath(void) |
Guido van Rossum | 50d4cc2 | 1997-11-22 21:59:45 +0000 | [diff] [blame] | 448 | { |
| 449 | if (!module_search_path) |
| 450 | calculate_path(); |
| 451 | |
| 452 | return module_search_path; |
| 453 | } |
| 454 | |
| 455 | char * |
Thomas Wouters | 7889010 | 2000-07-22 19:25:51 +0000 | [diff] [blame] | 456 | Py_GetPrefix(void) |
Guido van Rossum | 50d4cc2 | 1997-11-22 21:59:45 +0000 | [diff] [blame] | 457 | { |
| 458 | if (!module_search_path) |
| 459 | calculate_path(); |
| 460 | |
| 461 | return prefix; |
| 462 | } |
| 463 | |
| 464 | char * |
Thomas Wouters | 7889010 | 2000-07-22 19:25:51 +0000 | [diff] [blame] | 465 | Py_GetExecPrefix(void) |
Guido van Rossum | 50d4cc2 | 1997-11-22 21:59:45 +0000 | [diff] [blame] | 466 | { |
Guido van Rossum | a34c313 | 1997-12-05 22:07:14 +0000 | [diff] [blame] | 467 | if (!module_search_path) |
| 468 | calculate_path(); |
| 469 | |
| 470 | return exec_prefix; |
Guido van Rossum | 50d4cc2 | 1997-11-22 21:59:45 +0000 | [diff] [blame] | 471 | } |
| 472 | |
| 473 | char * |
Thomas Wouters | 7889010 | 2000-07-22 19:25:51 +0000 | [diff] [blame] | 474 | Py_GetProgramFullPath(void) |
Guido van Rossum | 50d4cc2 | 1997-11-22 21:59:45 +0000 | [diff] [blame] | 475 | { |
| 476 | if (!module_search_path) |
| 477 | calculate_path(); |
| 478 | |
| 479 | return progpath; |
| 480 | } |