-
Notifications
You must be signed in to change notification settings - Fork 16
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Bring back jupyterlite-xeus-python tests (#39)
- Loading branch information
1 parent
21f50dd
commit 36d47f8
Showing
12 changed files
with
255 additions
and
18 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
name: xeus-python-kernel-1 | ||
channels: | ||
- https://repo.mamba.pm/emscripten-forge | ||
- conda-forge | ||
dependencies: | ||
- xeus-python | ||
- xeus-lua | ||
- numpy | ||
- matplotlib | ||
- pillow | ||
- ipywidgets | ||
- pip: | ||
# Installing a python package that ships a lab extension under share/ | ||
- ipycanvas | ||
# Installing a pure python package | ||
- py2vega |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
name: xeus-python-kernel-2 | ||
channels: | ||
- https://repo.mamba.pm/emscripten-forge | ||
- conda-forge | ||
dependencies: | ||
- xeus-python | ||
- pip: | ||
# Installing NumPy with pip should fail | ||
- numpy |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
name: xeus-python-kernel-3 | ||
channels: | ||
- https://repo.mamba.pm/emscripten-forge | ||
- conda-forge | ||
dependencies: | ||
- xeus-python | ||
- numpy | ||
- pip: | ||
- . |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
[project] | ||
name = "test-package" | ||
version = "0.1.0" |
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
print("Hey") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,79 @@ | ||
"""Test creating Python envs for jupyterlite-xeus-python.""" | ||
|
||
import os | ||
from tempfile import TemporaryDirectory | ||
from pathlib import Path | ||
|
||
import pytest | ||
|
||
from jupyterlite_core.app import LiteStatusApp | ||
|
||
from jupyterlite_xeus.add_on import XeusAddon | ||
|
||
|
||
def test_python_env_from_file_1(): | ||
app = LiteStatusApp(log_level="DEBUG") | ||
app.initialize() | ||
manager = app.lite_manager | ||
|
||
addon = XeusAddon(manager) | ||
addon.environment_file = "environment-1.yml" | ||
|
||
for step in addon.post_build(manager): | ||
pass | ||
|
||
# Check env | ||
assert os.path.isdir(addon.prefix) | ||
|
||
assert os.path.isfile(Path(addon.prefix) / "bin/xpython.js") | ||
assert os.path.isfile(Path(addon.prefix) / "bin/xpython.wasm") | ||
|
||
assert os.path.isfile(Path(addon.prefix) / "bin/xlua.js") | ||
assert os.path.isfile(Path(addon.prefix) / "bin/xlua.wasm") | ||
|
||
# Checking pip packages | ||
assert os.path.isdir(Path(addon.prefix) / "lib/python3.11") | ||
assert os.path.isdir(Path(addon.prefix) / "lib/python3.11/site-packages") | ||
assert os.path.isdir(Path(addon.prefix) / "lib/python3.11/site-packages/ipywidgets") | ||
assert os.path.isdir(Path(addon.prefix) / "lib/python3.11/site-packages/ipycanvas") | ||
assert os.path.isdir(Path(addon.prefix) / "lib/python3.11/site-packages/py2vega") | ||
|
||
# Checking labextensions | ||
assert os.path.isdir( | ||
Path(addon.prefix) | ||
/ "share/jupyter/labextensions/@jupyter-widgets/jupyterlab-manager" | ||
) | ||
assert os.path.isdir(Path(addon.prefix) / "share/jupyter/labextensions/ipycanvas") | ||
|
||
|
||
def test_python_env_from_file_3(): | ||
app = LiteStatusApp(log_level="DEBUG") | ||
app.initialize() | ||
manager = app.lite_manager | ||
|
||
addon = XeusAddon(manager) | ||
addon.environment_file = "test_package/environment-3.yml" | ||
|
||
for step in addon.post_build(manager): | ||
pass | ||
|
||
# Test | ||
assert os.path.isdir( | ||
Path(addon.prefix) / "lib/python3.11/site-packages/test_package" | ||
) | ||
assert os.path.isfile( | ||
Path(addon.prefix) / "lib/python3.11/site-packages/test_package/hey.py" | ||
) | ||
|
||
|
||
def test_python_env_from_file_2(): | ||
app = LiteStatusApp(log_level="DEBUG") | ||
app.initialize() | ||
manager = app.lite_manager | ||
|
||
addon = XeusAddon(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 |