building: force the runtime hook execution order based on filenames #7012
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.
Force the execution order of runtime hooks that are tied to imported modules and packages by sorting them by their filename (basename). This gives us stable and predictable execution order; up until now, the order depended on the order modules appeared in the module graph, i.e., on the order of imports made in the program.
It also gives us the ability to force execution of some hooks before other hooks, and conversely, force execution of some hooks
after all other hooks, by giving them appropriate names.
For example, a runtime hook named
pyi_rth_000_00_mymod_early.py
should be executed first (right after custom runtime hooks), while the one namedpyi_rth_zzz_00_mymod_late.py
should be executed last; regardless of the names used by potential 3rd party runtime hooks, as long as they adhere to thepyi_rth_
prefix.