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