support different pyodide versions (#328)

* add PyLoader class

* create global loader during app creation time and remove it when pyscript loading operations are done

* make the loader global and open/close when apps is starting. Also add concept of app config so users can set if they want to autoclose the loader of handle it themselves

* add pyconfig file

* auto add global config if there's no config set in the page

* export initializer type

* define type for config

* move initialization out of svelte file, into app config

* change runtimes from strings to objects

* fix typo
This commit is contained in:
Fabio Pliger
2022-05-11 16:59:13 -05:00
committed by GitHub
parent 73a0d9b02e
commit 363f3751f9
7 changed files with 157 additions and 88 deletions

View File

@@ -14,6 +14,14 @@
- paths:
- ./utils.py
</py-env>
<py-config>
- autoclose_loader: false
- runtimes:
-
src: "https://cdn.jsdelivr.net/pyodide/v0.20.0/full/pyodide.js"
name: pyodide-0.20
lang: python
</py-config>
</head>
<body>
@@ -43,6 +51,8 @@ async def foo():
else:
out3.clear()
# close the global PyScript pyscript_loader
pyscript_loader.close()
pyscript.run_until_complete(foo())
</py-script>
</body>