Upgrade Pyodide to 0.24.0 and install the native orjson package (#5598)

* Upgrade Pyodide to 0.24.0 and install the native orjson package

* add changeset

* add changeset

---------

Co-authored-by: gradio-pr-bot <gradio-pr-bot@users.noreply.github.com>
Co-authored-by: Abubakar Abid <abubakar@huggingface.co>
This commit is contained in:
Yuichiro Tachibana (Tsuchiya) 2023-09-20 01:51:37 +08:00 committed by GitHub
parent d1ad1f671c
commit 6b17143868
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 8 additions and 5 deletions

View File

@ -0,0 +1,6 @@
---
"@gradio/wasm": patch
"gradio": patch
---
feat:Upgrade Pyodide to 0.24.0 and install the native orjson package

View File

@ -175,8 +175,7 @@ class App(FastAPI):
blocks: gradio.Blocks, app_kwargs: Dict[str, Any] | None = None
) -> App:
app_kwargs = app_kwargs or {}
if not wasm_utils.IS_WASM:
app_kwargs.setdefault("default_response_class", ORJSONResponse)
app_kwargs.setdefault("default_response_class", ORJSONResponse)
app = App(**app_kwargs)
app.configure_app(blocks)

View File

@ -14,7 +14,7 @@ import { makeHttpRequest } from "./http";
import scriptRunnerPySource from "./py/script_runner.py?raw";
import unloadModulesPySource from "./py/unload_modules.py?raw";
importScripts("https://cdn.jsdelivr.net/pyodide/v0.23.2/full/pyodide.js");
importScripts("https://cdn.jsdelivr.net/pyodide/v0.24.0/full/pyodide.js");
let pyodide: PyodideInterface;
@ -71,9 +71,7 @@ async function loadPyodideAndPackages(
];
console.debug("Loading Gradio wheels.", gradioWheelUrls);
await micropip.add_mock_package("ffmpy", "0.3.0");
await micropip.add_mock_package("orjson", "3.8.12");
await micropip.add_mock_package("aiohttp", "3.8.4");
await micropip.add_mock_package("multidict", "4.7.6");
await pyodide.loadPackage(["ssl", "distutils", "setuptools"]);
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.callKwargs(gradioWheelUrls, {