Skip to content

Commit

Permalink
building: ensure that onefile builds on Windows have manifest embedded
Browse files Browse the repository at this point in the history
The onefile builds on Windows may not have manifest embedded if
icon was explicitly disabled via `--icon NONE`. This in turn causes
subtle issues, such as #5624.

Remove the convoluted check for entering the resource-modification
codepath, as we always need to reach the part that embeds the
manifest in the onefile executable, and the rest of
resource-modification parts are already guarded by their corresponding
checks. This should simplify the code and make it less prone to
errors.
  • Loading branch information
rokm committed Mar 11, 2021
1 parent b9e70f3 commit d7000e9
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 3 deletions.
5 changes: 2 additions & 3 deletions PyInstaller/building/api.py
Expand Up @@ -531,8 +531,7 @@ def assemble(self):
if not os.path.exists(exe):
raise SystemExit(_MISSING_BOOTLOADER_ERRORMSG)

if is_win and (self.icon != "NONE" or self.versrsrc or self.resources
or self.uac_admin or self.uac_uiaccess or not is_64bits):
if is_win:
fd, tmpnm = tempfile.mkstemp(prefix=os.path.basename(exe) + ".",
dir=CONF['workpath'])
# need to close the file, otherwise copying resources will fail
Expand Down Expand Up @@ -598,7 +597,7 @@ def assemble(self):
logger.error("Error while updating resource %s %s in %s"
" from data file %s",
restype, resname, tmpnm, resfile, exc_info=1)
if is_win and self.manifest and not self.exclude_binaries:
if self.manifest and not self.exclude_binaries:
self.manifest.update_resources(tmpnm, [1])
trash.append(tmpnm)
exe = tmpnm
Expand Down
2 changes: 2 additions & 0 deletions news/5625.bugfix.rst
@@ -0,0 +1,2 @@
(Windows) Fix ``onefile`` builds not having manifest embedded when icon is
disabled via ``--icon NONE``.

0 comments on commit d7000e9

Please sign in to comment.