From 4883bbada9a7030ba86917b93f61943cd9178a6b Mon Sep 17 00:00:00 2001 From: Eric Pugh Date: Fri, 9 Feb 2024 09:29:05 -0500 Subject: [PATCH 1/4] Attempt to upgrade to Jupyterlite 0.2.3 --- README.md | 7 ++++++- jupyterlite/jupyter_lite_config.json | 8 ++++---- jupyterlite/requirements.txt | 27 ++++++++++++--------------- 3 files changed, 22 insertions(+), 20 deletions(-) diff --git a/README.md b/README.md index b928388..71c2bb8 100644 --- a/README.md +++ b/README.md @@ -6,7 +6,7 @@ Pyodide kernel and all dependencies according Jupyterlite [manual](https://jupyt ## How to -* The build is [Docker](./Dockerfile) based. For a local run try `docker run -it --rm -e TARGET_DIR=/dist -v "$(pwd)":/dist $(docker build -q .)`. +* The build is [Docker](./Dockerfile) based. For a local run try `docker run -it --rm -e TARGET_DIR=/dist -v "$(pwd)":/dist $(docker build .)`. This will generate a `jupyter-lite-build.tgz` with the self-contained Jupyterlite web app in your current directory. * On Github a [GH action](./action.yml) uses the Docker build and is embedded into the [build workflow](./.github/workflows/main.yml) which also add the build artifact as a release asset. @@ -23,3 +23,8 @@ Unzip the TGZ file which will then unpack into `./notebooks`. Run either `python -m http.server 8000 --directory ./notebooks` or `ruby -run -ehttpd ./notebooks -p 8000` Browse to http://localhost:8000 and you should see the Jupyterlite interface. + + +## Details + +`./jupyterlite/jupyter_lite_config.json` defines all the files to be compiled at build time instead of run time for offline use. See https://jupyterlite.readthedocs.io/en/latest/howto/configure/advanced/offline.html diff --git a/jupyterlite/jupyter_lite_config.json b/jupyterlite/jupyter_lite_config.json index 7fa98f3..abef717 100644 --- a/jupyterlite/jupyter_lite_config.json +++ b/jupyterlite/jupyter_lite_config.json @@ -10,8 +10,8 @@ "https://files.pythonhosted.org/packages/py2.py3/i/ipycanvas/ipycanvas-0.13.1-py2.py3-none-any.whl", "https://files.pythonhosted.org/packages/py2.py3/i/ipycytoscape/ipycytoscape-1.3.3-py2.py3-none-any.whl", "https://files.pythonhosted.org/packages/py2.py3/i/ipython-genutils/ipython_genutils-0.2.0-py2.py3-none-any.whl", - "https://files.pythonhosted.org/packages/py2.py3/i/ipyvue/ipyvue-1.8.0-py2.py3-none-any.whl", - "https://files.pythonhosted.org/packages/py2.py3/i/ipyvuetify/ipyvuetify-1.8.4-py2.py3-none-any.whl", + "https://files.pythonhosted.org/packages/py2.py3/i/ipyvue/ipyvue-1.10.1-py2.py3-none-any.whl", + "https://files.pythonhosted.org/packages/py2.py3/i/ipyvuetify/ipyvuetify-1.8.10-py2.py3-none-any.whl", "https://files.pythonhosted.org/packages/py2.py3/j/jsonpointer/jsonpointer-2.3-py2.py3-none-any.whl", "https://files.pythonhosted.org/packages/py2.py3/m/mistune/mistune-2.0.5-py2.py3-none-any.whl", "https://files.pythonhosted.org/packages/py2.py3/p/pandocfilters/pandocfilters-1.5.0-py2.py3-none-any.whl", @@ -37,7 +37,7 @@ "https://files.pythonhosted.org/packages/py3/e/entrypoints/entrypoints-0.4-py3-none-any.whl", "https://files.pythonhosted.org/packages/py3/f/fqdn/fqdn-1.5.1-py3-none-any.whl", "https://files.pythonhosted.org/packages/py3/i/idna/idna-3.4-py3-none-any.whl", - "https://files.pythonhosted.org/packages/py3/i/ipyleaflet/ipyleaflet-0.17.2-py3-none-any.whl", + "https://files.pythonhosted.org/packages/py3/i/ipyleaflet/ipyleaflet-0.17.4-py3-none-any.whl", "https://files.pythonhosted.org/packages/py3/i/ipython/ipython-8.10.0-py3-none-any.whl", "https://files.pythonhosted.org/packages/py3/i/ipywidgets/ipywidgets-8.0.4-py3-none-any.whl", "https://files.pythonhosted.org/packages/py3/i/isoduration/isoduration-20.11.0-py3-none-any.whl", @@ -76,4 +76,4 @@ "https://files.pythonhosted.org/packages/py3/x/xyzservices/xyzservices-2022.9.0-py3-none-any.whl" ] } -} \ No newline at end of file +} diff --git a/jupyterlite/requirements.txt b/jupyterlite/requirements.txt index 6da9c53..f1c0793 100644 --- a/jupyterlite/requirements.txt +++ b/jupyterlite/requirements.txt @@ -1,14 +1,14 @@ -# Contents below from https://github.com/jupyterlite/demo/blob/main/requirements.txt - # Core modules (mandatory) -jupyterlite-core==0.1.0 -jupyterlab~=3.5.1 +jupyterlite-core==0.2.3 +jupyterlab~=4.0.11 +notebook~=7.0.7 + # Python kernel (optional) -jupyterlite-pyodide-kernel==0.0.8 +jupyterlite-pyodide-kernel==0.2.1 # JavaScript kernel (optional) -jupyterlite-javascript-kernel==0.1.0b21 +jupyterlite-javascript-kernel==0.2.3 # Language support (optional) jupyterlab-language-pack-fr-FR @@ -22,18 +22,19 @@ jupyterlite-p5-kernel==0.1.0 jupyterlite-xeus-lua==0.3.1 # JupyterLab: Fasta file renderer (optional) -jupyterlab-fasta>=3,<4 +jupyterlab-fasta>=3.3.0,<4 # JupyterLab: Geojson file renderer (optional) -jupyterlab-geojson>=3,<4 +jupyterlab-geojson>=3.4.0,<4 # JupyterLab: guided tour (optional) -jupyterlab-tour +# TODO: re-enable after https://github.com/jupyterlab-contrib/jupyterlab-tour/issues/82 +# jupyterlab-tour # JupyterLab: dark theme jupyterlab-night # JupyterLab: Miami nights theme (optional) jupyterlab_miami_nights # Python: ipywidget library for Jupyter notebooks (optional) -ipywidgets>=8.0.0,<9 +ipywidgets>=8.1.1,<9 # Python: ipyevents library for Jupyter notebooks (optional) ipyevents>=2.0.1 # Python: interative Matplotlib library for Jupyter notebooks (optional) @@ -43,11 +44,7 @@ ipycanvas>=0.9.1 # Python: ipyleaflet library for Jupyter notebooks (optional) ipyleaflet -# Python: plotting libraries (optional) -plotly>=5,<6 -bqplot - # Contents below added from https://jupyterlite.readthedocs.io/en/latest/howto/configure/advanced/offline.html -jupyterlite-core[mathjax]==0.1.0 \ No newline at end of file +#jupyterlite-core[mathjax]==0.1.0 From c0c4db19f9447f949d0a8ce510548ac7b56796bf Mon Sep 17 00:00:00 2001 From: Eric Pugh Date: Fri, 9 Feb 2024 11:12:05 -0500 Subject: [PATCH 2/4] local server that supports wasm files --- server.py | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) create mode 100644 server.py diff --git a/server.py b/server.py new file mode 100644 index 0000000..a13d53b --- /dev/null +++ b/server.py @@ -0,0 +1,27 @@ +import http.server +import socketserver + +PORT = 8080 + +class HttpRequestHandler(http.server.SimpleHTTPRequestHandler): + extensions_map = { + '': 'application/octet-stream', + '.manifest': 'text/cache-manifest', + '.html': 'text/html', + '.png': 'image/png', + '.jpg': 'image/jpg', + '.svg': 'image/svg+xml', + '.css': 'text/css', + '.js':'application/x-javascript', + '.wasm': 'application/wasm', + '.json': 'application/json', + '.xml': 'application/xml', + } + +httpd = socketserver.TCPServer(("localhost", PORT), HttpRequestHandler) + +try: + print(f"serving at http://localhost:{PORT}") + httpd.serve_forever() +except KeyboardInterrupt: + pass From 24e2333e2e6b4ac5160e9e14b163689cf51e90d8 Mon Sep 17 00:00:00 2001 From: Eric Pugh Date: Fri, 9 Feb 2024 14:09:38 -0500 Subject: [PATCH 3/4] Now getting futhur, till crash on import name 'BaseComm' --- Dockerfile | 1 - 1 file changed, 1 deletion(-) diff --git a/Dockerfile b/Dockerfile index 77b8100..e2b02a5 100644 --- a/Dockerfile +++ b/Dockerfile @@ -18,5 +18,4 @@ CMD jupyter lite build \ --lite-dir /build \ --no-sourcemaps \ --output-dir notebooks \ - --pyodide https://github.com/pyodide/pyodide/releases/download/0.23.2/pyodide-0.23.2.tar.bz2 \ && tar -czf ${TARGET_DIR}/jupyter-lite-build.tgz notebooks From aa1588493055eb76a765dedce8f01a197a16f75d Mon Sep 17 00:00:00 2001 From: Eric Pugh Date: Fri, 9 Feb 2024 14:13:20 -0500 Subject: [PATCH 4/4] create sourcemaps, so we don't have any 404 from server.py... --- Dockerfile | 1 - 1 file changed, 1 deletion(-) diff --git a/Dockerfile b/Dockerfile index e2b02a5..a684580 100644 --- a/Dockerfile +++ b/Dockerfile @@ -16,6 +16,5 @@ ENV TARGET_DIR=${GITHUB_WORKSPACE:-/github/workspace} CMD jupyter lite build \ --config /build/jupyter_lite_config.json \ --lite-dir /build \ - --no-sourcemaps \ --output-dir notebooks \ && tar -czf ${TARGET_DIR}/jupyter-lite-build.tgz notebooks