Skip to content
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

Update Pyodide to 0.27.2 #1300

Merged
merged 4 commits into from
Jan 28, 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 .python-version
Original file line number Diff line number Diff line change
@@ -1 +1 @@
3.12.1
3.12.7
3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -44,5 +44,6 @@
"immutable": "4.2.3",
"protobufjs": "7.2.5",
"@types/react": "^18.2.0"
}
},
"packageManager": "[email protected]+sha512.a6b2f7906b721bba3d67d4aff083df04dad64c399707841b7acf00f6b133b7ac24255f2652fa22ae3534329dc6180534e98d17432037ff6fd140556e2bb3137e"
}
4 changes: 2 additions & 2 deletions packages/desktop/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
"test": "vitest",
"start:electron": "tsc -p electron && cross-env NODE_ENV=development concurrently \"./scripts/build_electron.js --watch\" \"electron .\"",
"build:electron": "tsc -p electron && cross-env NODE_ENV=production ./scripts/build_electron.js",
"build:pyodide": "curl -L https://github.com/pyodide/pyodide/releases/download/0.26.2/pyodide-core-0.26.2.tar.bz2 | tar xj -C ./build --files-from=./pyodide-files.txt",
"build:pyodide": "curl -L https://github.com/pyodide/pyodide/releases/download/0.27.2/pyodide-core-0.27.2.tar.bz2 | tar xj -C ./build --files-from=./pyodide-files.txt",
"build:bin": "tsc -p bin-src && ./scripts/build_bin.js",
"build:wheels": "./scripts/copy_wheels.js",
"postbuild:web": "./scripts/post_build_web.js",
Expand Down Expand Up @@ -58,7 +58,7 @@
"//": "The packages not bundled with bin/dump_artifacts.js must be specified here as the runtime dependencies. See `scripts/build_bin.js` for the details.",
"dependencies": {
"fs-extra": "^11.2.0",
"pyodide": "0.26.2",
"pyodide": "0.27.2",
"yargs": "^17.7.2"
},
"devDependencies": {
Expand Down
2 changes: 1 addition & 1 deletion packages/kernel/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
"@types/path-browserify": "^1.0.0",
"@types/react": "^18.2.0",
"@vitejs/plugin-react": "^4.3.4",
"pyodide": "0.26.2"
"pyodide": "0.27.2"
},
"dependencies": {
"@jupyterlab/coreutils": "^6.3.4",
Expand Down
2 changes: 1 addition & 1 deletion packages/kernel/py/stlite-lib/pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ dependencies = [
dev-dependencies = [
"matplotlib>=3.9.2",
"pandas-stubs>=2.2.3.241009",
"pyodide-py>=0.26.2",
"pyodide-py>=0.27.2",
"pyright>=1.1.384",
"pytest>=8.3.3",
"pytest-asyncio>=0.24.0",
Expand Down
8 changes: 4 additions & 4 deletions packages/kernel/py/stlite-lib/uv.lock

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

4 changes: 2 additions & 2 deletions packages/kernel/src/file.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
import { writeFileWithParents, renameWithParents } from "./file";

describe("writeFileWithParents()", () => {
let pyodide: PyodideInterface;
let pyodide: PyodideInterface & { FS: any }; // XXX: This is a temporary workaround to fix the type error.

Check warning on line 8 in packages/kernel/src/file.spec.ts

View workflow job for this annotation

GitHub Actions / test-kernel

Unexpected any. Specify a different type

beforeEach(async () => {
pyodide = await loadPyodide({
Expand Down Expand Up @@ -45,7 +45,7 @@
});

describe("renameWithParents", () => {
let pyodide: PyodideInterface;
let pyodide: PyodideInterface & { FS: any }; // XXX: This is a temporary workaround to fix the type error.

Check warning on line 48 in packages/kernel/src/file.spec.ts

View workflow job for this annotation

GitHub Actions / test-kernel

Unexpected any. Specify a different type

beforeEach(async () => {
pyodide = await loadPyodide({
Expand Down
11 changes: 7 additions & 4 deletions packages/kernel/src/file.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,10 @@
return path.resolve(getAppHomeDir(appId), filePath);
};

function ensureParent(pyodide: PyodideInterface, filePath: string): void {
function ensureParent(
pyodide: PyodideInterface & { FS: any }, // XXX: This is a temporary workaround to fix the type error.

Check warning on line 20 in packages/kernel/src/file.ts

View workflow job for this annotation

GitHub Actions / test-kernel

Unexpected any. Specify a different type
filePath: string,
): void {
const normalized = path.normalize(filePath);

const dirPath = path.dirname(normalized);
Expand Down Expand Up @@ -45,17 +48,17 @@
}

export function writeFileWithParents(
pyodide: PyodideInterface,
pyodide: PyodideInterface & { FS: any }, // XXX: This is a temporary workaround to fix the type error.

Check warning on line 51 in packages/kernel/src/file.ts

View workflow job for this annotation

GitHub Actions / test-kernel

Unexpected any. Specify a different type
filePath: string,
data: string | ArrayBufferView,
opts?: Parameters<PyodideInterface["FS"]["writeFile"]>[2],
opts?: unknown,
): void {
ensureParent(pyodide, filePath);
pyodide.FS.writeFile(filePath, data, opts);
}

export function renameWithParents(
pyodide: PyodideInterface,
pyodide: PyodideInterface & { FS: any }, // XXX: This is a temporary workaround to fix the type error.

Check warning on line 61 in packages/kernel/src/file.ts

View workflow job for this annotation

GitHub Actions / test-kernel

Unexpected any. Specify a different type
oldPath: string,
newPath: string,
): void {
Expand Down
10 changes: 5 additions & 5 deletions packages/kernel/src/worker-runtime.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/// <reference lib="WebWorker" />

import type Pyodide from "pyodide";
import type { PyodideInterface } from "pyodide";
import type { PyProxy, PyBuffer } from "pyodide/ffi";
import { PromiseDelegate } from "@stlite/common";
import {
Expand Down Expand Up @@ -39,7 +39,7 @@ if (typeof global !== "undefined" && typeof global.self === "undefined") {
}

function dispatchModuleAutoLoading(
pyodide: Pyodide.PyodideInterface,
pyodide: PyodideInterface,
postMessage: PostMessageFn,
sources: string[],
): void {
Expand All @@ -54,7 +54,7 @@ script_runner.moduleAutoLoadPromise = __moduleAutoLoadPromise__
`);
}

let initPyodidePromise: Promise<Pyodide.PyodideInterface> | null = null;
let initPyodidePromise: Promise<PyodideInterface> | null = null;

export function startWorkerEnv(
defaultPyodideUrl: string,
Expand All @@ -71,7 +71,7 @@ export function startWorkerEnv(
});
}

let pyodide: Pyodide.PyodideInterface;
let pyodide: PyodideInterface & { FS: any }; // XXX: This is a temporary workaround to fix the type error.

let httpServer: PyProxy;

Expand Down Expand Up @@ -200,7 +200,7 @@ export function startWorkerEnv(
postProgressMessage("Unpacking archives.");
await Promise.all(
archives.map(async (archive) => {
let buffer: Parameters<Pyodide.PyodideInterface["unpackArchive"]>[0];
let buffer: Parameters<PyodideInterface["unpackArchive"]>[0];
if ("url" in archive) {
console.debug(`Fetch an archive from ${archive.url}`);
buffer = await fetch(archive.url).then((res) => res.arrayBuffer());
Expand Down
2 changes: 1 addition & 1 deletion packages/kernel/src/worker.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
import { startWorkerEnv } from "./worker-runtime";
import { generateRandomAppId } from "./app-id";

const pyodideUrl = "https://cdn.jsdelivr.net/pyodide/v0.26.2/full/pyodide.mjs";
const pyodideUrl = "https://cdn.jsdelivr.net/pyodide/v0.27.2/full/pyodide.mjs";

if ("postMessage" in self) {
// Dedicated worker
Expand Down
14 changes: 10 additions & 4 deletions packages/sharing/src/App.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,15 @@ import STREAMLIT_WHEEL from "streamlit.whl";

declare const EDITOR_APP_ORIGIN_REGEX: string;
declare const EDITOR_APP_ORIGIN: string;
const wheelUrls = {
// The resolved URLs such as STLITE_LIB_WHEEL only contain the pathnames e.g. "/assets/stlite_lib-0.1.0-py3-none-any.whl"
// and micropip treats such path-only URLs as local file URLs e.g. "file:////assets/stlite_lib-0.1.0-py3-none-any.whl"
// since 0.7.0 due to the change by https://github.com/pyodide/micropip/pull/145,
// though these URLs are actually for remote resources.
// So we need to convert these path-only URLs to full URLs including the protocol explicitly.
stliteLib: new URL(STLITE_LIB_WHEEL, import.meta.url).href,
streamlit: new URL(STREAMLIT_WHEEL, import.meta.url).href,
};

const editorAppOriginRegex = EDITOR_APP_ORIGIN_REGEX
? new RegExp(EDITOR_APP_ORIGIN_REGEX)
Expand Down Expand Up @@ -94,10 +103,7 @@ st.write("Hello World")`,
...makeToastKernelCallbacks(),
moduleAutoLoad: true,
sharedWorker: isSharedWorkerMode(),
wheelUrls: {
stliteLib: STLITE_LIB_WHEEL,
streamlit: STREAMLIT_WHEEL,
},
wheelUrls,
workerType: "module", // Vite loads the worker scripts as ES modules without bundling at dev time, so we need to specify the type as "module" for the "import" statements in the worker script to work.
});
_kernel = kernel;
Expand Down
2 changes: 1 addition & 1 deletion requirements.dev.txt
Original file line number Diff line number Diff line change
@@ -1 +1 @@
pyodide-build==0.26.2
pyodide-build==0.27.2
8 changes: 4 additions & 4 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -14992,10 +14992,10 @@ pure-color@^1.2.0:
resolved "https://registry.npmjs.org/pure-color/-/pure-color-1.3.0.tgz"
integrity sha512-QFADYnsVoBMw1srW7OVKEYjG+MbIa49s54w1MA1EDY6r2r/sTcKKYqRX1f4GYvnXP7eN/Pe9HFcX+hwzmrXRHA==

pyodide@0.26.2:
version "0.26.2"
resolved "https://registry.npmjs.org/pyodide/-/pyodide-0.26.2.tgz"
integrity sha512-8VCRdFX83gBsWs6XP2rhG8HMaB+JaVyyav4q/EMzoV8fXH8HN6T5IISC92SNma6i1DRA3SVXA61S1rJcB8efgA==
pyodide@0.27.2:
version "0.27.2"
resolved "https://registry.yarnpkg.com/pyodide/-/pyodide-0.27.2.tgz#8cd43abe245bffbbf82031c95fd79e4bc719d83d"
integrity sha512-sfA2kiUuQVRpWI4BYnU3sX5PaTTt/xrcVEmRzRcId8DzZXGGtPgCBC0gCqjUTUYSa8ofPaSjXmzESc86yvvCHg==
dependencies:
ws "^8.5.0"

Expand Down
Loading