Skip to content

Commit 877b150

Browse files
committed
Fix handling of channels from prefixes
1 parent e177999 commit 877b150

File tree

2 files changed

+14
-6
lines changed

2 files changed

+14
-6
lines changed

jupyterlite_xeus/add_on.py

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -158,8 +158,6 @@ def post_build(self, manager):
158158
raise ValueError(f"Environment name '{env_name}' used more than once")
159159
self.prefixes[env_name] = prefix
160160
self.specs[env_name] = self.get_environment_specs(prefix)
161-
# For lack of a better way for now
162-
self.channels[env_name] = DEFAULT_CHANNELS
163161

164162
all_kernels = []
165163
for env_name, prefix in self.prefixes.items():
@@ -357,7 +355,7 @@ def copy_kernel(self, env_name, prefix, kernel_dir, kernel_wasm, kernel_js, kern
357355
],
358356
)
359357

360-
def update_empack_meta(self, file_path, new_data):
358+
def update_empack_meta(self, file_path, env_name, new_data):
361359
if file_path.exists():
362360
with open(file_path, "r", encoding="utf-8") as f:
363361
data = json.load(f)
@@ -366,6 +364,17 @@ def update_empack_meta(self, file_path, new_data):
366364

367365
data.update(new_data)
368366

367+
# Generate channels entry
368+
if not hasattr(self.channels, env_name):
369+
# Detect channels from empack_meta
370+
self.channels[env_name] = []
371+
for pkg in data["packages"]:
372+
pkg_channel = pkg.get("channel", None)
373+
if pkg_channel is not None and pkg_channel != 'PyPi' and pkg_channel not in self.channels[env_name]:
374+
self.channels[env_name].append(pkg_channel)
375+
376+
data.update({"channels", self.channels[env_name]})
377+
369378
with open(file_path, "w", encoding="utf-8") as f:
370379
json.dump(data, f, indent=2)
371380

@@ -488,7 +497,8 @@ def pack_prefix(self, env_name, prefix):
488497
self.update_empack_meta,
489498
[
490499
out_path / EMPACK_ENV_META,
491-
{"specs": self.specs[env_name], "channels": self.channels[env_name]},
500+
env_name,
501+
{"specs": self.specs[env_name]},
492502
],
493503
),
494504
(

tests/test_xeus.py

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -210,8 +210,6 @@ def test_multiple_envs():
210210
update_action_args = update_cp_env_steps["actions"][0][1]
211211
expected_tmp_path = update_action_args[0]
212212
assert expected_tmp_path.name == "empack_env_meta.json"
213-
assert isinstance(update_action_args[1], dict)
214-
assert "specs" in update_action_args[1]
215213

216214
copy_action_args = update_cp_env_steps["actions"][1][1]
217215
assert copy_action_args[1] == target_path / env_name_tmp / "empack_env_meta.json"

0 commit comments

Comments
 (0)