Skip to content

Commit dffb813

Browse files
authored
use a list for piplite_urls (#161)
1 parent 0f9673d commit dffb813

File tree

2 files changed

+34
-15
lines changed

2 files changed

+34
-15
lines changed

jupyterlite_pyodide_kernel/addons/piplite.py

Lines changed: 14 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
import urllib.parse
77
from hashlib import md5, sha256
88
from pathlib import Path
9-
from typing import Tuple as _Tuple
9+
from typing import List as _List
1010

1111
import doit.tools
1212
from jupyterlite_core.constants import (
@@ -16,8 +16,7 @@
1616
LAB_EXTENSIONS,
1717
UTF8,
1818
)
19-
from jupyterlite_core.trait_types import TypedTuple
20-
from traitlets import Unicode
19+
from traitlets import List
2120

2221
from ._base import _BaseAddon
2322

@@ -37,8 +36,7 @@ class PipliteAddon(_BaseAddon):
3736
__all__ = ["post_init", "build", "post_build", "check"]
3837

3938
# traits
40-
piplite_urls: _Tuple[str] = TypedTuple(
41-
Unicode(),
39+
piplite_urls: _List[str] = List(
4240
help="Local paths or URLs of piplite-compatible wheels to copy and index",
4341
).tag(config=True)
4442

@@ -84,8 +82,18 @@ def settings_schema(self):
8482

8583
def post_init(self, manager):
8684
"""handle downloading of wheels"""
85+
task_names = []
8786
for path_or_url in self.piplite_urls:
88-
yield from self.resolve_one_wheel(path_or_url)
87+
for task in self.resolve_one_wheel(path_or_url):
88+
if task["name"] in task_names:
89+
self.log.warning(
90+
"[piplite] skipping-already scheduled wheel task %s: %s",
91+
task["name"],
92+
task["targets"],
93+
)
94+
continue
95+
yield task
96+
task_names += [task["name"]]
8997

9098
def build(self, manager):
9199
"""yield a doit task to copy each local wheel into the output_dir"""

jupyterlite_pyodide_kernel/tests/test_piplite.py

Lines changed: 20 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -24,12 +24,17 @@
2424
from .conftest import WHEELS, PYODIDE_KERNEL_EXTENSION
2525

2626

27-
def has_wheel_after_build(an_empty_lite_dir, script_runner):
27+
def has_wheel_after_build(an_empty_lite_dir, script_runner, cli_args=None):
2828
"""run a build, expecting the fixture wheel to be there"""
29-
build = script_runner.run(["jupyter", "lite", "build"], cwd=str(an_empty_lite_dir))
29+
cli_args = cli_args or []
30+
build = script_runner.run(
31+
["jupyter", "lite", "build", *cli_args], cwd=str(an_empty_lite_dir)
32+
)
3033
assert build.success
3134

32-
check = script_runner.run(["jupyter", "lite", "check"], cwd=str(an_empty_lite_dir))
35+
check = script_runner.run(
36+
["jupyter", "lite", "check", *cli_args], cwd=str(an_empty_lite_dir)
37+
)
3338
assert check.success
3439

3540
output = an_empty_lite_dir / "_output"
@@ -47,12 +52,13 @@ def has_wheel_after_build(an_empty_lite_dir, script_runner):
4752
assert WHEELS[0].name in wheel_index_text, wheel_index_text
4853

4954

55+
@mark.parametrize("by_cli", [0, 1, 2])
5056
@mark.parametrize(
5157
"remote,folder",
5258
[[True, False], [False, False], [False, True]],
5359
)
5460
def test_piplite_urls(
55-
an_empty_lite_dir, script_runner, remote, folder, a_fixture_server
61+
by_cli, remote, folder, an_empty_lite_dir, script_runner, a_fixture_server
5662
):
5763
"""can we include a single wheel?"""
5864
ext = WHEELS[0]
@@ -75,15 +81,20 @@ def test_piplite_urls(
7581
"federated_extensions": [
7682
str(PYODIDE_KERNEL_EXTENSION),
7783
],
78-
},
79-
"PipliteAddon": {
80-
"piplite_urls": piplite_urls,
81-
},
84+
}
8285
}
8386

87+
if by_cli == 0:
88+
cli_args = []
89+
config.update(PipliteAddon={"piplite_urls": piplite_urls})
90+
elif by_cli == 1:
91+
cli_args = ["--piplite-wheels", piplite_urls[0]]
92+
elif by_cli == 2:
93+
cli_args = ["--piplite-wheels", piplite_urls[0], "--piplite-wheels", "."]
94+
8495
(an_empty_lite_dir / "jupyter_lite_config.json").write_text(json.dumps(config))
8596

86-
has_wheel_after_build(an_empty_lite_dir, script_runner)
97+
has_wheel_after_build(an_empty_lite_dir, script_runner, cli_args)
8798

8899

89100
def test_lite_dir_wheel(an_empty_lite_dir, script_runner):

0 commit comments

Comments
 (0)