Move .frozen to second entry in sys.path #8105
Merged
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.
The recent change to allow a
".frozen"
entry insys.path
to specify the frozen module search order (see #8079) placed this entry at the start ofsys.path
. This is against the CPython standard/docs/behaviour which requiressys.path[0]
to be the location of the current script (or''
if that can't be determined, like at a REPL).Some scripts will use
sys.path[0]
to find out where they are run from. And egupip
is now broken with".frozen"
as the first entry.The reason
".frozen"
was put first was to keep the same behaviour as before for searching frozen modules, namely that frozen code is searched before the filesystem (frozen code was previously searched when""
was encountered insys.path
). But this behaviour will need to change because it's more important to havesys.path[0]
being the current script's directory (or the empty string).This PR does the following:
".frozen"
to the second entry insys.path
".frozen"
part ofMICROPY_PY_SYS_PATH_DEFAULT
on the unix and windows ports, so it can be overridden/changed by use of theMICROPYPATH
environment variableupip
to skip".frozen"
because it doesn't make sense to install to.frozen
See related #7536.