1{
2 lib,
3 buildPythonPackage,
4 fetchFromGitHub,
5 nodejs,
6 yarn-berry_3,
7 hatch-jupyter-builder,
8 hatchling,
9 async-lru,
10 httpx,
11 importlib-metadata,
12 ipykernel,
13 jinja2,
14 jupyter-core,
15 jupyter-lsp,
16 jupyter-server,
17 jupyterlab-server,
18 notebook-shim,
19 packaging,
20 setuptools,
21 tomli,
22 tornado,
23 traitlets,
24 pythonOlder,
25}:
26
27buildPythonPackage rec {
28 pname = "jupyterlab";
29 version = "4.4.5";
30 pyproject = true;
31
32 src = fetchFromGitHub {
33 owner = "jupyterlab";
34 repo = "jupyterlab";
35 tag = "v${version}";
36 hash = "sha256-Joc8gtUJS8J2SLJqBV3f4bzmOje1grdgIMUkcwl9K44=";
37 };
38
39 nativeBuildInputs = [
40 nodejs
41 yarn-berry_3.yarnBerryConfigHook
42 ];
43
44 preConfigure = ''
45 pushd jupyterlab/staging
46 '';
47
48 offlineCache = yarn-berry_3.fetchYarnBerryDeps {
49 inherit src;
50 sourceRoot = "${src.name}/jupyterlab/staging";
51 hash = "sha256-EwR1gVrEy7QV8DnJBPx1AlbWY10FFngpLXdAIKn1HI0=";
52 };
53
54 preBuild = ''
55 popd
56 '';
57
58 build-system = [
59 hatch-jupyter-builder
60 hatchling
61 ];
62
63 dependencies = [
64 async-lru
65 httpx
66 ipykernel
67 jinja2
68 jupyter-core
69 jupyter-lsp
70 jupyter-server
71 jupyterlab-server
72 notebook-shim
73 packaging
74 setuptools
75 tornado
76 traitlets
77 ]
78 ++ lib.optionals (pythonOlder "3.11") [ tomli ]
79 ++ lib.optionals (pythonOlder "3.10") [ importlib-metadata ];
80
81 makeWrapperArgs = [
82 "--set"
83 "JUPYTERLAB_DIR"
84 "$out/share/jupyter/lab"
85 ];
86
87 # Depends on npm
88 doCheck = false;
89
90 pythonImportsCheck = [ "jupyterlab" ];
91
92 meta = with lib; {
93 changelog = "https://github.com/jupyterlab/jupyterlab/blob/${src.tag}/CHANGELOG.md";
94 description = "Jupyter lab environment notebook server extension";
95 license = licenses.bsd3;
96 homepage = "https://jupyter.org/";
97 teams = [ lib.teams.jupyter ];
98 mainProgram = "jupyter-lab";
99 };
100}