Skip to content

Preparing better lockFileContents for Pyodide 0.28.1 #144

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Aug 6, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion docs/index.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion docs/index.js.map

Large diffs are not rendered by default.

2 changes: 2 additions & 0 deletions docs/zip-Cv6FEM4N.js

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions docs/zip-Cv6FEM4N.js.map

Large diffs are not rendered by default.

19 changes: 12 additions & 7 deletions esm/interpreter/pyodide.js
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ const indexURLs = new WeakMap();

export default {
type,
module: (version = '0.27.7') =>
module: (version = '0.28.1') =>
`https://cdn.jsdelivr.net/pyodide/v${version}/full/pyodide.mjs`,
async engine({ loadPyodide, version }, config, url, baseURL) {
progress('Loading Pyodide');
Expand Down Expand Up @@ -99,17 +99,22 @@ export default {
// packages are uniquely stored as JSON key
const key = stringify(packages);
if (storage.has(key)) {
const blob = new Blob(
[storage.get(key)],
{ type: 'application/json' },
);
// this should be used to bootstrap loadPyodide
options.lockFileURL = URL.createObjectURL(blob);
const value = storage.get(key);

// versions are not currently understood by pyodide when
// a lockFileURL is used instead of micropip.install(packages)
// https://github.com/pyodide/pyodide/issues/5135#issuecomment-2441038644
// https://github.com/pyscript/pyscript/issues/2245
options.packages = packages.map(name => name.split(/[>=<]=/)[0]);

if (version.startsWith('0.27')) {
const blob = new Blob([value], { type: 'application/json' });
options.lockFileURL = URL.createObjectURL(blob);
}
else {
options.lockFileContents = value;
}

packages = null;
}
}
Expand Down
2 changes: 1 addition & 1 deletion esm/interpreter/webr.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ const run = async (interpreter, code) => {
export default {
type,
experimental: true,
module: (version = '0.5.5-dev') =>
module: (version = '0.5.4') =>
`https://cdn.jsdelivr.net/npm/webr@${version}/dist/webr.mjs`,
async engine(module, config, _, baseURL) {
const { get } = stdio();
Expand Down
2 changes: 1 addition & 1 deletion node.importmap
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"imports": {
"http://pyodide": "./test/mocked/pyodide.mjs",
"https://cdn.jsdelivr.net/pyodide/v0.27.7/full/pyodide.mjs": "./test/mocked/pyodide.mjs",
"https://cdn.jsdelivr.net/pyodide/v0.28.1/full/pyodide.mjs": "./test/mocked/pyodide.mjs",
"https://cdn.jsdelivr.net/npm/@micropython/[email protected]/micropython.mjs": "./test/mocked/micropython.mjs",
"./3rd-party/toml.js": "./test/mocked/toml.mjs"
}
Expand Down
44 changes: 22 additions & 22 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

10 changes: 5 additions & 5 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "polyscript",
"version": "0.18.7",
"version": "0.18.9",
"description": "PyScript single core to rule them all",
"main": "./esm/index.js",
"types": "./types/polyscript/esm/index.d.ts",
Expand Down Expand Up @@ -47,17 +47,17 @@
"license": "APACHE-2.0",
"devDependencies": {
"@node-loader/import-maps": "^1.1.0",
"@playwright/test": "^1.54.1",
"@playwright/test": "^1.54.2",
"@rollup/plugin-node-resolve": "^16.0.1",
"@rollup/plugin-terser": "^0.4.4",
"@zip.js/zip.js": "^2.7.70",
"@zip.js/zip.js": "^2.7.72",
"c8": "^10.1.3",
"chokidar": "^4.0.3",
"eslint": "^9.32.0",
"linkedom": "^0.18.11",
"rollup": "^4.46.2",
"static-handler": "^0.5.3",
"typescript": "^5.8.3"
"typescript": "^5.9.2"
},
"type": "module",
"module": "./dist/index.js",
Expand Down Expand Up @@ -95,6 +95,6 @@
"to-json-callback": "^0.1.1"
},
"worker": {
"blob": "sha256-/ijN208Vut7w0/RQg848GbrzMVJWIAXyHNY5JK81MCI="
"blob": "sha256-AXShINMvVZpHtkidZMDhr0GyDeHHI3ubeK5sWCJAZYY="
}
}
2 changes: 1 addition & 1 deletion test/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ import("../esm/index.js").then(async polyscript => {
// all tests
for (const test of [
async function versionedRuntime() {
document.head.innerHTML = `<script type="pyodide" version="0.27.7">${content}</script>`;
document.head.innerHTML = `<script type="pyodide" version="0.28.1">${content}</script>`;
await tick();
assert(pyodide.content, dedent(content));
assert(pyodide.target.tagName, "PYODIDE-SCRIPT");
Expand Down
2 changes: 1 addition & 1 deletion versions/pyodide
Original file line number Diff line number Diff line change
@@ -1 +1 @@
0.27.7
0.28.1
2 changes: 1 addition & 1 deletion versions/webr
Original file line number Diff line number Diff line change
@@ -1 +1 @@
0.5.5-dev
0.5.4