Add Pyodide lockFileURL test (#2209)

This commit is contained in:
Andrea Giammarchi
2024-10-07 13:23:05 +02:00
committed by GitHub
parent f827efe2fc
commit febbb031ac
8 changed files with 104 additions and 139 deletions

View File

@@ -0,0 +1 @@
packages = ["numpy", "matplotlib"]

View File

@@ -0,0 +1,41 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<link rel="stylesheet" href="../../../dist/core.css">
<script type="module">
import '../../../dist/core.js';
addEventListener('py:progress', ({ detail }) => {
console.log(detail);
});
test([]);
function test($) {
const script = document.createElement('script');
script.type = 'py';
script.src = 'index.py';
script.toggleAttribute('worker', true);
script.setAttribute('config', `${$.length ? 'cached' : 'never'}.toml`);
script.addEventListener(
'py:done',
() => {
if ($.push(performance.now() - time) === 3) {
const [_, justCDN, lockFile] = $;
console.log({ justCDN, lockFile });
document.body.textContent = justCDN > lockFile ? 'OK' : 'NO';
document.documentElement.classList.add('done');
}
else setTimeout(test, 0, $);
script.remove();
},
{ once: true },
);
document.body.append(script);
const time = performance.now();
}
</script>
</head>
</html>

View File

@@ -0,0 +1,6 @@
import numpy
import matplotlib
# just do something with the packages
print(len(dir(numpy)))
print(len(dir(matplotlib)))

View File

@@ -0,0 +1,2 @@
packages_cache = "never"
packages = ["numpy", "matplotlib"]