(original) (raw)
diff -r 66e30c4870bb .bzrignore --- a/.bzrignore Thu Mar 21 15:02:16 2013 -0700 +++ b/.bzrignore Thu Mar 21 22:55:56 2013 -0700 @@ -11,6 +11,7 @@ build Makefile.pre platform +pybuilddir.txt pyconfig.h libpython*.a libpython*.so* diff -r 66e30c4870bb .hgignore --- a/.hgignore Thu Mar 21 15:02:16 2013 -0700 +++ b/.hgignore Thu Mar 21 22:55:56 2013 -0700 @@ -35,6 +35,7 @@ Parser/pgen.stamp$ ^core ^python-gdb.py +^pybuilddir.txt syntax: glob python.exe-gdb.py diff -r 66e30c4870bb Lib/site.py --- a/Lib/site.py Thu Mar 21 15:02:16 2013 -0700 +++ b/Lib/site.py Thu Mar 21 22:55:56 2013 -0700 @@ -114,18 +114,6 @@ sys.path[:] = L return known_paths -# XXX This should not be part of site.py, since it is needed even when -# using the -S option for Python. See http://www.python.org/sf/586680 -def addbuilddir(): - """Append ./build/lib. in case we're running in the build dir - (especially for Guido :-)""" - from sysconfig import get_platform - s = "build/lib.%s-%.3s" % (get_platform(), sys.version) - if hasattr(sys, 'gettotalrefcount'): - s += '-pydebug' - s = os.path.join(os.path.dirname(sys.path.pop()), s) - sys.path.append(s) - def _init_pathinfo(): """Return a set containing all existing directory entries from sys.path""" @@ -537,9 +525,6 @@ abs__file__() known_paths = removeduppaths() - if (os.name == "posix" and sys.path and - os.path.basename(sys.path[-1]) == "Modules"): - addbuilddir() if ENABLE_USER_SITE is None: ENABLE_USER_SITE = check_enableusersite() known_paths = addusersitepackages(known_paths) diff -r 66e30c4870bb Makefile.pre.in --- a/Makefile.pre.in Thu Mar 21 15:02:16 2013 -0700 +++ b/Makefile.pre.in Thu Mar 21 22:55:56 2013 -0700 @@ -1294,6 +1294,7 @@ Modules/Setup Modules/Setup.local Modules/Setup.config \ Modules/ld_so_aix Modules/python.exp Misc/python.pc -rm -f python*-gdb.py + -rm -f pybuilddir.txt find $(srcdir) '(' -name '*.fdc' -o -name '*~' \ -o -name '[@,#]*' -o -name '*.old' \ -o -name '*.orig' -o -name '*.rej' \ diff -r 66e30c4870bb Modules/getpath.c --- a/Modules/getpath.c Thu Mar 21 15:02:16 2013 -0700 +++ b/Modules/getpath.c Thu Mar 21 22:55:56 2013 -0700 @@ -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 */