Skip to content

Commit a62ae1e

Browse files
committed
lite: Fix robotkernel dependencies
1 parent 81b56ea commit a62ae1e

File tree

8 files changed

+164
-66
lines changed

8 files changed

+164
-66
lines changed

lite/jupyter-lite.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
"collaborative": true,
66
"exposeAppInBrowser": true,
77
"disabledExtensions": [
8+
"@jupyterlite/javascript-kernel-extension",
89
"jupyterlab-videochat:rooms-server",
910
"nbdime-jupyterlab"
1011
]

lite/jupyterlite-robotkernel/MANIFEST.in

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,17 @@
11
include LICENSE
22
include *.md
3-
include pyproject.toml
43
include package.json
54
include install.json
6-
include ts*.json
75
include yarn.lock
86

9-
graft jupyterlite_robotkernel/labextension
7+
graft py_src/jupyterlite_robotkernel/addons
8+
graft py_src/jupyterlite_robotkernel/labextension
109

1110
# Javascript files
12-
graft src
11+
graft packages
1312
graft style
1413
prune **/node_modules
15-
prune lib
16-
prune binder
14+
prune **/lib
1715

1816
# Patterns to exclude from any directory
1917
global-exclude *~

lite/jupyterlite-robotkernel/py_src/jupyterlite_robotkernel/addons/__init__.py

Whitespace-only changes.

lite/jupyterlite-robotkernel/py_src/jupyterlite_robotkernel/piplite.py renamed to lite/jupyterlite-robotkernel/py_src/jupyterlite_robotkernel/addons/piplite.py

Lines changed: 2 additions & 58 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
"""a JupyterLite addon for supporting piplite wheels"""
22

3+
# Overridden to patch_jupyterlite_json to support robolite-kernel
4+
35
from jupyterlite.addons.piplite import PipliteAddon as BasePipliteAddon
46
from jupyterlite.addons.piplite import PIPLITE_URLS
57
from jupyterlite.addons.piplite import write_wheel_index
@@ -12,7 +14,6 @@
1214
from pathlib import Path
1315

1416
import json
15-
import subprocess
1617
import sys
1718

1819

@@ -22,63 +23,6 @@
2223

2324

2425
class PipliteAddon(BasePipliteAddon):
25-
def post_init(self, manager):
26-
"""update the root jupyter-lite.json with pipliteUrls"""
27-
yield from super().post_init(manager)
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-
):
34-
# Install robotkernel
35-
self.output_wheels.mkdir(parents=True, exist_ok=True)
36-
subprocess.check_call(
37-
[PY, "-m", "pip", "wheel", "--prefer-binary", "robotkernel >= 1.6a2"],
38-
cwd=self.output_wheels,
39-
)
40-
# Remove wheels that conflict with pyolite shims
41-
subprocess.check_call(["rm", *self.output_wheels.glob("ipykernel-*")])
42-
subprocess.check_call(
43-
["rm", *self.output_wheels.glob("widgetsnbextension-*")]
44-
)
45-
# Remove binary wheels
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-
)
8226

8327
def patch_jupyterlite_json(self, jupyterlite_json, whl_index, whl_metas, pkg_jsons):
8428
"""add the piplite wheels to jupyter-lite.json"""
Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
"""Install RobotKernel wheels."""
2+
from importlib import resources
3+
from jupyterlite.addons.base import BaseAddon
4+
from pathlib import Path
5+
6+
import json
7+
import traitlets
8+
9+
DEFAULT_WHEELS = json.loads(
10+
resources.read_text("jupyterlite_robotkernel.addons", "wheels.json")
11+
)
12+
13+
14+
class RobotKernelAddon(BaseAddon):
15+
"""Ensures the unique dependencies of robotkernel are available."""
16+
17+
__all__ = ["pre_build"]
18+
19+
wheel_urls = traitlets.List(DEFAULT_WHEELS).tag(config=True)
20+
21+
def pre_build(self, manager):
22+
"""Downloads wheels."""
23+
for wheel in self.wheel_urls:
24+
dest = manager.output_dir / "pypi" / Path(wheel).name
25+
if dest.exists():
26+
continue
27+
yield dict(
28+
name=f"""fetch:{wheel.rsplit("/", 1)[-1]}""",
29+
actions=[(self.fetch_one, [wheel, dest])],
30+
targets=[dest]
31+
)
Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
[
2+
"https://files.pythonhosted.org/packages/py2.py3/a/asttokens/asttokens-2.0.5-py2.py3-none-any.whl",
3+
"https://files.pythonhosted.org/packages/py2.py3/a/attrs/attrs-21.4.0-py2.py3-none-any.whl",
4+
"https://files.pythonhosted.org/packages/py2.py3/b/backcall/backcall-0.2.0-py2.py3-none-any.whl",
5+
"https://files.pythonhosted.org/packages/py2.py3/b/bleach/bleach-4.1.0-py2.py3-none-any.whl",
6+
"https://files.pythonhosted.org/packages/py2.py3/d/defusedxml/defusedxml-0.7.1-py2.py3-none-any.whl",
7+
"https://files.pythonhosted.org/packages/py2.py3/d/docutils/docutils-0.18.1-py2.py3-none-any.whl",
8+
"https://files.pythonhosted.org/packages/py2.py3/e/executing/executing-0.8.3-py2.py3-none-any.whl",
9+
"https://files.pythonhosted.org/packages/py2.py3/i/ipython_genutils/ipython_genutils-0.2.0-py2.py3-none-any.whl",
10+
"https://files.pythonhosted.org/packages/py2.py3/i/ipywidgets/ipywidgets-7.7.0-py2.py3-none-any.whl",
11+
"https://files.pythonhosted.org/packages/py2.py3/j/jedi/jedi-0.18.1-py2.py3-none-any.whl",
12+
"https://files.pythonhosted.org/packages/py2.py3/j/jupyterlab_pygments/jupyterlab_pygments-0.1.2-py2.py3-none-any.whl",
13+
"https://files.pythonhosted.org/packages/py2.py3/l/lunr/lunr-0.6.2-py2.py3-none-any.whl",
14+
"https://files.pythonhosted.org/packages/py2.py3/m/mistune/mistune-0.8.4-py2.py3-none-any.whl",
15+
"https://files.pythonhosted.org/packages/py2.py3/p/pandocfilters/pandocfilters-1.5.0-py2.py3-none-any.whl",
16+
"https://files.pythonhosted.org/packages/py2.py3/p/parso/parso-0.8.3-py2.py3-none-any.whl",
17+
"https://files.pythonhosted.org/packages/py2.py3/p/pexpect/pexpect-4.8.0-py2.py3-none-any.whl",
18+
"https://files.pythonhosted.org/packages/py2.py3/p/pickleshare/pickleshare-0.7.5-py2.py3-none-any.whl",
19+
"https://files.pythonhosted.org/packages/py2.py3/p/ptyprocess/ptyprocess-0.7.0-py2.py3-none-any.whl",
20+
"https://files.pythonhosted.org/packages/py2.py3/p/pycparser/pycparser-2.21-py2.py3-none-any.whl",
21+
"https://files.pythonhosted.org/packages/py2.py3/p/python_dateutil/python_dateutil-2.8.2-py2.py3-none-any.whl",
22+
"https://files.pythonhosted.org/packages/py2.py3/s/six/six-1.16.0-py2.py3-none-any.whl",
23+
"https://files.pythonhosted.org/packages/py2.py3/t/testpath/testpath-0.6.0-py3-none-any.whl",
24+
"https://files.pythonhosted.org/packages/py2.py3/w/wcwidth/wcwidth-0.2.5-py2.py3-none-any.whl",
25+
"https://files.pythonhosted.org/packages/py2.py3/w/webencodings/webencodings-0.5.1-py2.py3-none-any.whl",
26+
"https://files.pythonhosted.org/packages/py3/J/Jinja2/Jinja2-3.1.1-py3-none-any.whl",
27+
"https://files.pythonhosted.org/packages/py3/P/Pygments/Pygments-2.11.2-py3-none-any.whl",
28+
"https://files.pythonhosted.org/packages/py3/S/Send2Trash/Send2Trash-1.8.0-py3-none-any.whl",
29+
"https://files.pythonhosted.org/packages/py3/a/argon2_cffi/argon2_cffi-21.3.0-py3-none-any.whl",
30+
"https://files.pythonhosted.org/packages/py3/b/beautifulsoup4/beautifulsoup4-4.10.0-py3-none-any.whl",
31+
"https://files.pythonhosted.org/packages/py3/d/decorator/decorator-5.1.1-py3-none-any.whl",
32+
"https://files.pythonhosted.org/packages/py3/e/entrypoints/entrypoints-0.4-py3-none-any.whl",
33+
"https://files.pythonhosted.org/packages/py3/i/ipython/ipython-8.2.0-py3-none-any.whl",
34+
"https://files.pythonhosted.org/packages/py3/j/jsonschema/jsonschema-4.4.0-py3-none-any.whl",
35+
"https://files.pythonhosted.org/packages/py3/j/jupyter_client/jupyter_client-7.2.0-py3-none-any.whl",
36+
"https://files.pythonhosted.org/packages/py3/j/jupyter_core/jupyter_core-4.9.2-py3-none-any.whl",
37+
"https://files.pythonhosted.org/packages/py3/j/jupyterlab_widgets/jupyterlab_widgets-1.1.0-py3-none-any.whl",
38+
"https://files.pythonhosted.org/packages/py3/m/matplotlib_inline/matplotlib_inline-0.1.3-py3-none-any.whl",
39+
"https://files.pythonhosted.org/packages/py3/n/nbclient/nbclient-0.5.13-py3-none-any.whl",
40+
"https://files.pythonhosted.org/packages/py3/n/nbconvert/nbconvert-6.4.5-py3-none-any.whl",
41+
"https://files.pythonhosted.org/packages/py3/n/nbformat/nbformat-5.2.0-py3-none-any.whl",
42+
"https://files.pythonhosted.org/packages/py3/n/nest_asyncio/nest_asyncio-1.5.4-py3-none-any.whl",
43+
"https://files.pythonhosted.org/packages/py3/n/notebook/notebook-6.4.10-py3-none-any.whl",
44+
"https://files.pythonhosted.org/packages/py3/p/packaging/packaging-21.3-py3-none-any.whl",
45+
"https://files.pythonhosted.org/packages/py3/p/prometheus_client/prometheus_client-0.13.1-py3-none-any.whl",
46+
"https://files.pythonhosted.org/packages/py3/p/prompt_toolkit/prompt_toolkit-3.0.28-py3-none-any.whl",
47+
"https://files.pythonhosted.org/packages/py3/p/pure_eval/pure_eval-0.2.2-py3-none-any.whl",
48+
"https://files.pythonhosted.org/packages/py3/p/pyparsing/pyparsing-3.0.7-py3-none-any.whl",
49+
"https://files.pythonhosted.org/packages/py3/r/robotframework/robotframework-5.0-py3-none-any.whl",
50+
"https://files.pythonhosted.org/packages/py3/r/robotkernel/robotkernel-1.6a2-py3-none-any.whl",
51+
"https://files.pythonhosted.org/packages/py3/s/setuptools/setuptools-61.2.0-py3-none-any.whl",
52+
"https://files.pythonhosted.org/packages/py3/s/soupsieve/soupsieve-2.3.1-py3-none-any.whl",
53+
"https://files.pythonhosted.org/packages/py3/s/stack_data/stack_data-0.2.0-py3-none-any.whl",
54+
"https://files.pythonhosted.org/packages/py3/t/terminado/terminado-0.13.3-py3-none-any.whl",
55+
"https://files.pythonhosted.org/packages/py3/t/traitlets/traitlets-5.1.1-py3-none-any.whl"
56+
]
Lines changed: 67 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,67 @@
1+
"""Generate wheels.json for RobotKernelAddon
2+
3+
Usage:
4+
5+
python wheels.py
6+
7+
"""
8+
9+
from contextlib import contextmanager
10+
from tempfile import mkdtemp
11+
from pathlib import Path
12+
13+
import json
14+
import os
15+
import subprocess
16+
import sys
17+
import shutil
18+
19+
PY = Path(sys.executable)
20+
21+
22+
@contextmanager
23+
def NamedTemporaryDirectory():
24+
tmpdir = mkdtemp()
25+
try:
26+
yield tmpdir
27+
finally:
28+
shutil.rmtree(tmpdir)
29+
30+
31+
def wheels_json(tmpdir: str):
32+
cwd = Path(tmpdir).resolve()
33+
cwd.mkdir(parents=True, exist_ok=True)
34+
# Install robotkernel
35+
subprocess.check_call(
36+
[PY, "-m", "pip", "wheel", "--prefer-binary", "robotkernel >=1.6a1"], cwd=cwd
37+
)
38+
# Remove wheels that conflict with pyolite shims
39+
for path in cwd.glob("ipykernel-*"):
40+
os.unlink(path)
41+
for path in cwd.glob("widgetsnbextension-*"):
42+
os.unlink(path)
43+
# Remove binary wheels
44+
for path in set(cwd.glob("*")) - (set(cwd.glob("*-none-any.whl"))):
45+
os.unlink(path)
46+
# Freeze
47+
PY2_PY3_EXCEPTIONS = ["testpath-0.6.0-py3-none-any.whl"]
48+
return json.dumps(
49+
[
50+
f"""https://files.pythonhosted.org/packages/py2.py3/{path.name[0]}/{path.name.split("-")[0]}/{path.name}"""
51+
for path in sorted(cwd.glob("*-none-any.whl"))
52+
if path.name.endswith("py2.py3-none-any.whl")
53+
or path.name in PY2_PY3_EXCEPTIONS
54+
]
55+
+ [
56+
f"""https://files.pythonhosted.org/packages/py3/{path.name[0]}/{path.name.split("-")[0]}/{path.name}"""
57+
for path in sorted(cwd.glob("*-none-any.whl"))
58+
if not path.name.endswith("py2.py3-none-any.whl")
59+
and path.name not in PY2_PY3_EXCEPTIONS
60+
],
61+
indent=4,
62+
)
63+
64+
65+
if __name__ == "__main__":
66+
with NamedTemporaryDirectory() as tmpdir:
67+
(Path(__file__).parent / "wheels.json").write_text(wheels_json(tmpdir))

lite/jupyterlite-robotkernel/setup.cfg

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ classifiers =
3232
Topic :: Multimedia :: Graphics :: Presentation
3333

3434
[options]
35-
python_requires = >=3.6
35+
python_requires = >=3.7
3636
package_dir =
3737
= py_src
3838

@@ -52,4 +52,5 @@ where =
5252

5353
[options.entry_points]
5454
jupyterlite.addon.v0 =
55-
piplite = jupyterlite_robotkernel.piplite:PipliteAddon
55+
piplite = jupyterlite_robotkernel.addons.piplite:PipliteAddon
56+
robotkernel = jupyterlite_robotkernel.addons.robotkernel:RobotKernelAddon

0 commit comments

Comments
 (0)