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