def build_wheel_from_sdist()

in xar/pip_installer.py [0:0]


    def build_wheel_from_sdist(self, sdist):
        """
        Given a sdist archive extract it, build in a temporary directory, and
        put the wheel into the downloads directory.
        """
        temp = tempfile.mkdtemp()
        try:
            source = self.extract_sdist(sdist, temp)
            # Make sure to import setuptools and wheel in the setup.py.
            # This is happening in a temporary directory, so we will just
            # overwrite the setup.py to add our own imports.
            setup_py = os.path.join(source, "setup.py")
            with open(setup_py, "r") as f:
                original = f.read()
            with open(setup_py, "w") as f:
                f.write("import setuptools\n")
                f.write("import wheel\n")
                f.write(original)
            # Build the wheel
            command = [
                sys.executable,
                setup_py,
                "bdist_wheel",
                "-d",
                os.path.abspath(self._dest),
            ]
            subprocess.check_call(command, cwd=source)
        except subprocess.CalledProcessError:
            raise BuildException("Failed to build %s" % str(os.path.basename(sdist)))
        finally:
            xar_util.safe_rmtree(temp)