1{
2 lib,
3 pythonOlder,
4 stdenv,
5 buildPythonPackage,
6 fetchPypi,
7 hatch-jupyter-builder,
8 hatchling,
9 pytestCheckHook,
10 pytest-console-scripts,
11 pytest-jupyter,
12 pytest-timeout,
13 argon2-cffi,
14 jinja2,
15 tornado,
16 pyzmq,
17 ipykernel,
18 traitlets,
19 jupyter-core,
20 jupyter-client,
21 jupyter-events,
22 jupyter-server-terminals,
23 nbformat,
24 nbconvert,
25 packaging,
26 send2trash,
27 terminado,
28 prometheus-client,
29 anyio,
30 websocket-client,
31 overrides,
32 requests,
33 flaky,
34}:
35
36buildPythonPackage rec {
37 pname = "jupyter-server";
38 version = "2.16.0";
39 pyproject = true;
40 disabled = pythonOlder "3.9";
41
42 src = fetchPypi {
43 pname = "jupyter_server";
44 inherit version;
45 hash = "sha256-ZdS0T98ty73+CqGs5KhC1Kr3RqK3sWgTTVqu01Yht/Y=";
46 };
47
48 build-system = [
49 hatch-jupyter-builder
50 hatchling
51 ];
52
53 dependencies = [
54 argon2-cffi
55 jinja2
56 tornado
57 pyzmq
58 traitlets
59 jupyter-core
60 jupyter-client
61 jupyter-events
62 jupyter-server-terminals
63 nbformat
64 nbconvert
65 packaging
66 send2trash
67 terminado
68 prometheus-client
69 anyio
70 websocket-client
71 overrides
72 ];
73
74 # https://github.com/NixOS/nixpkgs/issues/299427
75 stripExclude = lib.optionals stdenv.hostPlatform.isDarwin [ "favicon.ico" ];
76
77 pythonImportsCheck = [ "jupyter_server" ];
78
79 nativeCheckInputs = [
80 ipykernel
81 pytestCheckHook
82 pytest-console-scripts
83 pytest-jupyter
84 pytest-timeout
85 requests
86 flaky
87 ];
88
89 pytestFlags = [
90 "-Wignore::DeprecationWarning"
91 # 19 failures on python 3.13:
92 # ResourceWarning: unclosed database in <sqlite3.Connection object at 0x7ffff2a0cc70>
93 # TODO: Can probably be removed at the next update
94 "-Wignore::pytest.PytestUnraisableExceptionWarning"
95 ];
96
97 preCheck = ''
98 export HOME=$(mktemp -d)
99 export PATH=$out/bin:$PATH
100 '';
101
102 disabledTests = [
103 "test_cull_idle"
104 "test_server_extension_list"
105 "test_subscribe_websocket"
106 # test is presumable broken in sandbox
107 "test_authorized_requests"
108 ]
109 ++ lib.optionals stdenv.hostPlatform.isDarwin [
110 # attempts to use trashcan, build env doesn't allow this
111 "test_delete"
112 # Insufficient access privileges for operation
113 "test_regression_is_hidden"
114 ]
115 ++ lib.optionals stdenv.hostPlatform.isLinux [
116 # Failed: DID NOT RAISE <class 'tornado.web.HTTPError'>
117 "test_copy_big_dir"
118 ]
119 ++ lib.optionals (stdenv.hostPlatform.isDarwin && stdenv.hostPlatform.isx86_64) [
120 # TypeError: the JSON object must be str, bytes or bytearray, not NoneType
121 "test_terminal_create_with_cwd"
122 ];
123
124 disabledTestPaths = [
125 "tests/services/kernels/test_api.py"
126 "tests/services/sessions/test_api.py"
127 # nbconvert failed: `relax_add_props` kwargs of validate has been
128 # deprecated for security reasons, and will be removed soon.
129 "tests/nbconvert/test_handlers.py"
130 ];
131
132 __darwinAllowLocalNetworking = true;
133
134 meta = {
135 changelog = "https://github.com/jupyter-server/jupyter_server/blob/v${version}/CHANGELOG.md";
136 description = "Backend—i.e. core services, APIs, and REST endpoints—to Jupyter web applications";
137 mainProgram = "jupyter-server";
138 homepage = "https://github.com/jupyter-server/jupyter_server";
139 license = lib.licenses.bsdOriginal;
140 teams = [ lib.teams.jupyter ];
141 };
142}