Skip to content

Commit 7ef1c94

Browse files
committed
Fix handling of channels from prefixes
1 parent e177999 commit 7ef1c94

File tree

2 files changed

+15
-6
lines changed

2 files changed

+15
-6
lines changed

jupyterlite_xeus/add_on.py

Lines changed: 15 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,18 @@ def update_empack_meta(self, file_path, new_data):
366364

367365
data.update(new_data)
368366

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

@@ -488,7 +498,8 @@ def pack_prefix(self, env_name, prefix):
488498
self.update_empack_meta,
489499
[
490500
out_path / EMPACK_ENV_META,
491-
{"specs": self.specs[env_name], "channels": self.channels[env_name]},
501+
env_name,
502+
{"specs": self.specs[env_name]},
492503
],
493504
),
494505
(

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)