summaryrefslogtreecommitdiff
path: root/pkgs/development/python-modules/jupyter-console/default.nix
blob: 887cd4e21e0262d3f8f4c0f2c767f856e3c1db3d (plain)
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
81
82
83
84
85
86
87
88
89
{
  lib,
  buildPythonPackage,
  fetchFromGitHub,

  # build-system
  hatchling,

  # dependencies
  ipykernel,
  ipython,
  jupyter-client,
  jupyter-core,
  prompt-toolkit,
  pygments,
  pyzmq,
  traitlets,

  # tests
  flaky,
  pexpect,
  pytestCheckHook,
}:

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

  src = fetchFromGitHub {
    owner = "jupyter";
    repo = "jupyter_console";
    tag = "v${version}";
    hash = "sha256-jdSeZCspcjEQVBpJyxVnwJ5SAq+SS1bW9kqp/F/zwCQ=";
  };

  postPatch =
    # Use wrapped executable in tests
    let
      binPath = "${placeholder "out"}/bin/jupyter-console";
    in
    ''
      substituteInPlace jupyter_console/tests/test_console.py \
        --replace-fail "'-m', 'jupyter_console', " "" \
        --replace-fail "sys.executable" "'${binPath}'"
    '';

  build-system = [ hatchling ];

  dependencies = [
    ipykernel
    ipython
    jupyter-client
    jupyter-core
    prompt-toolkit
    pygments
    pyzmq
    traitlets
  ];

  pythonImportsCheck = [ "jupyter_console" ];

  nativeCheckInputs = [
    flaky
    pexpect
    pytestCheckHook
  ];

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

  disabledTests = [
    # Flaky: pexpect.exceptions.TIMEOUT: Timeout exceeded
    "test_console_starts"
    "test_display_text"
  ];

  __darwinAllowLocalNetworking = true;

  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;
    teams = [ lib.teams.jupyter ];
  };
}