mirror of
https://github.com/gradio-app/gradio.git
synced 2025-04-12 12:40:29 +08:00
Lite fix matplotlib install postprocess (#5998)
* Fix the postprocessing after installing matplotlib * Apply formatter * add changeset --------- Co-authored-by: gradio-pr-bot <gradio-pr-bot@users.noreply.github.com>
This commit is contained in:
parent
b8b9f6d27e
commit
584fd97d59
5
.changeset/wet-dingos-battle.md
Normal file
5
.changeset/wet-dingos-battle.md
Normal file
@ -0,0 +1,5 @@
|
||||
---
|
||||
"@gradio/wasm": minor
|
||||
---
|
||||
|
||||
feat:Lite fix matplotlib install postprocess
|
@ -91,7 +91,7 @@ async function loadPyodideAndPackages(
|
||||
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(["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.install(["fastapi<0.104.0"]); // XXX: Workaround for #5986.
|
||||
await micropip.install(["fastapi<0.104.0"]); // XXX: Workaround for #5986.
|
||||
await micropip.install.callKwargs(gradioWheelUrls, {
|
||||
keep_going: true
|
||||
});
|
||||
@ -330,9 +330,11 @@ self.onmessage = async (event: MessageEvent<InMessage>): Promise<void> => {
|
||||
.callKwargs(requirements, { keep_going: true })
|
||||
.then(() => {
|
||||
if (requirements.includes("matplotlib")) {
|
||||
// Ref: https://github.com/streamlit/streamlit/blob/1.22.0/lib/streamlit/web/bootstrap.py#L111
|
||||
// This backend setting is required to use matplotlib in Wasm environment.
|
||||
return pyodide.runPythonAsync(`
|
||||
from stlite_server.bootstrap import _fix_matplotlib_crash
|
||||
_fix_matplotlib_crash()
|
||||
import matplotlib
|
||||
matplotlib.use("agg")
|
||||
`);
|
||||
}
|
||||
})
|
||||
|
Loading…
x
Reference in New Issue
Block a user