Skip to content
This repository was archived by the owner on Feb 14, 2024. It is now read-only.

Commit ba9891f

Browse files
authored
More testing (#143)
* More testing * Add test for incompatible environment file * Move var creation
1 parent 155bd3e commit ba9891f

File tree

4 files changed

+57
-3
lines changed

4 files changed

+57
-3
lines changed

jupyterlite_xeus_python/build.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -171,8 +171,6 @@ def _install_pip_dependencies(prefix_path, dependencies, log=None):
171171
record_csv = csv.reader(record_content.splitlines())
172172
all_files = [_file[0] for _file in record_csv]
173173

174-
non_supported_files = [".so", ".a", ".dylib", ".lib", ".exe" ".dll"]
175-
176174
# List of tuples: (path: str, inside_site_packages: bool)
177175
files = [(_file, not _file.startswith("../../")) for _file in all_files]
178176

@@ -183,6 +181,8 @@ def _install_pip_dependencies(prefix_path, dependencies, log=None):
183181
with open(package_dist_info / "RECORD", "w") as record:
184182
record.write(fixed_record_data)
185183

184+
non_supported_files = [".so", ".a", ".dylib", ".lib", ".exe" ".dll"]
185+
186186
# COPY files under `prefix_path`
187187
for _file, inside_site_packages in files:
188188
path = Path(_file)

tests/environment-1.yml

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,4 +5,10 @@ channels:
55
dependencies:
66
- numpy
77
- matplotlib
8-
- ipycanvas
8+
- pillow
9+
- ipywidgets
10+
- pip:
11+
# Installing a python package that ships a lab extension under share/
12+
- ipycanvas
13+
# Installing a pure python package
14+
- py2vega

tests/environment-2.yml

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
name: xeus-python-kernel-2
2+
channels:
3+
- https://repo.mamba.pm/emscripten-forge
4+
- https://repo.mamba.pm/conda-forge
5+
dependencies:
6+
- pip:
7+
# Installing NumPy with pip should fail
8+
- numpy

tests/test_xeus_python_env.py

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@
44
from tempfile import TemporaryDirectory
55
from pathlib import Path
66

7+
import pytest
8+
79
from jupyterlite_core.app import LiteStatusApp
810

911
from jupyterlite_xeus_python.env_build_addon import XeusPythonEnv
@@ -57,7 +59,45 @@ def test_python_env_from_file_1():
5759
"/tmp/xeus-python-kernel/envs/xeus-python-kernel-1/bin/xpython_wasm.wasm"
5860
)
5961

62+
# Checking pip packages
63+
assert os.path.isdir(
64+
"/tmp/xeus-python-kernel/envs/xeus-python-kernel-1/lib/python3.10"
65+
)
66+
assert os.path.isdir(
67+
"/tmp/xeus-python-kernel/envs/xeus-python-kernel-1/lib/python3.10/site-packages"
68+
)
69+
assert os.path.isdir(
70+
"/tmp/xeus-python-kernel/envs/xeus-python-kernel-1/lib/python3.10/site-packages/ipywidgets"
71+
)
72+
assert os.path.isdir(
73+
"/tmp/xeus-python-kernel/envs/xeus-python-kernel-1/lib/python3.10/site-packages/ipycanvas"
74+
)
75+
assert os.path.isdir(
76+
"/tmp/xeus-python-kernel/envs/xeus-python-kernel-1/lib/python3.10/site-packages/py2vega"
77+
)
78+
79+
# Checking labextensions
80+
assert os.path.isdir(
81+
"/tmp/xeus-python-kernel/envs/xeus-python-kernel-1/share/jupyter/labextensions/@jupyter-widgets/jupyterlab-manager"
82+
)
83+
assert os.path.isdir(
84+
"/tmp/xeus-python-kernel/envs/xeus-python-kernel-1/share/jupyter/labextensions/ipycanvas"
85+
)
86+
6087
# Check empack output
6188
assert os.path.isfile(Path(addon.cwd.name) / "empack_env_meta.json")
6289

6390
os.remove(Path(addon.cwd.name) / "empack_env_meta.json")
91+
92+
93+
def test_python_env_from_file_2():
94+
app = LiteStatusApp(log_level="DEBUG")
95+
app.initialize()
96+
manager = app.lite_manager
97+
98+
addon = XeusPythonEnv(manager)
99+
addon.environment_file = "environment-2.yml"
100+
101+
with pytest.raises(RuntimeError, match="Cannot install binary PyPI package"):
102+
for step in addon.post_build(manager):
103+
pass

0 commit comments

Comments
 (0)