From 5072a3d9709645bc9310db812cedc9ff2f32bcf8 Mon Sep 17 00:00:00 2001 From: "Yuichiro Tachibana (Tsuchiya)" Date: Wed, 7 Feb 2024 00:22:20 +0900 Subject: [PATCH 1/5] Remove the pyodide-http patch because urllib3 started to support Pyodide from 2.2.0 --- .../py/stlite-server/stlite_server/bootstrap.py | 11 ----------- streamlit | 2 +- 2 files changed, 1 insertion(+), 12 deletions(-) diff --git a/packages/kernel/py/stlite-server/stlite_server/bootstrap.py b/packages/kernel/py/stlite-server/stlite_server/bootstrap.py index 857eb9987..636da4d6a 100644 --- a/packages/kernel/py/stlite-server/stlite_server/bootstrap.py +++ b/packages/kernel/py/stlite-server/stlite_server/bootstrap.py @@ -144,16 +144,6 @@ def _import_pyarrow_interchange(): logger.error("Failed to fix Altair", exc_info=e) -def _fix_requests(): - try: - import pyodide_http # type: ignore[import] - - pyodide_http.patch_all() # Patch all libraries - except ImportError: - # pyodide_http is not installed. No need to do anything. - pass - - def prepare( main_script_path: str, args: List[str], @@ -166,7 +156,6 @@ def prepare( _fix_sys_path(main_script_path) _fix_matplotlib_crash() _fix_altair() - _fix_requests() _fix_sys_argv(main_script_path, args) _fix_pydeck_mapbox_api_warning() _install_pages_watcher(main_script_path) diff --git a/streamlit b/streamlit index 0fad240d5..8466c6c6b 160000 --- a/streamlit +++ b/streamlit @@ -1 +1 @@ -Subproject commit 0fad240d53501bf05a060102e632c1d1c56b6c2b +Subproject commit 8466c6c6b721966b04448e74856704d26c77be7d From 1d338cbf0a6d4ce9944f25f02d471eb050e56243 Mon Sep 17 00:00:00 2001 From: "Yuichiro Tachibana (Tsuchiya)" Date: Wed, 7 Feb 2024 00:47:13 +0900 Subject: [PATCH 2/5] Pin urllib3 version --- packages/common/src/index.ts | 1 + packages/common/src/requirements.ts | 4 ++++ packages/desktop/bin/dump_artifacts.ts | 7 +++++-- packages/kernel/src/worker.ts | 9 +++++++-- 4 files changed, 17 insertions(+), 4 deletions(-) create mode 100644 packages/common/src/requirements.ts diff --git a/packages/common/src/index.ts b/packages/common/src/index.ts index 2adbd2ced..82868273b 100644 --- a/packages/common/src/index.ts +++ b/packages/common/src/index.ts @@ -1,2 +1,3 @@ +export * from "./requirements"; export * from "./requirements-txt"; export * from "./promise-delegate"; diff --git a/packages/common/src/requirements.ts b/packages/common/src/requirements.ts new file mode 100644 index 000000000..30303f797 --- /dev/null +++ b/packages/common/src/requirements.ts @@ -0,0 +1,4 @@ +// stlite-specific requirements +export const STLITE_REQUIREMENTS = [ + "urllib3==2.2.0", // `urllib3` supports Pyodide since 2.2.0. https://urllib3.readthedocs.io/en/stable/reference/contrib/emscripten.html +]; diff --git a/packages/desktop/bin/dump_artifacts.ts b/packages/desktop/bin/dump_artifacts.ts index 68b3231c2..a0391585b 100755 --- a/packages/desktop/bin/dump_artifacts.ts +++ b/packages/desktop/bin/dump_artifacts.ts @@ -11,7 +11,7 @@ import { type PyodideInterface, version as pyodideVersion, } from "pyodide"; -import { parseRequirementsTxt } from "@stlite/common"; +import { parseRequirementsTxt, STLITE_REQUIREMENTS } from "@stlite/common"; import type { DesktopAppManifest } from "../electron/main"; // @ts-ignore @@ -132,7 +132,10 @@ async function installPackages( await pyodide.loadPackage(["micropip"]); const micropip = pyodide.pyimport("micropip"); - const requirements: string[] = [...options.requirements]; + const requirements: string[] = [ + ...options.requirements, + ...STLITE_REQUIREMENTS, + ]; if (options.useLocalKernelWheels) { const stliteKernelDir = path.dirname(require.resolve("@stlite/kernel")); // -> /path/to/kernel/dist const stliteKernelPyDir = path.resolve(stliteKernelDir, "../py"); // -> /path/to/kernel/py diff --git a/packages/kernel/src/worker.ts b/packages/kernel/src/worker.ts index d3e215908..918414600 100644 --- a/packages/kernel/src/worker.ts +++ b/packages/kernel/src/worker.ts @@ -1,5 +1,5 @@ import type Pyodide from "pyodide"; -import { PromiseDelegate } from "@stlite/common"; +import { PromiseDelegate, STLITE_REQUIREMENTS } from "@stlite/common"; import { writeFileWithParents, renameWithParents } from "./file"; import { verifyRequirements } from "./requirements"; import { mockPyArrow } from "./mock"; @@ -180,7 +180,12 @@ async function loadPyodideAndPackages() { requirements ); await micropip.install.callKwargs( - [wheels.stliteServer, wheels.streamlit, ...requirements], + [ + wheels.stliteServer, + wheels.streamlit, + ...requirements, + ...STLITE_REQUIREMENTS, + ], { keep_going: true } ); console.debug("Installed the wheels and the requirements"); From a92372670526acaeb014bf8f6922608dd428b1e6 Mon Sep 17 00:00:00 2001 From: "Yuichiro Tachibana (Tsuchiya)" Date: Wed, 7 Feb 2024 01:02:27 +0900 Subject: [PATCH 3/5] Fix urllib3 version spec --- packages/common/src/requirements.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/common/src/requirements.ts b/packages/common/src/requirements.ts index 30303f797..8704f1308 100644 --- a/packages/common/src/requirements.ts +++ b/packages/common/src/requirements.ts @@ -1,4 +1,4 @@ // stlite-specific requirements export const STLITE_REQUIREMENTS = [ - "urllib3==2.2.0", // `urllib3` supports Pyodide since 2.2.0. https://urllib3.readthedocs.io/en/stable/reference/contrib/emscripten.html + "urllib3>=2.2.0", // `urllib3` supports Pyodide since 2.2.0. https://urllib3.readthedocs.io/en/stable/reference/contrib/emscripten.html ]; From 0bdbeef74a35074331f412b262904fd15b063419 Mon Sep 17 00:00:00 2001 From: "Yuichiro Tachibana (Tsuchiya)" Date: Wed, 7 Feb 2024 01:25:05 +0900 Subject: [PATCH 4/5] Revert "Pin urllib3 version" This reverts commit 1d338cbf0a6d4ce9944f25f02d471eb050e56243. --- packages/common/src/index.ts | 1 - packages/common/src/requirements.ts | 4 ---- packages/desktop/bin/dump_artifacts.ts | 7 ++----- packages/kernel/src/worker.ts | 9 ++------- 4 files changed, 4 insertions(+), 17 deletions(-) delete mode 100644 packages/common/src/requirements.ts diff --git a/packages/common/src/index.ts b/packages/common/src/index.ts index 82868273b..2adbd2ced 100644 --- a/packages/common/src/index.ts +++ b/packages/common/src/index.ts @@ -1,3 +1,2 @@ -export * from "./requirements"; export * from "./requirements-txt"; export * from "./promise-delegate"; diff --git a/packages/common/src/requirements.ts b/packages/common/src/requirements.ts deleted file mode 100644 index 8704f1308..000000000 --- a/packages/common/src/requirements.ts +++ /dev/null @@ -1,4 +0,0 @@ -// stlite-specific requirements -export const STLITE_REQUIREMENTS = [ - "urllib3>=2.2.0", // `urllib3` supports Pyodide since 2.2.0. https://urllib3.readthedocs.io/en/stable/reference/contrib/emscripten.html -]; diff --git a/packages/desktop/bin/dump_artifacts.ts b/packages/desktop/bin/dump_artifacts.ts index a0391585b..68b3231c2 100755 --- a/packages/desktop/bin/dump_artifacts.ts +++ b/packages/desktop/bin/dump_artifacts.ts @@ -11,7 +11,7 @@ import { type PyodideInterface, version as pyodideVersion, } from "pyodide"; -import { parseRequirementsTxt, STLITE_REQUIREMENTS } from "@stlite/common"; +import { parseRequirementsTxt } from "@stlite/common"; import type { DesktopAppManifest } from "../electron/main"; // @ts-ignore @@ -132,10 +132,7 @@ async function installPackages( await pyodide.loadPackage(["micropip"]); const micropip = pyodide.pyimport("micropip"); - const requirements: string[] = [ - ...options.requirements, - ...STLITE_REQUIREMENTS, - ]; + const requirements: string[] = [...options.requirements]; if (options.useLocalKernelWheels) { const stliteKernelDir = path.dirname(require.resolve("@stlite/kernel")); // -> /path/to/kernel/dist const stliteKernelPyDir = path.resolve(stliteKernelDir, "../py"); // -> /path/to/kernel/py diff --git a/packages/kernel/src/worker.ts b/packages/kernel/src/worker.ts index 918414600..d3e215908 100644 --- a/packages/kernel/src/worker.ts +++ b/packages/kernel/src/worker.ts @@ -1,5 +1,5 @@ import type Pyodide from "pyodide"; -import { PromiseDelegate, STLITE_REQUIREMENTS } from "@stlite/common"; +import { PromiseDelegate } from "@stlite/common"; import { writeFileWithParents, renameWithParents } from "./file"; import { verifyRequirements } from "./requirements"; import { mockPyArrow } from "./mock"; @@ -180,12 +180,7 @@ async function loadPyodideAndPackages() { requirements ); await micropip.install.callKwargs( - [ - wheels.stliteServer, - wheels.streamlit, - ...requirements, - ...STLITE_REQUIREMENTS, - ], + [wheels.stliteServer, wheels.streamlit, ...requirements], { keep_going: true } ); console.debug("Installed the wheels and the requirements"); From 4e8bd776827f51216aad0562042ab7fd48cc050b Mon Sep 17 00:00:00 2001 From: "Yuichiro Tachibana (Tsuchiya)" Date: Wed, 7 Feb 2024 01:25:23 +0900 Subject: [PATCH 5/5] Update the streamlit submodule --- streamlit | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/streamlit b/streamlit index 8466c6c6b..740b29a74 160000 --- a/streamlit +++ b/streamlit @@ -1 +1 @@ -Subproject commit 8466c6c6b721966b04448e74856704d26c77be7d +Subproject commit 740b29a7499a8d3c8fcb1a3744be97d204cd38a6