def extract(self, root="build"):
        """Extracts the files from the build plan into the local build directory ``root``.

        Returns :class:`pathlib.Path`
        """
        os.makedirs(root, exist_ok=True)
        cwd = os.getcwd()
        try:
            os.chdir(root)

            for filename, content in self.files.items():
                filename = pathlib.Path(filename)
                # Forbid parent directory components and absolute paths completely to avoid
                # the possibility of writing outside the build root.
                assert not filename.is_absolute() and ".." not in filename.parts
                dirname = os.path.dirname(filename)
                if dirname:
                    os.makedirs(dirname, exist_ok=True)

                if isinstance(content, str):
                    content = content.encode("utf-8")
                with open(filename, "wb") as f:
                    f.write(content)
            return pathlib.Path(os.getcwd())
        finally:
            os.chdir(cwd)
Extracts the files from the build plan into the local build directory ``root``.

        Returns :class:`pathlib.Path`
        
amaranth/build/run.py