Files
pyscript/pyscript.core/esm/runtime/pyodide.js
Andrea Giammarchi 50b1a1d7c5 Fix #1512 - Improve worker tests + update Pyodide (#1513)
* Fix #1512 - Improve worker tests + update Pyodide

* [pre-commit.ci] auto fixes from pre-commit.com hooks

for more information, see https://pre-commit.ci

* [pre-commit.ci] auto fixes from pre-commit.com hooks

for more information, see https://pre-commit.ci

---------

Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
2023-06-08 17:39:01 +02:00

40 lines
1.1 KiB
JavaScript

import { fetchPaths, stdio } from "./_utils.js";
import {
run,
runAsync,
runEvent,
runWorker,
runWorkerAsync,
writeFile,
} from "./_python.js";
const type = "pyodide";
// REQUIRES INTEGRATION TEST
/* c8 ignore start */
export default {
type: [type, "py"],
module: (version = "0.23.2") =>
`https://cdn.jsdelivr.net/pyodide/v${version}/full/pyodide.mjs`,
async engine({ loadPyodide }, config, url) {
const { stderr, stdout, get } = stdio();
const indexURL = url.slice(0, url.lastIndexOf("/"));
const runtime = await get(loadPyodide({ stderr, stdout, indexURL }));
if (config.fetch) await fetchPaths(this, runtime, config.fetch);
if (config.packages) {
await runtime.loadPackage("micropip");
const micropip = await runtime.pyimport("micropip");
await micropip.install(config.packages);
micropip.destroy();
}
return runtime;
},
run,
runAsync,
runEvent,
runWorker,
runWorkerAsync,
writeFile,
};
/* c8 ignore stop */