def compile_to_bootstrap_exe(self,exe,source,relpath=None):
        """Compile the given sourcecode into a bootstrapping exe.

        This method compiles the given sourcecode into a stand-alone exe using
        PyPy, then stores that in the bootstrap env under the name of the given
        Executable object.  If the source has been previously compiled then a
        cached version of the exe may be used.
        """
        if not relpath:
            relpath = exe.name
        source = "__rpython__ = True\n" + source
        cdir = os.path.join(self.tempdir,"compile")
        if not os.path.exists(cdir):
            os.mkdir(cdir)
        source_hash = hashlib.md5(source).hexdigest()
        outname = "bootstrap_%s.%s" % (source_hash,get_platform())
        if exe.gui_only:
            outname += ".gui"
        if sys.platform == "win32":
            outname += ".exe"
        #  First try to use a precompiled version.
        if COMPILED_BOOTSTRAP_CACHE is not None:
            outfile = os.path.join(COMPILED_BOOTSTRAP_CACHE,outname)
            if os.path.exists(outfile):
                return self.copy_to_bootstrap_env(outfile,relpath)
        #  Otherwise we have to compile it anew.
        try:
            outfile = self._compiled_exes[(source_hash,exe.gui_only)]
        except KeyError:
            infile = os.path.join(cdir,"bootstrap.py")
            outfile = os.path.join(cdir,outname)
            with open(infile,"wt") as f:
                f.write(source)
            opts = dict(gui_only=exe.gui_only)
            pypyc.compile_rpython(infile,outfile,**opts)
            self._compiled_exes[(source_hash,exe.gui_only)] = outfile
        #  Try to save the compiled exe for future use.
        if COMPILED_BOOTSTRAP_CACHE is not None:
            cachedfile = os.path.join(COMPILED_BOOTSTRAP_CACHE,outname)
            try:
                shutil.copy2(outfile,cachedfile)
            except EnvironmentError:
                pass
        return self.copy_to_bootstrap_env(outfile,relpath)
dataset/ETHPy150Open cloudmatrix/esky/esky/bdist_esky/__init__.py/bdist_esky.compile_to_bootstrap_exe/original