Skip to content

analysis: ensure __main__ is always among excludes - #7956

Merged
rokm merged 2 commits into
pyinstaller:developfrom
rokm:always-exclude-main
Sep 28, 2023
Merged

rokm merged 2 commits into
pyinstaller:developfrom
rokm:always-exclude-main

Conversation

@rokm

@rokm rokm commented Sep 27, 2023

Copy link
Copy Markdown
Member

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).

The hook for pkg_resources hook already contains a localized attempt at solving the problem with __main__, but that does not work with vendored versions of pkg_resources (like the one pip has - 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).

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).
@rokm
rokm merged commit e70c723 into pyinstaller:develop Sep 28, 2023
@rokm
rokm deleted the always-exclude-main branch September 28, 2023 07:59
@github-actions github-actions Bot locked as resolved and limited conversation to collaborators Nov 27, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants