From 1a53d626d9b14045cd80ac200d0004f25b298596 Mon Sep 17 00:00:00 2001 From: thomasjm Date: Mon, 13 May 2024 16:19:39 -0700 Subject: [PATCH] bash-kernel: fix and add smoke test --- .../python-modules/bash-kernel/default.nix | 20 +++++++++++--- .../python-modules/bash-kernel/test.ipynb | 26 +++++++++++++++++++ 2 files changed, 42 insertions(+), 4 deletions(-) create mode 100644 pkgs/development/python-modules/bash-kernel/test.ipynb diff --git a/pkgs/development/python-modules/bash-kernel/default.nix b/pkgs/development/python-modules/bash-kernel/default.nix index c3ab6083ba1d..57f28860fca9 100644 --- a/pkgs/development/python-modules/bash-kernel/default.nix +++ b/pkgs/development/python-modules/bash-kernel/default.nix @@ -6,7 +6,7 @@ , ipykernel , python , pexpect -, bash +, bashInteractive , substituteAll }: @@ -24,7 +24,7 @@ buildPythonPackage rec { patches = [ (substituteAll { src = ./bash-path.patch; - bash = lib.getExe bash; + bash = lib.getExe bashInteractive; }) ]; @@ -45,8 +45,20 @@ buildPythonPackage rec { ${python.pythonOnBuildForHost.interpreter} -m bash_kernel.install --prefix $out ''; - # no tests - doCheck = false; + checkPhase = '' + runHook preCheck + + # Create a JUPYTER_PATH with the kernelspec + export JUPYTER_PATH=$(mktemp -d) + mkdir -p $JUPYTER_PATH/kernels/bash + echo '{ "language": "bash", "argv": [ "${python}/bin/python", "-m", "bash_kernel", "-f", "{connection_file}" ] }' > $JUPYTER_PATH/kernels/bash/kernel.json + + # Evaluate a test notebook with papermill + cd $(mktemp -d) + ${python.withPackages (ps: [ps.papermill])}/bin/papermill --kernel bash ${./test.ipynb} out.ipynb + + runHook postCheck + ''; meta = with lib; { description = "Bash Kernel for Jupyter"; diff --git a/pkgs/development/python-modules/bash-kernel/test.ipynb b/pkgs/development/python-modules/bash-kernel/test.ipynb new file mode 100644 index 000000000000..4d061381b96d --- /dev/null +++ b/pkgs/development/python-modules/bash-kernel/test.ipynb @@ -0,0 +1,26 @@ +{ + "cells": [ + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "echo hi" + ] + } + ], + "metadata": { + "kernel_info": { + "display_name": "Unknown", + "name": "bash" + }, + "language_info": { + "file_extension": ".ipynb", + "name": "bash", + "version": "5.0" + } + }, + "nbformat": 4, + "nbformat_minor": 2 +}