n8n/packages/nodes-base/nodes/Code/Pyodide.ts
कारतोफ्फेलस्क्रिप्ट™ bf351243df
fix(Code Node): Install python modules always in a user-writable folder (#6568)
* upgrade pyodide

* install pyodide modules to a custom user-writable path

* in `augmentObject` `newData` is never undefined
2023-07-07 16:43:45 +02:00

18 lines
481 B
TypeScript

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