From 376dfaaa808866cc114eff3cf1635746c3c50c5d Mon Sep 17 00:00:00 2001 From: "Yuichiro Tachibana (Tsuchiya)" Date: Fri, 3 May 2024 15:12:15 +0900 Subject: [PATCH] Specify the fastapi version on Lite to avoid ujson installation which is not available on Pyodide yet (#8204) * Specify the fastapi version on Lite to avoid ujson installation which is not available on Pyodide yet * add changeset * Refactoring --------- Co-authored-by: gradio-pr-bot --- .changeset/shiny-toes-beam.md | 6 ++++++ js/wasm/src/webworker/index.ts | 14 ++++++++++---- 2 files changed, 16 insertions(+), 4 deletions(-) create mode 100644 .changeset/shiny-toes-beam.md diff --git a/.changeset/shiny-toes-beam.md b/.changeset/shiny-toes-beam.md new file mode 100644 index 0000000000..4bf298cc84 --- /dev/null +++ b/.changeset/shiny-toes-beam.md @@ -0,0 +1,6 @@ +--- +"@gradio/wasm": patch +"gradio": patch +--- + +fix:Specify the fastapi version on Lite to avoid ujson installation which is not available on Pyodide yet diff --git a/js/wasm/src/webworker/index.ts b/js/wasm/src/webworker/index.ts index ba41c92f54..7b012130d1 100644 --- a/js/wasm/src/webworker/index.ts +++ b/js/wasm/src/webworker/index.ts @@ -73,12 +73,18 @@ async function initializeEnvironment( ]; console.debug("Loading Gradio wheels.", gradioWheelUrls); updateProgress("Loading Gradio wheels"); - await micropip.add_mock_package("ffmpy", "0.3.0"); await pyodide.loadPackage(["ssl", "setuptools"]); - await micropip.install(["typing-extensions>=4.8.0"]); // Typing extensions needs to be installed first otherwise the versions from the pyodide lockfile is used which is incompatible with the latest fastapi. - await micropip.install(["markdown-it-py[linkify]~=2.2.0"]); // On 3rd June 2023, markdown-it-py 3.0.0 has been released. The `gradio` package depends on its `>=2.0.0` version so its 3.x will be resolved. However, it conflicts with `mdit-py-plugins`'s dependency `markdown-it-py >=1.0.0,<3.0.0` and micropip currently can't resolve it. So we explicitly install the compatible version of the library here. - await micropip.install(["anyio==3.*"]); // `fastapi` depends on `anyio>=3.4.0,<5` so its 4.* can be installed, but it conflicts with the anyio version `httpx` depends on, `==3.*`. Seems like micropip can't resolve it for now, so we explicitly install the compatible version of the library here. + await micropip.add_mock_package("ffmpy", "0.3.0"); await micropip.add_mock_package("pydantic", "2.4.2"); // PydanticV2 is not supported on Pyodide yet. Mock it here for installing the `gradio` package to pass the version check. Then, install PydanticV1 below. + await micropip.install.callKwargs( + [ + "typing-extensions>=4.8.0", // Typing extensions needs to be installed first otherwise the versions from the pyodide lockfile is used which is incompatible with the latest fastapi. + "markdown-it-py[linkify]~=2.2.0", // On 3rd June 2023, markdown-it-py 3.0.0 has been released. The `gradio` package depends on its `>=2.0.0` version so its 3.x will be resolved. However, it conflicts with `mdit-py-plugins`'s dependency `markdown-it-py >=1.0.0,<3.0.0` and micropip currently can't resolve it. So we explicitly install the compatible version of the library here. + "anyio==3.*", // `fastapi` depends on `anyio>=3.4.0,<5` so its 4.* can be installed, but it conflicts with the anyio version `httpx` depends on, `==3.*`. Seems like micropip can't resolve it for now, so we explicitly install the compatible version of the library here. + "fastapi<0.111.0" // `fastapi==0.111.0` added `ujson` as a dependency, but it's not available on Pyodide yet. + ], + { keep_going: true } + ); await micropip.install.callKwargs(gradioWheelUrls, { keep_going: true });