1{ lib
2, fetchurl
3, buildPythonPackage
4, pythonOlder
5, fetchPypi
6, hatchling
7, beautifulsoup4
8, bleach
9, defusedxml
10, jinja2
11, jupyter-core
12, jupyterlab-pygments
13, markupsafe
14, mistune
15, nbclient
16, packaging
17, pandocfilters
18, pygments
19, tinycss2
20, traitlets
21, importlib-metadata
22, flaky
23, ipywidgets
24, pyppeteer
25, pytestCheckHook
26}:
27
28let
29 # see https://github.com/jupyter/nbconvert/issues/1896
30 style-css = fetchurl {
31 url = "https://cdn.jupyter.org/notebook/5.4.0/style/style.min.css";
32 hash = "sha256-WGWmCfRDewRkvBIc1We2GQdOVAoFFaO4LyIvdk61HgE=";
33 };
34in buildPythonPackage rec {
35 pname = "nbconvert";
36 version = "7.8.0";
37
38 disabled = pythonOlder "3.8";
39
40 format = "pyproject";
41
42 src = fetchPypi {
43 inherit pname version;
44 hash = "sha256-9bwVoSR+FN1Bzu8MCjvHACDgFldusFeNpi8cW0+VBHk=";
45 };
46
47 # Add $out/share/jupyter to the list of paths that are used to search for
48 # various exporter templates
49 patches = [
50 ./templates.patch
51 ];
52
53 postPatch = ''
54 substituteAllInPlace ./nbconvert/exporters/templateexporter.py
55
56 mkdir -p share/templates/classic/static
57 cp ${style-css} share/templates/classic/static/style.css
58 '';
59
60 nativeBuildInputs = [
61 hatchling
62 ];
63
64 propagatedBuildInputs = [
65 beautifulsoup4
66 bleach
67 defusedxml
68 jinja2
69 jupyter-core
70 jupyterlab-pygments
71 markupsafe
72 mistune
73 nbclient
74 packaging
75 pandocfilters
76 pygments
77 tinycss2
78 traitlets
79 ] ++ lib.optionals (pythonOlder "3.10") [
80 importlib-metadata
81 ];
82
83 preCheck = ''
84 export HOME=$(mktemp -d)
85 '';
86
87 nativeCheckInputs = [
88 flaky
89 ipywidgets
90 pyppeteer
91 pytestCheckHook
92 ];
93
94 disabledTests = [
95 # Attempts network access (Failed to establish a new connection: [Errno -3] Temporary failure in name resolution)
96 "test_export"
97 "test_webpdf_with_chromium"
98 # ModuleNotFoundError: No module named 'nbconvert.tests'
99 "test_convert_full_qualified_name"
100 "test_post_processor"
101 ];
102
103 # Some of the tests use localhost networking.
104 __darwinAllowLocalNetworking = true;
105
106 meta = {
107 description = "Converting Jupyter Notebooks";
108 homepage = "https://jupyter.org/";
109 license = lib.licenses.bsd3;
110 maintainers = with lib.maintainers; [ fridh ];
111 };
112}