mirror of
https://github.com/pyscript/pyscript.git
synced 2026-02-12 22:00:56 -05:00
Add Pyodide lockFileURL test (#2209)
This commit is contained in:
committed by
GitHub
parent
f827efe2fc
commit
febbb031ac
1
core/tests/javascript/pyodide-cache/cached.toml
Normal file
1
core/tests/javascript/pyodide-cache/cached.toml
Normal file
@@ -0,0 +1 @@
|
||||
packages = ["numpy", "matplotlib"]
|
||||
41
core/tests/javascript/pyodide-cache/index.html
Normal file
41
core/tests/javascript/pyodide-cache/index.html
Normal 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>
|
||||
6
core/tests/javascript/pyodide-cache/index.py
Normal file
6
core/tests/javascript/pyodide-cache/index.py
Normal file
@@ -0,0 +1,6 @@
|
||||
import numpy
|
||||
import matplotlib
|
||||
|
||||
# just do something with the packages
|
||||
print(len(dir(numpy)))
|
||||
print(len(dir(matplotlib)))
|
||||
2
core/tests/javascript/pyodide-cache/never.toml
Normal file
2
core/tests/javascript/pyodide-cache/never.toml
Normal file
@@ -0,0 +1,2 @@
|
||||
packages_cache = "never"
|
||||
packages = ["numpy", "matplotlib"]
|
||||
Reference in New Issue
Block a user