diff options
author | Antoine Pitrou <solipsis@pitrou.net> | 2010-08-13 22:25:01 (GMT) |
---|---|---|
committer | Antoine Pitrou <solipsis@pitrou.net> | 2010-08-13 22:25:01 (GMT) |
commit | e9b428f9977f8733e6b0d2c321c093779f95080f (patch) | |
tree | 2583b8f93efed20d9d849cbd1b001e4282e32f00 /setup.py | |
parent | 09c449c7de0fea077ceaee5cb04017d6994341e7 (diff) | |
download | cpython-e9b428f9977f8733e6b0d2c321c093779f95080f.zip cpython-e9b428f9977f8733e6b0d2c321c093779f95080f.tar.gz cpython-e9b428f9977f8733e6b0d2c321c093779f95080f.tar.bz2 |
Reimplement addbuilddir() in C inside getpath.c, so as to execute it
at interpreter startup before importing any non-builtin modules.
Should fix #9589.
Diffstat (limited to 'setup.py')
-rw-r--r-- | setup.py | 14 |
1 files changed, 14 insertions, 0 deletions
@@ -22,6 +22,10 @@ COMPILED_WITH_PYDEBUG = hasattr(sys, 'gettotalrefcount') # This global variable is used to hold the list of modules to be disabled. disabled_module_list = [] +# File which contains the directory for shared mods (for sys.path fixup +# when running from the build dir, see Modules/getpath.c) +_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' @@ -224,6 +228,16 @@ class PyBuildExt(build_ext): args['compiler_so'] = compiler + ' ' + ccshared + ' ' + cflags self.compiler.set_executables(**args) + # Not only do we write the builddir cookie, but we manually install + # the shared modules directory if it isn't already in sys.path. + # Otherwise trying to import the extensions after building them + # will fail. + with open(_BUILDDIR_COOKIE, "wb") as f: + f.write(self.build_lib.encode('utf-8', 'surrogateescape')) + abs_build_lib = os.path.join(os.path.dirname(__file__), self.build_lib) + if abs_build_lib not in sys.path: + sys.path.append(abs_build_lib) + build_ext.build_extensions(self) longest = max([len(e.name) for e in self.extensions]) |