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

More testing #143

Merged
merged 3 commits into from
Jul 25, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions jupyterlite_xeus_python/build.py
Original file line number Diff line number Diff line change
Expand Up @@ -171,8 +171,6 @@ def _install_pip_dependencies(prefix_path, dependencies, log=None):
record_csv = csv.reader(record_content.splitlines())
all_files = [_file[0] for _file in record_csv]

non_supported_files = [".so", ".a", ".dylib", ".lib", ".exe" ".dll"]

# List of tuples: (path: str, inside_site_packages: bool)
files = [(_file, not _file.startswith("../../")) for _file in all_files]

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

non_supported_files = [".so", ".a", ".dylib", ".lib", ".exe" ".dll"]

# COPY files under `prefix_path`
for _file, inside_site_packages in files:
path = Path(_file)
Expand Down
8 changes: 7 additions & 1 deletion tests/environment-1.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,10 @@ channels:
dependencies:
- numpy
- matplotlib
- ipycanvas
- pillow
- ipywidgets
- pip:
# Installing a python package that ships a lab extension under share/
- ipycanvas
# Installing a pure python package
- py2vega
8 changes: 8 additions & 0 deletions tests/environment-2.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
name: xeus-python-kernel-2
channels:
- https://repo.mamba.pm/emscripten-forge
- https://repo.mamba.pm/conda-forge
dependencies:
- pip:
# Installing NumPy with pip should fail
- numpy
40 changes: 40 additions & 0 deletions tests/test_xeus_python_env.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@
from tempfile import TemporaryDirectory
from pathlib import Path

import pytest

from jupyterlite_core.app import LiteStatusApp

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

# Checking pip packages
assert os.path.isdir(
"/tmp/xeus-python-kernel/envs/xeus-python-kernel-1/lib/python3.10"
)
assert os.path.isdir(
"/tmp/xeus-python-kernel/envs/xeus-python-kernel-1/lib/python3.10/site-packages"
)
assert os.path.isdir(
"/tmp/xeus-python-kernel/envs/xeus-python-kernel-1/lib/python3.10/site-packages/ipywidgets"
)
assert os.path.isdir(
"/tmp/xeus-python-kernel/envs/xeus-python-kernel-1/lib/python3.10/site-packages/ipycanvas"
)
assert os.path.isdir(
"/tmp/xeus-python-kernel/envs/xeus-python-kernel-1/lib/python3.10/site-packages/py2vega"
)

# Checking labextensions
assert os.path.isdir(
"/tmp/xeus-python-kernel/envs/xeus-python-kernel-1/share/jupyter/labextensions/@jupyter-widgets/jupyterlab-manager"
)
assert os.path.isdir(
"/tmp/xeus-python-kernel/envs/xeus-python-kernel-1/share/jupyter/labextensions/ipycanvas"
)

# Check empack output
assert os.path.isfile(Path(addon.cwd.name) / "empack_env_meta.json")

os.remove(Path(addon.cwd.name) / "empack_env_meta.json")


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

addon = XeusPythonEnv(manager)
addon.environment_file = "environment-2.yml"

with pytest.raises(RuntimeError, match="Cannot install binary PyPI package"):
for step in addon.post_build(manager):
pass