Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

building: ensure that onefile builds on Windows have manifest embedded #5625

Merged
merged 2 commits into from Mar 13, 2021

Conversation

rokm
Copy link
Member

@rokm rokm commented Mar 11, 2021

... regardless of the icon setting.

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.

Fixes #5624.

Side note: with 3c3228d, the behavior of this issue became inverted; before it (i.e., PyInstaller 4.1 and older), the manifest would not be embedded if icon was not provided (i.e., self.icon was falsy), i.e., by default. So this may also explain some weird behavior of Windows onefile builds made with PyInstaller 4.1 and older (which mysteriously went away if --icon was specified).

Test building with different --icon options, as that is what seems to
be triggering inconsistent behavior at the moment.
Comment on lines 534 to 536
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):
or self.uac_admin or self.uac_uiaccess or not is_64bits
or (self.manifest and not self.exclude_binaries)):
Copy link
Member

@bwoodsend bwoodsend Mar 11, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'd rather like some comments in here explaining why simply if is_win: is not what we want. Is it that there's no point adding a manifest unless at least one of those conditions is true or that it breaks it if we unconditionally add the manifest ?

Copy link
Member Author

@rokm rokm Mar 11, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, that's a fair point. I think going with just is_win should be enough (and I strongly suspect that this part of code simply gradually evolved to be that way).

The optional stuff (self.icon, self.versrsrc and self.resources) are under their corresponding subsequent checks anyway.

The (self.manifest and not self.exclude_binaries) was added to fix this issue (and its subsequent check has an additional is_win check that's redundant).

self.uac_admin or self.uac_uiaccess are probably there to ensure that we add the manifest if either of those options is enabled (as they're written in the manifest).

Not sure about not is_64bits part, but I suspect that nowdays the self.icon != "NONE" accounts for most cases, so that doesn't influence much, anyway.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is it that there's no point adding a manifest unless at least one of those conditions is true or that it breaks it if we unconditionally add the manifest ?

We probably always need the manifest. If nothing else, we use it to try opting-in for long paths; and as discovered by #5624, some other things may depend on it as well.

The only time when we don't need to embed it in the executable is if we're doing onedir build, since it's written to a separate file. (Which I think is why we have that not self.exclude_binaries check).

Copy link
Member

@bwoodsend bwoodsend Mar 11, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Tracing the blame back, it does look like it started of as add if needed and if needed grew and grew:

(Which I think is why we have that not self.exclude_binaries check).

Hmm, possibly. It looks like there isn't just a self.is_onefile flag.

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 pyinstaller#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.
@rokm
Copy link
Member Author

rokm commented Mar 11, 2021

Let's see what the CI thinks about the simplified version, then...

@bwoodsend
Copy link
Member

bwoodsend commented Mar 11, 2021

Strange. AppVeyor appears to have dosed off. Might need to give it an encouraging git push -f...

@bwoodsend bwoodsend added the merge-on-ci-pass This PR is ready to merge providing CI passes label Mar 11, 2021
@bwoodsend
Copy link
Member

@Legorooj Are you able to merge this? Every time I press the confirm rebase and merge button it doesn't do it.

@Legorooj Legorooj merged commit 482b8a4 into pyinstaller:develop Mar 13, 2021
@Legorooj
Copy link
Member

Merged 👍

@rokm rokm deleted the missing-manifest branch March 22, 2021 19:37
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Nov 16, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
merge-on-ci-pass This PR is ready to merge providing CI passes
Projects
None yet
Development

Successfully merging this pull request may close these issues.

The window can not be clicked through (tkinter wm_attributes("-transparentcolor", color) method)
4 participants