|
22 | 22 |
|
23 | 23 |
|
24 | 24 | class PipliteAddon(BasePipliteAddon): |
25 | | - |
26 | 25 | def post_init(self, manager): |
27 | 26 | """update the root jupyter-lite.json with pipliteUrls""" |
28 | 27 | 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 | + ): |
30 | 34 | # Install robotkernel |
31 | 35 | self.output_wheels.mkdir(parents=True, exist_ok=True) |
32 | 36 | subprocess.check_call( |
33 | 37 | [PY, "-m", "pip", "wheel", "--prefer-binary", "robotkernel >= 1.6a2"], |
34 | | - cwd=self.output_wheels |
| 38 | + cwd=self.output_wheels, |
35 | 39 | ) |
36 | 40 | # Remove wheels that conflict with pyolite shims |
37 | 41 | 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 | + ) |
39 | 45 | # 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 | + ) |
41 | 82 |
|
42 | 83 | def patch_jupyterlite_json(self, jupyterlite_json, whl_index, whl_metas, pkg_jsons): |
43 | 84 | """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 | + ) |
45 | 88 | config = json.loads(jupyterlite_json.read_text(**UTF8)) |
46 | 89 | old_urls = ( |
47 | 90 | config.setdefault(JUPYTER_CONFIG_DATA, {}) |
|
0 commit comments