in python/setup.py [0:0]
def with_project_on_sys_path(self, func):
# Ensure metadata is up-to-date
self.reinitialize_command("build_py", inplace=0)
self.run_command("build_py")
bpy_cmd = self.get_finalized_command("build_py")
build_path = normalize_path(bpy_cmd.build_lib)
# Build extensions
self.reinitialize_command("egg_info", egg_base=build_path)
self.run_command("egg_info")
self.reinitialize_command("build_ext", inplace=0)
self.run_command("build_ext")
ei_cmd = self.get_finalized_command("egg_info")
old_path = sys.path[:]
old_modules = sys.modules.copy()
try:
sys.path.insert(0, normalize_path(ei_cmd.egg_base))
working_set.__init__()
add_activation_listener(lambda dist: dist.activate())
require("%s==%s" % (ei_cmd.egg_name, ei_cmd.egg_version))
func()
finally:
sys.path[:] = old_path
sys.modules.clear()
sys.modules.update(old_modules)
working_set.__init__()