coatless-quarto / pyodide

Quarto extension to enable interactive Python code cells in HTML documents using Pyodide
http://quarto.thecoatlessprofessor.com/pyodide/
53 stars 3 forks source link

[Feature]: Auto-load packages or auto-run code blocks #19

Open HenrikBengtsson opened 3 weeks ago

HenrikBengtsson commented 3 weeks ago

Feature Description

Background

The webR implementation allows us to auto-load packages, e.g.

webr:
  show-startup-message: false
  repos: ["https://cran.r-universe.dev", "https://repo.r-wasm.org"]
  packages: ["seguid"]
  autoload-packages: true

However, AFAIU, this is not yet possible in the Pyodide implementation. The best I came up with is to add an initial code block;

```{pyodide-python}
#| read-only: true
await micropip.install("seguid")
from seguid import *
```

and instruct the reader to 'Run' that before anything else following, cf. https://www.seguid.org/demo-python.html.

Wish 1

It would be useful if we could do:

pyodide:
  packages: ["seguid"]
  autoload-packages: true

such that the seguid package is automatically installed and loaded from PyPI.

Wish 2

It would also be useful to be able to auto-run individual code blocks as in webR, e.g.

```{pyodide-python}
#| read-only: true
#| autorun: true
await micropip.install("seguid")
from seguid import *
```

Comment: I'm not 100% sure, but it could be what https://github.com/coatless-quarto/pyodide/issues/5 is already ask for.

PS. Thanks for these awesome Quarto-Wasm extensions.