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 alembic
93 certipy
94 idna
95 jinja2
96 jupyter-events
97 oauthlib
98 packaging
99 pamela
100 prometheus-client
101 pydantic
102 python-dateutil
103 requests
104 sqlalchemy
105 tornado
106 traitlets
107 ]
108 ++ lib.optionals (pythonOlder "3.10") [
109 async-generator
110 importlib-metadata
111 ];
112
113 pythonImportsCheck = [ "jupyterhub" ];
114
115 nativeCheckInputs = [
116 addBinToPathHook
117 beautifulsoup4
118 cryptography
119 jsonschema
120 jupyterlab
121 mock
122 nbclassic
123 playwright
124 # require pytest-asyncio<0.23
125 # https://github.com/jupyterhub/jupyterhub/pull/4663
126 (pytest-asyncio.overrideAttrs (
127 final: prev: {
128 version = "0.21.2";
129 src = fetchFromGitHub {
130 inherit (prev.src) owner repo;
131 rev = "refs/tags/v${final.version}";
132 hash = "sha256-AVVvdo/CDF9IU6l779sLc7wKz5h3kzMttdDNTPLYxtQ=";
133 };
134 }
135 ))
136 pytestCheckHook
137 requests-mock
138 versionCheckHook
139 virtualenv
140 ];
141 versionCheckProgramArg = "--version";
142
143 disabledTests = [
144 # Tries to install older versions through pip
145 "test_upgrade"
146 # Testcase fails to find requests import
147 "test_external_service"
148 # Attempts to do TLS connection
149 "test_connection_notebook_wrong_certs"
150 # AttributeError: 'coroutine' object...
151 "test_valid_events"
152 "test_invalid_events"
153 "test_user_group_roles"
154 ];
155
156 disabledTestPaths = [
157 # Not testing with a running instance
158 # AttributeError: 'coroutine' object has no attribute 'db'
159 "docs/test_docs.py"
160 "jupyterhub/tests/browser/test_browser.py"
161 "jupyterhub/tests/test_api.py"
162 "jupyterhub/tests/test_auth_expiry.py"
163 "jupyterhub/tests/test_auth.py"
164 "jupyterhub/tests/test_metrics.py"
165 "jupyterhub/tests/test_named_servers.py"
166 "jupyterhub/tests/test_orm.py"
167 "jupyterhub/tests/test_pages.py"
168 "jupyterhub/tests/test_proxy.py"
169 "jupyterhub/tests/test_scopes.py"
170 "jupyterhub/tests/test_services_auth.py"
171 "jupyterhub/tests/test_singleuser.py"
172 "jupyterhub/tests/test_spawner.py"
173 "jupyterhub/tests/test_user.py"
174 ];
175
176 meta = {
177 description = "Serves multiple Jupyter notebook instances";
178 homepage = "https://github.com/jupyterhub/jupyterhub";
179 changelog = "https://github.com/jupyterhub/jupyterhub/blob/${version}/docs/source/reference/changelog.md";
180 license = lib.licenses.bsd3;
181 teams = [ lib.teams.jupyter ];
182 badPlatforms = [
183 # E OSError: dlopen(/nix/store/43zml0mlr17r5jsagxr00xxx91hz9lky-openpam-20170430/lib/libpam.so, 6): image not found
184 lib.systems.inspect.patterns.isDarwin
185 ];
186 };
187}