@@ -230,6 +230,9 @@ important of these are as follows:
230230File System Setup
231231-----------------
232232
233+ The Standard Library
234+ ====================
235+
233236In order for Python to run, it needs access to the standard library in the
234237Emscripten file system. There are several possible approaches to this:
235238
@@ -258,10 +261,35 @@ Emscripten file system. There are several possible approaches to this:
258261 in the browser. The disadvantage is that Emscripten does not itself include a
259262 TARFS so it requires a downstream implementation.
260263
261- Pyodide uses the ``ZipImporter `` approach in every runtime.
264+ Pyodide uses the ``ZipImporter `` approach in every runtime. Python uses the
265+ NODEFS approach when run with node and the ``ZipImporter `` approach for the web
266+ example. We will continue with this approach.
267+
268+ The `ZipImporter ` provides a clean resolution for a bootstrapping problem: The
269+ Python runtime is capable of unpacking a wide variety of archive formats, but
270+ the Python runtime is not ready to use until the standard library is already
271+ available. Since `zipimport.py ` is a frozen module, it avoids these problems.
272+ All of the other approaches solve the bootstrapping problem by setting up the
273+ standard library using JavaScript.
274+
275+ Packages
276+ ========
262277
263- Python uses the NODEFS approach when run with node and the ``ZipImporter ``
264- approach for the web example. We will continue with this approach.
278+ It is also necessary to make any needed packages available in the Emscripten
279+ file system. Currently Emscripten cpython has no support for packages. Pyodide
280+ uses two different approaches for packages:
281+
282+ * In the browser, Pyodide downloads and unpacks wheels into the MEMFS
283+ site-packages directory. It then preloads all dynamic libraries in the wheel.
284+ The work of downloading and installing all the packages is redone every time
285+ the runtime starts.
286+
287+ * The Pyodide `python ` cli entrypoint mounts all of the host file system as
288+ NODEFS directories before it bootstraps Python. This allows the normal virtual
289+ environment mechanism to work. Pyodide virtual environments contain a patched
290+ copy of pip and a custom `pip.conf ` so that pip will install Pyodide wheels.
291+ On startup the Pyodide `python ` cli will preload all Emscripten dynamic
292+ libraries that are in the sitee-packages directory.
265293
266294
267295-----------------------------
0 commit comments