Skip to content

Commit 81b56ea

Browse files
committed
lite: Add to generate jupyter_lite_config.json
1 parent 8f2bed8 commit 81b56ea

File tree

2 files changed

+50
-8
lines changed

2 files changed

+50
-8
lines changed

lite/jupyterlite-robotkernel/packages/robolite-kernel/package.json

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,8 +20,7 @@
2020
"types": "lib/index.d.ts",
2121
"style": "style/index.css",
2222
"files": [
23-
"{lib,style}/**/*.{css,d.ts,eot,gif,html,jpg,js,js.map,json,png,svg,woff2,ttf}",
24-
"pypi/*.{json,whl}"
23+
"{lib,style}/**/*.{css,d.ts,eot,gif,html,jpg,js,js.map,json,png,svg,woff2,ttf}"
2524
],
2625
"scripts": {
2726
"build": "yarn run build:lib && yarn run build:labextension:dev",

lite/jupyterlite-robotkernel/py_src/jupyterlite_robotkernel/piplite.py

Lines changed: 49 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -22,26 +22,69 @@
2222

2323

2424
class PipliteAddon(BasePipliteAddon):
25-
2625
def post_init(self, manager):
2726
"""update the root jupyter-lite.json with pipliteUrls"""
2827
yield from super().post_init(manager)
29-
if not set(self.output_wheels.glob("robotkernel-*")):
28+
if not any(
29+
[
30+
set(self.output_wheels.glob("robotkernel-*")),
31+
any(["/robotkernel-" in url for url in manager.piplite_urls]),
32+
]
33+
):
3034
# Install robotkernel
3135
self.output_wheels.mkdir(parents=True, exist_ok=True)
3236
subprocess.check_call(
3337
[PY, "-m", "pip", "wheel", "--prefer-binary", "robotkernel >= 1.6a2"],
34-
cwd=self.output_wheels
38+
cwd=self.output_wheels,
3539
)
3640
# Remove wheels that conflict with pyolite shims
3741
subprocess.check_call(["rm", *self.output_wheels.glob("ipykernel-*")])
38-
subprocess.check_call(["rm", *self.output_wheels.glob("widgetsnbextension-*")])
42+
subprocess.check_call(
43+
["rm", *self.output_wheels.glob("widgetsnbextension-*")]
44+
)
3945
# Remove binary wheels
40-
subprocess.check_call(["rm", *(set(self.output_wheels.glob("*")) - (set(self.output_wheels.glob("*-none-any.whl"))))])
46+
subprocess.check_call(
47+
[
48+
"rm",
49+
*(
50+
set(self.output_wheels.glob("*"))
51+
- (set(self.output_wheels.glob("*-none-any.whl")))
52+
),
53+
]
54+
)
55+
# Freeze
56+
PY2_PY3_EXCEPTIONS = ["testpath-0.6.0-py3-none-any.whl"]
57+
(manager.output_dir / "jupyter_lite_config.json").write_text(
58+
json.dumps(
59+
{
60+
"LiteBuildConfig": {
61+
"piplite_urls": [
62+
f"""https://files.pythonhosted.org/packages/py2.py3/{path.name[0]}/{path.name.split("-")[0]}/{path.name}"""
63+
for path in sorted(
64+
self.output_wheels.glob("*-none-any.whl")
65+
)
66+
if path.name.endswith("py2.py3-none-any.whl")
67+
or path.name in PY2_PY3_EXCEPTIONS
68+
]
69+
+ [
70+
f"""https://files.pythonhosted.org/packages/py3/{path.name[0]}/{path.name.split("-")[0]}/{path.name}"""
71+
for path in sorted(
72+
self.output_wheels.glob("*-none-any.whl")
73+
)
74+
if not path.name.endswith("py2.py3-none-any.whl")
75+
and path.name not in PY2_PY3_EXCEPTIONS
76+
]
77+
}
78+
},
79+
indent=4,
80+
)
81+
)
4182

4283
def patch_jupyterlite_json(self, jupyterlite_json, whl_index, whl_metas, pkg_jsons):
4384
"""add the piplite wheels to jupyter-lite.json"""
44-
super().patch_jupyterlite_json(jupyterlite_json, whl_index, whl_metas, pkg_jsons)
85+
super().patch_jupyterlite_json(
86+
jupyterlite_json, whl_index, whl_metas, pkg_jsons
87+
)
4588
config = json.loads(jupyterlite_json.read_text(**UTF8))
4689
old_urls = (
4790
config.setdefault(JUPYTER_CONFIG_DATA, {})

0 commit comments

Comments
 (0)