about summary refs log tree commit diff
path: root/nixpkgs/pkgs/development/python-modules/jupyter-console/default.nix
blob: 81276bcc411ebce6ee41d46fa94957ef9389987e (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
{ lib
, buildPythonPackage
, fetchPypi
, pythonOlder
, hatchling
, ipykernel
, exceptiongroup
, ipython
, jupyter-client
, jupyter-core
, prompt-toolkit
, pygments
, pyzmq
, traitlets
, flaky
, pexpect
, pytestCheckHook
}:

buildPythonPackage rec {
  pname = "jupyter-console";
  version = "6.6.3";
  format = "pyproject";

  disabled = pythonOlder "3.7";

  src = fetchPypi {
    pname = "jupyter_console";
    inherit version;
    hash = "sha256-VmpL8xyHrb+t8izfhG4wabWace1dpx1rpNiqrRSlNTk=";
  };

  nativeBuildInputs = [
    hatchling
  ];

  postPatch = ''
    # use wrapped executable in tests
    substituteInPlace jupyter_console/tests/test_console.py \
      --replace "args = ['-m', 'jupyter_console', '--colors=NoColor']" "args = ['--colors=NoColor']" \
      --replace "cmd = sys.executable" "cmd = '${placeholder "out"}/bin/jupyter-console'" \
      --replace "check_output([sys.executable, '-m', 'jupyter_console'," "check_output(['${placeholder "out"}/bin/jupyter-console',"
  '';

  propagatedBuildInputs = [
    ipykernel
    ipython
    jupyter-client
    jupyter-core
    prompt-toolkit
    pygments
    pyzmq
    traitlets
  ] ++ lib.optionals (pythonOlder "3.11") [
    exceptiongroup
  ];

  pythonImportsCheck = [
    "jupyter_console"
  ];

  nativeCheckInputs = [
    flaky
    pexpect
    pytestCheckHook
  ];

  preCheck = ''
    export HOME=$TMPDIR
  '';

  meta = {
    description = "Jupyter terminal console";
    mainProgram = "jupyter-console";
    homepage = "https://github.com/jupyter/jupyter_console";
    changelog = "https://github.com/jupyter/jupyter_console/releases/tag/v${version}";
    license = lib.licenses.bsd3;
    maintainers = lib.teams.jupyter.members;
  };
}