Skip to content

Commit

Permalink
Update Jupyterlite (#130)
Browse files Browse the repository at this point in the history
  • Loading branch information
hoxbro authored Aug 13, 2024
1 parent 928809b commit 8e93b9e
Show file tree
Hide file tree
Showing 5 changed files with 28 additions and 31 deletions.
2 changes: 1 addition & 1 deletion pixi.toml
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,7 @@ nodejs = "*"
python-build = "*"

[feature.lite.tasks]
lite-build = "bash scripts/jupyterlite/build.sh"
lite-build = { cmd = "bash build.sh", cwd = "scripts/jupyterlite" }
# Service worker only work on 127.0.0.1
# https://jupyterlite.readthedocs.io/en/latest/howto/configure/advanced/service-worker.html#limitations
lite-server = "python -m http.server --directory ./jupyterlite --bind 127.0.0.1"
7 changes: 1 addition & 6 deletions scripts/jupyterlite/build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,9 @@

set -euxo pipefail

PACKAGE="holonote"

python -m build -w .
VERSION=$(python -c "import $PACKAGE; print($PACKAGE._version.__version__)")
export VERSION
python -m build -w ../..

# Update lockfiles
cd "$(dirname "${BASH_SOURCE[0]}")"
rm -rf node_modules
npm install .
node update_lock.js
Expand Down
25 changes: 12 additions & 13 deletions scripts/jupyterlite/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion scripts/jupyterlite/package.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"dependencies": {
"pyodide": "^0.25.1"
"pyodide": "^0.26.2"
}
}
23 changes: 13 additions & 10 deletions scripts/jupyterlite/patch_lock.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
import hashlib
import json
import os
import os.path
from glob import glob

from packaging.utils import parse_wheel_filename


def calculate_sha256(file_path):
sha256_hash = hashlib.sha256()
Expand All @@ -26,21 +28,22 @@ def calculate_sha256(file_path):

for p in data["packages"].values():
if not p["file_name"].startswith("http"):
p["file_name"] = os.path.join(url, p["file_name"])
p["file_name"] = f'{url}/{p["file_name"]}'


whl_files = glob("../../dist/*.whl")
for whl_file in whl_files:
name, version, *_ = parse_wheel_filename(os.path.basename(whl_file))

# Special handling of holonote
whl_file = glob("../../dist/*.whl")[0]
hn = data["packages"]["holonote"]
hn["version"] = os.environ["VERSION"]
hn["file_name"] = os.path.basename(whl_file)
hn["sha256"] = calculate_sha256(whl_file)
hn["imports"] = ["holonote"] # Not completely sure why this is empty
package = data["packages"][name]
package["version"] = str(version)
package["file_name"] = os.path.basename(whl_file)
package["sha256"] = calculate_sha256(whl_file)
package["imports"] = [name]

# To avoid importing it in the notebooks, we can't add it to pandas directly
# as fastparquet depends on it. So we add it to hvplot instead.
data["packages"]["hvplot"]["depends"].extend(["fastparquet"])

data["packages"]["holoviews"]["depends"].extend(["pyparsing"])


Expand Down

0 comments on commit 8e93b9e

Please sign in to comment.