Mercurial > cpython-lru_cache-weakref
view Modules/getpath.c @ 3546:3f7cdf1663f7 legacy-trunk
A version of swed that can import html files. Also demonstrates
implementing object handlers in Python.
| author | Jack Jansen <jack.jansen@cwi.nl> |
|---|---|
| date | Tue, 07 May 1996 15:25:36 +0000 |
| parents | b6c0a41e4a46 |
| children | f158edccc72c |
line wrap: on
line source
#include "Python.h" #include "osdefs.h" #ifdef HAVE_STDLIB_H #include <stdlib.h> #else extern char *getenv Py_PROTO((const char *)); #endif #ifndef PYTHONPATH #define PYTHONPATH ".:/usr/local/lib/python" #endif /* Return the initial python search path. This is called once from initsys() to initialize sys.path. The environment variable PYTHONPATH is fetched and the default path appended. The default path may be passed to the preprocessor; if not, a system-dependent default is used. */ char * getpythonpath() { char *path = getenv("PYTHONPATH"); char *defpath = PYTHONPATH; static char *buf = NULL; char *p; int n; if (path == NULL) path = ""; n = strlen(path) + strlen(defpath) + 2; if (buf != NULL) { free(buf); buf = NULL; } buf = malloc(n); if (buf == NULL) Py_FatalError("not enough memory to copy module search path"); strcpy(buf, path); p = buf + strlen(buf); if (p != buf) *p++ = DELIM; strcpy(p, defpath); return buf; }
