all: Move frozen modules to virtual directory. #8000
Closed
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.
Thie PR is for a fix created by @wnienhaus - I hope you don't mind me patching it and submitting it here (I needed to use it myself).
I've ammended it slightly to change the vpath from
.frozen
to|frozen
to make it much harder to have a conflict with a real file/folder. I've also added it to the default path for the windows build. Other than that it's as per the original commits at wnienhaus@450d6d3 and 5559cbd which I've maintained the authorship of.I've skipped 2918097 as it looks like it's doing more / enabling frozen where it wasn't previously?
I'm also interested in discussion / feedback about having the default position of the frozen import at the end of the search path. In general I think this is a sensible default, however it's different to the current behaviour where it's typically first.
This change "moves" frozen modules into a virtual directory
called "|frozen". This allows controlling the search order for
frozen modules, relative to other directories.
Before this change, frozen modules were found via the current
directory (i.e. the "" entry in sys.path). However, when a file
is executed from the command line the first entry in sys.path
(which is normally the empty string ""), is replaced by the base
path of the executing file (correct behavior as per CPython).
This made loading frozen modules fail.
With this change, frozen modules have their own entry in
sys.path, which also allows the user to control the order of
search when looking for frozen modules.
By default, the virtual "|frozen" directory is the last entry
in sys.path (i.e. it gets searched last).
Fixes issue #2322.