From e51e5a075e32ccd5ad8f607e529eed7d9b50f302 Mon Sep 17 00:00:00 2001 From: Jeremy Tuloup Date: Thu, 22 Aug 2019 17:32:48 +0200 Subject: [PATCH] Install xeus-python kernelspec for tests --- README.md | 2 -- azure-pipelines.yml | 1 - tests/run-test.py | 26 +++++++++++++++++++++++++- 3 files changed, 25 insertions(+), 4 deletions(-) diff --git a/README.md b/README.md index d41c5dfc..0064fc91 100644 --- a/README.md +++ b/README.md @@ -41,8 +41,6 @@ XEUS_LOG=1 jupyter lab --no-browser --watch ### Tests -Make sure `xeus-python` is installed and `jupyter --paths` points to where the kernel is installed. - To run the tests: ```bash diff --git a/azure-pipelines.yml b/azure-pipelines.yml index 4ea5f73e..e18f69e1 100644 --- a/azure-pipelines.yml +++ b/azure-pipelines.yml @@ -28,7 +28,6 @@ steps: - bash: | source activate jupyterlab-debugger - export JUPYTER_PATH=${CONDA_PREFIX}/share/jupyter export XEUS_LOG=1 jlpm run test displayName: Run the tests diff --git a/tests/run-test.py b/tests/run-test.py index 55e0c1c1..9e236aa8 100644 --- a/tests/run-test.py +++ b/tests/run-test.py @@ -1,14 +1,38 @@ # Copyright (c) Jupyter Development Team. # Distributed under the terms of the Modified BSD License. +import json import os +from os.path import join as pjoin + +from jupyter_core import paths from jupyterlab.tests.test_app import run_jest, JestApp HERE = os.path.realpath(os.path.dirname(__file__)) + +def _install_xpython_kernel(): + # Mimics: https://github.com/jupyterlab/jupyterlab/blob/cd2fb6ac3ecfae2bb4bcab84797932e625e9bb2f/jupyterlab/tests/test_app.py#L80-L95 + kernel_json = { + 'argv': [ + 'xpython', + '-f', '{connection_file}' + ], + 'display_name': "xpython", + 'language': 'python' + } + kernel_dir = pjoin(paths.jupyter_data_dir(), 'kernels', 'xpython') + os.makedirs(kernel_dir) + with open(pjoin(kernel_dir, 'kernel.json'), 'w') as f: + f.write(json.dumps(kernel_json)) + + if __name__ == '__main__': # xeus-python requires the xpython_debug_logs folder jest_app = JestApp.instance() - os.mkdir(os.path.join(jest_app.notebook_dir, 'xpython_debug_logs')) + os.mkdir(pjoin(jest_app.notebook_dir, 'xpython_debug_logs')) + + # install the kernel spec for xeus-python + _install_xpython_kernel() run_jest(HERE)