2017-11-25 15:20:31 +00:00
|
|
|
{ lib
|
|
|
|
, buildPythonPackage
|
|
|
|
, fetchPypi
|
|
|
|
, fetchpatch
|
2023-09-10 00:04:22 +02:00
|
|
|
, flit-core
|
2017-11-25 15:20:31 +00:00
|
|
|
, ipykernel
|
2017-11-28 21:39:36 +00:00
|
|
|
, python
|
2017-11-25 15:20:31 +00:00
|
|
|
, pexpect
|
2024-05-13 16:19:39 -07:00
|
|
|
, bashInteractive
|
2023-11-10 13:19:08 +01:00
|
|
|
, substituteAll
|
2017-11-25 15:20:31 +00:00
|
|
|
}:
|
2017-12-25 19:42:43 +01:00
|
|
|
|
2017-11-25 15:20:31 +00:00
|
|
|
buildPythonPackage rec {
|
2023-11-10 13:17:10 +01:00
|
|
|
pname = "bash-kernel";
|
2023-12-07 07:19:11 +00:00
|
|
|
version = "0.9.3";
|
2023-11-10 13:19:08 +01:00
|
|
|
pyproject = true;
|
2017-11-25 15:20:31 +00:00
|
|
|
|
|
|
|
src = fetchPypi {
|
2023-11-10 13:17:10 +01:00
|
|
|
pname = "bash_kernel";
|
|
|
|
inherit version;
|
2023-12-07 07:19:11 +00:00
|
|
|
hash = "sha256-n3oDgRyn2csfv/gIIjfPBFC5cYIlL9C4BYeha2XmbVg=";
|
2017-11-25 15:20:31 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
patches = [
|
2023-11-10 13:19:08 +01:00
|
|
|
(substituteAll {
|
|
|
|
src = ./bash-path.patch;
|
2024-05-13 16:19:39 -07:00
|
|
|
bash = lib.getExe bashInteractive;
|
2017-11-25 15:20:31 +00:00
|
|
|
})
|
|
|
|
];
|
|
|
|
|
2023-11-10 13:19:08 +01:00
|
|
|
nativeBuildInputs = [
|
|
|
|
flit-core
|
|
|
|
];
|
2017-11-25 15:20:31 +00:00
|
|
|
|
2023-11-10 13:19:08 +01:00
|
|
|
propagatedBuildInputs = [
|
|
|
|
ipykernel
|
|
|
|
pexpect
|
|
|
|
];
|
2017-11-25 15:20:31 +00:00
|
|
|
|
|
|
|
preBuild = ''
|
2017-12-25 19:42:43 +01:00
|
|
|
export HOME=$TMPDIR
|
2017-11-25 15:20:31 +00:00
|
|
|
'';
|
|
|
|
|
|
|
|
postInstall = ''
|
2023-11-05 17:38:24 -08:00
|
|
|
${python.pythonOnBuildForHost.interpreter} -m bash_kernel.install --prefix $out
|
2017-11-25 15:20:31 +00:00
|
|
|
'';
|
|
|
|
|
2024-05-13 16:19:39 -07:00
|
|
|
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
|
|
|
|
'';
|
2023-11-10 13:19:08 +01:00
|
|
|
|
2023-03-05 10:50:43 +01:00
|
|
|
meta = with lib; {
|
2017-11-25 15:20:31 +00:00
|
|
|
description = "Bash Kernel for Jupyter";
|
|
|
|
homepage = "https://github.com/takluyver/bash_kernel";
|
2023-03-05 10:50:43 +01:00
|
|
|
changelog = "https://github.com/takluyver/bash_kernel/releases/tag/${version}";
|
|
|
|
license = licenses.bsd3;
|
|
|
|
maintainers = with maintainers; [ zimbatm ];
|
2017-11-25 15:20:31 +00:00
|
|
|
};
|
|
|
|
}
|