Access to Emscripten's file system directly using Module.FS
See original GitHub issueFeature
Access the Emscripten Filesystem directly instead of waiting for pyodide
to initialise and be ready first.
Motivation
The Emscripten File system is provided by using the flag -s 'EXPORTED_RUNTIME_METHODS=["FS"]'
when compiling C programs to WASM using emcc
. This provides a direct access to the file system using Module.FS
.
In case of pyodide
however, because of the way it is compiled, the file system is accessible through pyodide.FS
(which is just a re-export of Module.FS
) or perhaps through pyodide._module.FS
as mentioned here:
https://pyodide.org/en/latest/usage/file-system.html#dealing-with-the-file-system
While there is no difference apart from the way to access it, the side effect is of waiting for pyodide
to be ready first.
Pitch
It would be nice to have access to Module.FS
directly, which has the advantage of not waiting on the initialisation / startup time. One use-case could be fetching and setting up any additional non-pyodide specific files in parallel even before the runtime is ready.
Further, envisioning that more runtimes / interpreters (such as Micropython) will / are adopting WebAssembly, this provides a consistent way of accessing the File System across all such runtimes / interpreters.
Alternatives
This is just meant to initiate a discussion and perhaps there are better ways to think about this. And there might be some caveats in this approach which are being overlooked.
Additional context
Tagging some folks from PyScript here: @fpliger @antocuni @ntoll and from Pyodide as well: @hoodmane @rth
Issue Analytics
- State:
- Created 10 months ago
- Comments:10 (9 by maintainers)
It would be interesting to see if we could share one
FS
instance between multiple Pyodide instances. In a lot of ways that makes more sense than the current system. Either sharing the FS or allowing users to shut down and restart the interpreter might help all the people asking to reinstall / reload modules.oh, I wasn’t aware of that. I thought/assumed that the FS is a singleton ans it’s shared between the various emscripten “processes”. I agree, if the FS is per-pyodide, then my suggestions are non-sense, sorry for that 😃
yes, I think that given the other constraints this is probably the best way to solve our use case (although it makes the code on pyscript side a bit more complicated than what I would have liked, but too bad 😃).