-
-
Notifications
You must be signed in to change notification settings - Fork 8.4k
Closed
Description
The unix port can import frozen modules (str and mpy) from the REPL but it can't import them when executing a file (eg from ./micropython test.py
). This is because when a file is executed from the command line the first entry in sys.path (which is originally the empty string '') is replaced by the base path of the executing file. This is the correct (CPython) behaviour.
But it means that frozen modules can no longer be found in the path -- they require the empty string in the path in order for them to be found in the import search (note that bare-metal ports always have '' in the path so they are ok).
Some ways to fix:
- Add a hack to the import machinery to always search frozen modules.
- Add a special directory to sys.path (eg
:frozen:/
) and prefix all the filenames in the list of frozen files with this special directory. The benefit of this is that it would allow the user to control the order of search when looking for frozen modules.