Skip to content

Commit

Permalink
Fix mount points (#59)
Browse files Browse the repository at this point in the history
* Fix mount points

* Add mount points test

* Update test

* Fixed missing env

* Fix empack usage

* Fix tests

* Fix test
  • Loading branch information
martinRenou authored Feb 5, 2024
1 parent 075cd58 commit 4ea46b4
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 1 deletion.
3 changes: 2 additions & 1 deletion jupyterlite_xeus/add_on.py
Original file line number Diff line number Diff line change
Expand Up @@ -293,6 +293,7 @@ def pack_prefix(self, kernel_dir):
)

host_path, mount_path = mount.split(":")
host_path = Path(host_path)
mount_path = Path(mount_path)

if not mount_path.is_absolute():
Expand All @@ -315,7 +316,7 @@ def pack_prefix(self, kernel_dir):
elif host_path.is_file():
pack_file(
host_file=host_path,
mount_file=mount_path,
mount_dir=mount_path,
outname=outname,
outdir=out_path,
)
Expand Down
27 changes: 27 additions & 0 deletions tests/test_xeus.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
import os
from tempfile import TemporaryDirectory
from pathlib import Path
import tarfile

import pytest

Expand Down Expand Up @@ -77,3 +78,29 @@ def test_python_env_from_file_2():
with pytest.raises(RuntimeError, match="Cannot install binary PyPI package"):
for step in addon.post_build(manager):
pass


def test_mount_point():
app = LiteStatusApp(log_level="DEBUG")
app.initialize()
manager = app.lite_manager

addon = XeusAddon(manager)
addon.environment_file = "environment-1.yml"
addon.mounts = [
f"{(Path(__file__).parent / "environment-1.yml").resolve()}:/share",
f"{(Path(__file__).parent / "test_package").resolve()}:/share/test_package",
]

for step in addon.post_build(manager):
pass

outpath = Path(addon.cwd.name) / "packed_env"

with tarfile.open(outpath / "mount_0.tar.gz", "r") as fobj:
names = fobj.getnames()
assert "share/environment-1.yml" in names

with tarfile.open(outpath / "mount_1.tar.gz", "r") as fobj:
names = fobj.getnames()
assert "share/test_package/environment-3.yml" in names

0 comments on commit 4ea46b4

Please sign in to comment.