about summary refs log tree commit diff
path: root/pkgs/development/python-modules/jupyterhub/default.nix
blob: 543564b606eaed7ff9bed772827a99f2bdc89c87 (plain) (blame)
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
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
{
  lib,
  stdenv,
  alembic,
  async-generator,
  beautifulsoup4,
  buildPythonPackage,
  certipy,
  configurable-http-proxy,
  cryptography,
  fetchFromGitHub,
  fetchNpmDeps,
  idna,
  importlib-metadata,
  jinja2,
  jsonschema,
  jupyter-events,
  jupyterlab,
  mock,
  nbclassic,
  nodejs,
  npmHooks,
  oauthlib,
  packaging,
  pamela,
  playwright,
  prometheus-client,
  pydantic,
  pytest-asyncio,
  pytestCheckHook,
  python-dateutil,
  pythonOlder,
  requests,
  requests-mock,
  setuptools,
  setuptools-scm,
  sqlalchemy,
  tornado,
  traitlets,
  virtualenv,
}:

buildPythonPackage rec {
  pname = "jupyterhub";
  version = "5.0.0";
  pyproject = true;

  disabled = pythonOlder "3.8";

  src = fetchFromGitHub {
    owner = "jupyterhub";
    repo = "jupyterhub";
    rev = "refs/tags/${version}";
    hash = "sha256-YGDbyWe3JSXbluOX6qyLqzl92Z/f5sD/5TPc2LR7W80=";
  };

  npmDeps = fetchNpmDeps {
    inherit src;
    hash = "sha256-7G/Y2yaMi9cyf20/o8rLXKIE6SdZ74HSWJ3Wfypl4Cc=";
  };

  postPatch = ''
    substituteInPlace jupyterhub/proxy.py --replace-fail \
      "'configurable-http-proxy'" \
      "'${configurable-http-proxy}/bin/configurable-http-proxy'"

    substituteInPlace jupyterhub/tests/test_proxy.py --replace-fail \
      "'configurable-http-proxy'" \
      "'${configurable-http-proxy}/bin/configurable-http-proxy'"
  '';

  nativeBuildInputs = [
    nodejs
    npmHooks.npmConfigHook
  ];

  build-system = [
    setuptools
    setuptools-scm
  ];

  dependencies =
    [
      alembic
      certipy
      idna
      jinja2
      jupyter-events
      oauthlib
      packaging
      pamela
      prometheus-client
      pydantic
      python-dateutil
      requests
      sqlalchemy
      tornado
      traitlets
    ]
    ++ lib.optionals (pythonOlder "3.10") [
      async-generator
      importlib-metadata
    ];

  nativeCheckInputs = [
    beautifulsoup4
    cryptography
    jsonschema
    jupyterlab
    mock
    nbclassic
    playwright
    # require pytest-asyncio<0.23
    # https://github.com/jupyterhub/jupyterhub/pull/4663
    (pytest-asyncio.overrideAttrs (
      final: prev: {
        version = "0.21.2";
        src = fetchFromGitHub {
          inherit (prev.src) owner repo;
          rev = "refs/tags/v${final.version}";
          hash = "sha256-AVVvdo/CDF9IU6l779sLc7wKz5h3kzMttdDNTPLYxtQ=";
        };
      }
    ))
    pytestCheckHook
    requests-mock
    virtualenv
  ];

  preCheck = ''
    export PATH=$out/bin:$PATH;
  '';

  disabledTests = [
    # Tries to install older versions through pip
    "test_upgrade"
    # Testcase fails to find requests import
    "test_external_service"
    # Attempts to do TLS connection
    "test_connection_notebook_wrong_certs"
    # AttributeError: 'coroutine' object...
    "test_valid_events"
    "test_invalid_events"
    "test_user_group_roles"
  ];

  disabledTestPaths = [
    # Not testing with a running instance
    # AttributeError: 'coroutine' object has no attribute 'db'
    "docs/test_docs.py"
    "jupyterhub/tests/browser/test_browser.py"
    "jupyterhub/tests/test_api.py"
    "jupyterhub/tests/test_auth_expiry.py"
    "jupyterhub/tests/test_auth.py"
    "jupyterhub/tests/test_metrics.py"
    "jupyterhub/tests/test_named_servers.py"
    "jupyterhub/tests/test_orm.py"
    "jupyterhub/tests/test_pages.py"
    "jupyterhub/tests/test_proxy.py"
    "jupyterhub/tests/test_scopes.py"
    "jupyterhub/tests/test_services_auth.py"
    "jupyterhub/tests/test_singleuser.py"
    "jupyterhub/tests/test_spawner.py"
    "jupyterhub/tests/test_user.py"
  ];

  meta = with lib; {
    description = "Serves multiple Jupyter notebook instances";
    homepage = "https://github.com/jupyterhub/jupyterhub";
    changelog = "https://github.com/jupyterhub/jupyterhub/blob/${version}/docs/source/reference/changelog.md";
    license = licenses.bsd3;
    maintainers = teams.jupyter.members;
    # darwin: E   OSError: dlopen(/nix/store/43zml0mlr17r5jsagxr00xxx91hz9lky-openpam-20170430/lib/libpam.so, 6): image not found
    broken = stdenv.isDarwin;
  };
}