1{
2 lib,
3 buildPythonPackage,
4 fetchFromGitHub,
5 fetchNpmDeps,
6 configurable-http-proxy,
7
8 # nativeBuildInputs
9 nodejs,
10 npmHooks,
11
12 # build-system
13 setuptools,
14 setuptools-scm,
15
16 # dependencies
17 alembic,
18 certipy,
19 idna,
20 jinja2,
21 jupyter-events,
22 oauthlib,
23 packaging,
24 pamela,
25 prometheus-client,
26 pydantic,
27 python-dateutil,
28 requests,
29 sqlalchemy,
30 tornado,
31 traitlets,
32 pythonOlder,
33 async-generator,
34 importlib-metadata,
35
36 # tests
37 addBinToPathHook,
38 beautifulsoup4,
39 cryptography,
40 jsonschema,
41 jupyterlab,
42 mock,
43 nbclassic,
44 playwright,
45 pytest-asyncio,
46 pytestCheckHook,
47 requests-mock,
48 versionCheckHook,
49 virtualenv,
50}:
51
52buildPythonPackage rec {
53 pname = "jupyterhub";
54 version = "5.3.0";
55 pyproject = true;
56
57 src = fetchFromGitHub {
58 owner = "jupyterhub";
59 repo = "jupyterhub";
60 rev = "refs/tags/${version}";
61 hash = "sha256-FAVNS7GPvglFuSTDTAUtZ6ZzY4yH+eo34KhUQ4C3b4I=";
62 };
63
64 npmDeps = fetchNpmDeps {
65 inherit src;
66 hash = "sha256-1ffF3i/IgE+J+0M+z6bzwZ9H8u0EYcYXTiBD9Jj7HdQ=";
67 };
68
69 postPatch = ''
70 substituteInPlace jupyterhub/proxy.py \
71 --replace-fail \
72 "'configurable-http-proxy'" \
73 "'${lib.getExe configurable-http-proxy}'"
74
75 substituteInPlace jupyterhub/tests/test_proxy.py \
76 --replace-fail \
77 "'configurable-http-proxy'" \
78 "'${lib.getExe configurable-http-proxy}'"
79 '';
80
81 nativeBuildInputs = [
82 nodejs
83 npmHooks.npmConfigHook
84 ];
85
86 build-system = [
87 setuptools
88 setuptools-scm
89 ];
90
91 dependencies =
92 [
93 alembic
94 certipy
95 idna
96 jinja2
97 jupyter-events
98 oauthlib
99 packaging
100 pamela
101 prometheus-client
102 pydantic
103 python-dateutil
104 requests
105 sqlalchemy
106 tornado
107 traitlets
108 ]
109 ++ lib.optionals (pythonOlder "3.10") [
110 async-generator
111 importlib-metadata
112 ];
113
114 pythonImportsCheck = [ "jupyterhub" ];
115
116 nativeCheckInputs = [
117 addBinToPathHook
118 beautifulsoup4
119 cryptography
120 jsonschema
121 jupyterlab
122 mock
123 nbclassic
124 playwright
125 # require pytest-asyncio<0.23
126 # https://github.com/jupyterhub/jupyterhub/pull/4663
127 (pytest-asyncio.overrideAttrs (
128 final: prev: {
129 version = "0.21.2";
130 src = fetchFromGitHub {
131 inherit (prev.src) owner repo;
132 rev = "refs/tags/v${final.version}";
133 hash = "sha256-AVVvdo/CDF9IU6l779sLc7wKz5h3kzMttdDNTPLYxtQ=";
134 };
135 }
136 ))
137 pytestCheckHook
138 requests-mock
139 versionCheckHook
140 virtualenv
141 ];
142 versionCheckProgramArg = "--version";
143
144 disabledTests = [
145 # Tries to install older versions through pip
146 "test_upgrade"
147 # Testcase fails to find requests import
148 "test_external_service"
149 # Attempts to do TLS connection
150 "test_connection_notebook_wrong_certs"
151 # AttributeError: 'coroutine' object...
152 "test_valid_events"
153 "test_invalid_events"
154 "test_user_group_roles"
155 ];
156
157 disabledTestPaths = [
158 # Not testing with a running instance
159 # AttributeError: 'coroutine' object has no attribute 'db'
160 "docs/test_docs.py"
161 "jupyterhub/tests/browser/test_browser.py"
162 "jupyterhub/tests/test_api.py"
163 "jupyterhub/tests/test_auth_expiry.py"
164 "jupyterhub/tests/test_auth.py"
165 "jupyterhub/tests/test_metrics.py"
166 "jupyterhub/tests/test_named_servers.py"
167 "jupyterhub/tests/test_orm.py"
168 "jupyterhub/tests/test_pages.py"
169 "jupyterhub/tests/test_proxy.py"
170 "jupyterhub/tests/test_scopes.py"
171 "jupyterhub/tests/test_services_auth.py"
172 "jupyterhub/tests/test_singleuser.py"
173 "jupyterhub/tests/test_spawner.py"
174 "jupyterhub/tests/test_user.py"
175 ];
176
177 meta = {
178 description = "Serves multiple Jupyter notebook instances";
179 homepage = "https://github.com/jupyterhub/jupyterhub";
180 changelog = "https://github.com/jupyterhub/jupyterhub/blob/${version}/docs/source/reference/changelog.md";
181 license = lib.licenses.bsd3;
182 teams = [ lib.teams.jupyter ];
183 badPlatforms = [
184 # E OSError: dlopen(/nix/store/43zml0mlr17r5jsagxr00xxx91hz9lky-openpam-20170430/lib/libpam.so, 6): image not found
185 lib.systems.inspect.patterns.isDarwin
186 ];
187 };
188}