Skip to content

[Feature]: Custom environments #15

Description

@psychemedia

Feature Description

I notice that you do some of the lifting to get matplotlib charts to work via JS in each rendered page:

    // Load the `matplotlib` package with necessary environment hook
    await mainPyodide.loadPackage("matplotlib");

    // Set the backend for matplotlib to be interactive.
    await mainPyodide.runPythonAsync(`
    import matplotlib
    matplotlib.use("module://matplotlib_pyodide.html5_canvas_backend")
    from matplotlib import pyplot as plt
    `);

I wonder if it would also be useful to allow config either globally or locally that would allow a user to specify in header or _quarto.yml things like:

- pyodide-pip
  - pandas

which would create something like:

await mainPyodide.loadPackage("pandas");

or optionally something like:

- pyodide-pip
  - pandas, ["import pandas as pd", "pd.options.display.max_rows = 5"]

to generate:

    await mainPyodide.loadPackage("pandas");

    await mainPyodide.runPythonAsync(`
       import pandas as pd
       pd.options.display.max_rows = 5
    `);

Alternatively, keep pyodide-pip as a simple list and then allow:

- pyodide-init
  - import pandas as pd
  - pd.options.display.max_rows = 5
  - etc

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions