Repository navigation
analysis: ensure __main__ is always among excludes - #7956
Merged
Merged
Conversation
Ensure that `__main__` is always excluded from the modulegraph, to prevent accidentally pulling `PyInstaller` itself into the modulegraph. This seems to happen on Windows, because modulegraph is able to resolve `__main__` as `.../PyInstaller.exe/__main__.py` and analyze it. The `__main__` has a different meaning during analysis compared to the program run-time, when it refers to the program's entry-point (which would always be part of the modulegraph anyway, by virtue of being the starting point of the analysis).
bwoodsend
approved these changes
Sep 27, 2023
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Ensure that
__main__is always excluded from the modulegraph, to prevent accidentally pullingPyInstalleritself into the modulegraph. This seems to happen on Windows, because modulegraph is able to resolve__main__as.../PyInstaller.exe/__main__.pyand analyze it.The
__main__has a different meaning during analysis compared to the program run-time, when it refers to the program's entry-point (which would always be part of the modulegraph anyway, by virtue of being the starting point of the analysis).The hook for
pkg_resourceshook already contains a localized attempt at solving the problem with__main__, but that does not work with vendored versions ofpkg_resources(like the onepiphas - ee https://github.com/orgs/pyinstaller/discussions/7955#discussioncomment-7122438).This could have been done deep in the bowels of modulegraph itself, but I think it is less hassle to have it done at the higher level (plus, this way it may be more noticeable if we ever get around to replacing the modulegraph).