Repository navigation
all: Move frozen modules to virtual directory. - #8000
Closed
andrewleech wants to merge 1 commit into
Closed
andrewleech wants to merge 1 commit into
andrewleech wants to merge 1 commit into
Conversation
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 micropython#2322.
Contributor
Author
|
Ah, for some reason I failed to see this was in fact submitted here already in #5057 so ignore me :-) |
Contributor
|
Very nice. Shows there is demand for this to be fixed 😄 . The pipe is good as an "unlikely to ever be in a directory name" character, however on unix shells (also PowerShell) it represents the pipe, which is perhaps a bit unfortunate? (In my original PR I proposed |
Member
|
Superseded by #8079. |
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 join this conversation on GitHub.
Already have an account?
Sign in to comment
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
.frozento|frozento 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.