Index: setup.py =================================================================== --- setup.py (révision 83978) +++ setup.py (copie de travail) @@ -22,6 +22,9 @@ # This global variable is used to hold the list of modules to be disabled. disabled_module_list = [] +# File which contains the build dir for shared mods (for Lib/site.py) +_BUILDDIR_COOKIE = "pybuilddir.txt" + def add_dir_to_list(dirlist, dir): """Add the directory 'dir' to the list 'dirlist' (at the front) if 1) 'dir' is not already in 'dirlist' @@ -254,6 +257,9 @@ print("Failed to build these modules:") print_three_column(failed) print() + + with open(_BUILDDIR_COOKIE, "w") as f: + f.write(self.build_lib) def build_extension(self, ext): Index: Lib/site.py =================================================================== --- Lib/site.py (révision 83978) +++ Lib/site.py (copie de travail) @@ -68,7 +68,11 @@ USER_SITE = None USER_BASE = None +# File which contains the build dir for shared mods if not installed. +_BUILDDIR_COOKIE = os.path.join( + os.path.dirname(os.path.dirname(__file__)), "pybuilddir.txt") + def makepath(*paths): dir = os.path.abspath(os.path.join(*paths)) return dir, os.path.normcase(dir) @@ -112,14 +116,10 @@ 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) + basedir = os.path.dirname(sys.path.pop()) + with open(_BUILDDIR_COOKIE, "r") as f: + sys.path.append(os.path.join(basedir, f.read())) - def _init_pathinfo(): """Return a set containing all existing directory entries from sys.path""" d = set() @@ -530,7 +530,8 @@ abs_paths() known_paths = removeduppaths() if (os.name == "posix" and sys.path and - os.path.basename(sys.path[-1]) == "Modules"): + os.path.basename(sys.path[-1]) == "Modules" and + os.path.exists(_BUILDDIR_COOKIE)): addbuilddir() if ENABLE_USER_SITE is None: ENABLE_USER_SITE = check_enableusersite()