Mercurial > cpython-lru_cache-weakref
diff Modules/getpath.c @ 83198:be3b4aa2ad28 2.7
- Issue #13150, #17512: sysconfig no longer parses the Makefile and config.h
files when imported, instead doing it at build time. This makes importing
sysconfig faster and reduces Python startup time by 20%.
| author | doko@ubuntu.com |
|---|---|
| date | Mon, 08 Apr 2013 21:20:09 +0200 |
| parents | fa6e50208d93 |
| children |
line wrap: on
line diff
--- a/Modules/getpath.c Mon Apr 08 16:03:30 2013 +0000 +++ b/Modules/getpath.c Mon Apr 08 21:20:09 2013 +0200 @@ -335,12 +335,27 @@ return 1; } - /* Check to see if argv[0] is in the build directory */ + /* Check to see if argv[0] is in the build directory. "pybuilddir.txt" + is written by setup.py and contains the relative path to the location + of shared library modules. */ strcpy(exec_prefix, argv0_path); - joinpath(exec_prefix, "Modules/Setup"); + joinpath(exec_prefix, "pybuilddir.txt"); if (isfile(exec_prefix)) { - reduce(exec_prefix); - return -1; + FILE *f = fopen(exec_prefix, "r"); + if (f == NULL) + errno = 0; + else { + char rel_builddir_path[MAXPATHLEN+1]; + size_t n; + n = fread(rel_builddir_path, 1, MAXPATHLEN, f); + rel_builddir_path[n] = '\0'; + fclose(f); + if (n >= 0) { + strcpy(exec_prefix, argv0_path); + joinpath(exec_prefix, rel_builddir_path); + return -1; + } + } } /* Search from argv0_path, until root is found */
