Unverified Commit 403a2406 authored by Martin Weinelt's avatar Martin Weinelt
Browse files

python311Packages.bash-kernel: fix build

Substitute the bash path more carefully, as not all quoted bash strings
are meant to be paths.
parent 8c87a8ab
Loading
Loading
Loading
Loading
+22 −0
Original line number Diff line number Diff line
diff --git a/bash_kernel/kernel.py b/bash_kernel/kernel.py
index 0496f1e..bd13c4f 100644
--- a/bash_kernel/kernel.py
+++ b/bash_kernel/kernel.py
@@ -88,7 +88,7 @@ class BashKernel(Kernel):
     @property
     def banner(self):
         if self._banner is None:
-            self._banner = check_output(['bash', '--version']).decode('utf-8')
+            self._banner = check_output(['@bash@', '--version']).decode('utf-8')
         return self._banner
 
     language_info = {'name': 'bash',
@@ -116,7 +116,7 @@ class BashKernel(Kernel):
             # source code there for comments and context for
             # understanding the code here.
             bashrc = os.path.join(os.path.dirname(pexpect.__file__), 'bashrc.sh')
-            child = pexpect.spawn("bash", ['--rcfile', bashrc], echo=False,
+            child = pexpect.spawn("@bash@", ['--rcfile', bashrc], echo=False,
                                   encoding='utf-8', codec_errors='replace')
             # Following comment stolen from upstream's REPLWrap:
             # If the user runs 'env', the value of PS1 will be in the output. To avoid
+16 −18
Original line number Diff line number Diff line
@@ -4,43 +4,38 @@
, fetchpatch
, flit-core
, ipykernel
, isPy27
, python
, pexpect
, bash
, substituteAll
}:

buildPythonPackage rec {
  pname = "bash-kernel";
  version = "0.9.1";
  format = "flit";
  disabled = isPy27;
  pyproject = true;

  src = fetchPypi {
    pname = "bash_kernel";
    inherit version;
    sha256 = "sha256-AYPVPjYP+baEcQUqmiiagWIXMlFrA04njpcgtdFaFis=";
    hash = "sha256-AYPVPjYP+baEcQUqmiiagWIXMlFrA04njpcgtdFaFis=";
  };

  patches = [
    (fetchpatch {
      url = "https://patch-diff.githubusercontent.com/raw/takluyver/bash_kernel/pull/69.diff";
      sha256 = "1qd7qjjmcph4dk6j0bl31h2fdmfiyyazvrc9xqqj8y21ki2sl33j";
    (substituteAll {
      src = ./bash-path.patch;
      bash = lib.getExe bash;
    })
  ];

  postPatch = ''
    substituteInPlace bash_kernel/kernel.py \
      --replace "'bash'" "'${bash}/bin/bash'" \
      --replace "\"bash\"" "'${bash}/bin/bash'"
  '';

  nativeBuildInputs = [ flit-core ];

  propagatedBuildInputs = [ ipykernel pexpect ];
  nativeBuildInputs = [
    flit-core
  ];

  # no tests
  doCheck = false;
  propagatedBuildInputs = [
    ipykernel
    pexpect
  ];

  preBuild = ''
    export HOME=$TMPDIR
@@ -50,6 +45,9 @@ buildPythonPackage rec {
    ${python.pythonOnBuildForHost.interpreter} -m bash_kernel.install --prefix $out
  '';

  # no tests
  doCheck = false;

  meta = with lib; {
    description = "Bash Kernel for Jupyter";
    homepage = "https://github.com/takluyver/bash_kernel";