py/builtinimport.c: Implement a "frozen overlay" using the filesystem.#8922
py/builtinimport.c: Implement a "frozen overlay" using the filesystem.#8922jimmo wants to merge 1 commit into
Conversation
This allows frozen files to be overridden by filesystem .py or .mpy files from a specific path. The idea is that during development, a whole directory tree might be frozen but for fast testing iteration it can be useful to just replace a couple of files. This allows the same directory structure to be defined, but any time a file is about to be loaded from frozen, the same path is attempted in the overlay path. Note: the overlay path should not be part of sys.path, otherwise it will prevent the frozen path from being found. Signed-off-by: Jim Mussared <[email protected]>
|
To make it a bit more clear... If the following tree is frozen: but with Then the frozen files will all be loaded as normal, except for c.py which will be loaded from the filesystem. Note that Filesystem files can be .py or .mpy (and the usual rules that .py takes precedence over .mpy applies). |
|
It was pointed out to me (thanks @tsukasa-au) that this has some resemblance to PEP420. |
…te-machine Swap PIO allocation of USB Host for better Pico W compatibility
|
This is an automated heads-up that we've just merged a Pull Request See #13763 A search suggests this PR might apply the STATIC macro to some C code. If it Although this is an automated message, feel free to @-reply to me directly if |
Draft/WIP.
Haven't given much thought to code size (especially when the feature is disabled). The
allow_frozenflag to thestat_methods in particular needs some thought.I considered a few other ways of implementing this, in particular making it detect the filesystem version of the file while searching sys.path but this creates a complicated interaction with things like loading the parent modules. Instead this approach says "a frozen file can be overridden by a filesystem file" rather than interfering with file discovery.
Filesystem means "VFS", so note this would work with
mpremote mounttoo... (perhaps via #8914 we could have a way to make mpremote construct this "files that have changed relative to freezing" directory to mount)This allows frozen files to be overridden by filesystem .py or .mpy files from a specific path specified in
micropython.frozen_overlay.The idea is that during development, a whole directory tree might be frozen
but for fast testing iteration it can be useful to just replace a couple
of files. This allows the same directory structure to be defined, but any
time a file is about to be loaded from frozen, the same path is attempted
in the overlay path.
Note: the overlay path should not be part of sys.path, otherwise it will
prevent the frozen path from being found.