2023-05-04 11:00:00 -07:00
|
|
|
import type { PyodideInterface } from 'pyodide';
|
|
|
|
|
|
|
|
let pyodideInstance: PyodideInterface | undefined;
|
|
|
|
|
2023-07-07 07:43:45 -07:00
|
|
|
export async function LoadPyodide(packageCacheDir: string): Promise<PyodideInterface> {
|
2023-05-04 11:00:00 -07:00
|
|
|
if (pyodideInstance === undefined) {
|
|
|
|
const { loadPyodide } = await import('pyodide');
|
2023-07-07 07:43:45 -07:00
|
|
|
pyodideInstance = await loadPyodide({ packageCacheDir });
|
|
|
|
|
|
|
|
await pyodideInstance.runPythonAsync(`
|
|
|
|
from _pyodide_core import jsproxy_typedict
|
|
|
|
from js import Object
|
|
|
|
`);
|
2023-05-04 11:00:00 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
return pyodideInstance;
|
|
|
|
}
|