From 6995bba6a8cbcf3bf893277863ee1d41dce13944 Mon Sep 17 00:00:00 2001
From: sheepmax <guichardmax@gmail.com>
Date: Sat, 9 Sep 2023 17:56:23 +0200
Subject: [PATCH] Install ipywidgets by default

---
 thebe_lite/_static/sphinx-thebe.js | 13 +++++++------
 1 file changed, 7 insertions(+), 6 deletions(-)

diff --git a/thebe_lite/_static/sphinx-thebe.js b/thebe_lite/_static/sphinx-thebe.js
index 1a9fdf86..ee909c75 100644
--- a/thebe_lite/_static/sphinx-thebe.js
+++ b/thebe_lite/_static/sphinx-thebe.js
@@ -175,8 +175,8 @@ var configureThebe = () => {
 
     updateThebeButtonStatus(
       `<span class='launch_msg'>Launching Pyodide kernel: </span><span class='status'>` +
-      data.status +
-      "</span>"
+        data.status +
+        "</span>"
     );
 
     if (data.status === "attached") {
@@ -301,7 +301,7 @@ function override_pyodide_lookup(fs, server_path) {
       currentDirectory += directory + "/";
       try {
         fs.mkdir(currentDirectory);
-      } catch { }
+      } catch {}
     }
   }
 
@@ -430,8 +430,9 @@ var initThebe = async () => {
   // 4. Execute the override_pyodide_lookup function in JS, and bake in the relative path from root in the book (the home)
   // NOTE: All functions used in override_pyodide_lookup should be nested inside it, since the web worker cannot access functions in this script
   thebelab.session.kernel.requestExecute({
-    code: `import js; import pyodide_js; js.fs = pyodide_js.FS; js.eval("""${override_pyodide_lookup.toString()}"""); js.eval(f"override_pyodide_lookup(fs, '${location.pathname.split("/").slice(0, -1).join("/") + "/"
-      }')")`,
+    code: `import js; import pyodide_js; js.fs = pyodide_js.FS; js.eval("""${override_pyodide_lookup.toString()}"""); js.eval(f"override_pyodide_lookup(fs, '${
+      location.pathname.split("/").slice(0, -1).join("/") + "/"
+    }')")`,
   });
 
   const request = new XMLHttpRequest();
@@ -451,7 +452,7 @@ var initThebe = async () => {
 
   // Fix for issues with ipywidgets in Thebe
   await thebelab.session.kernel.requestExecute({
-    code: `import ipykernel; ipykernel.version_info = (0,0)`,
+    code: `import ipykernel; ipykernel.version_info = (0,0)\n%pip install ipywidgets`,
   }).done;
   updateThebeButtonStatus("Running pre-intialized cells...");
   setupSpecialTaggedElements();
-- 
GitLab