How do you add a manifest to PyInstaller compiled EXE?

后端 未结 1 1837
醉梦人生
醉梦人生 2021-01-01 06:37

I am trying to add this manifest to my PyInstaller compiled EXE:




        
相关标签:
1条回答
  • 2021-01-01 07:07

    I had this same problem, using Pyinstaller 3.3. An explanation is given here and I adapted their answer, updating it for Pyinstaller 3.3, as a clumsy workaround. Their solution requires editing the Pyinstaller source code, unfortunately.

    Edit the <python install root>\Lib\site-packages\PyInstaller\building\api.py source file in Pyinstaller, so the beginning of the assemble method looks like this:

    def assemble(self):
        logger.info("Building EXE from %s", self.tocbasename)
        trash = []
        if os.path.exists(self.name):
            os.remove(self.name)
        if not os.path.exists(os.path.dirname(self.name)):
            os.makedirs(os.path.dirname(self.name))
        exe = self.exefiles[0][1]  # pathname of bootloader
        if not os.path.exists(exe):
            raise SystemExit(_MISSING_BOOTLOADER_ERRORMSG)
    
        # BEGINNING OF CHANGES
        if self.manifest_override != False:
            print "Overriding default manifest"
            tmpnm = tempfile.mktemp()
            shutil.copy2(exe, tmpnm)
            os.chmod(tmpnm, 0755)
            winmanifest.UpdateManifestResourcesFromXMLFile(tmpnm, self.manifest_override, names=[1], languages=[1033])
            exe = tmpnm
            trash.append(tmpnm)
        # END OF CHANGES
    
        if is_win and (self.icon or self.versrsrc or self.resources): 
    

    also in api.py in the section labeled

    # Available options for EXE in .spec files
    

    add

    self.manifest_override = kwargs.get('manifest_override', False)
    

    Finally in your spec file in the EXE section add:

    manifest_override=[NAME AND PATH OF YOUR MANIFEST FILE IN QUOTES]
    
    0 讨论(0)
提交回复
热议问题