2022-05-18 14:49:53 +00:00
|
|
|
{ beautifulsoup4
|
|
|
|
, bleach
|
2020-04-24 23:36:52 +00:00
|
|
|
, buildPythonPackage
|
2022-05-18 14:49:53 +00:00
|
|
|
, defusedxml
|
2020-04-24 23:36:52 +00:00
|
|
|
, fetchPypi
|
2022-08-21 13:32:41 +00:00
|
|
|
, fetchpatch
|
2022-05-18 14:49:53 +00:00
|
|
|
, ipywidgets
|
2020-04-24 23:36:52 +00:00
|
|
|
, jinja2
|
2020-12-07 07:45:13 +00:00
|
|
|
, jupyterlab-pygments
|
2022-05-18 14:49:53 +00:00
|
|
|
, lib
|
|
|
|
, markupsafe
|
|
|
|
, mistune
|
|
|
|
, nbclient
|
2020-04-24 23:36:52 +00:00
|
|
|
, pandocfilters
|
2022-05-18 14:49:53 +00:00
|
|
|
, pyppeteer
|
|
|
|
, pytestCheckHook
|
2022-04-27 09:35:20 +00:00
|
|
|
, tinycss2
|
2020-04-24 23:36:52 +00:00
|
|
|
}:
|
|
|
|
|
|
|
|
buildPythonPackage rec {
|
|
|
|
pname = "nbconvert";
|
2022-09-09 14:08:57 +00:00
|
|
|
version = "6.5.3";
|
2022-04-27 09:35:20 +00:00
|
|
|
format = "setuptools";
|
2020-04-24 23:36:52 +00:00
|
|
|
|
|
|
|
src = fetchPypi {
|
|
|
|
inherit pname version;
|
2022-09-09 14:08:57 +00:00
|
|
|
hash = "sha256-EO1pPEz9PGNYPIfKXDovbth0FFEDWV84JO/Mjfy3Uiw=";
|
2020-04-24 23:36:52 +00:00
|
|
|
};
|
|
|
|
|
2021-03-23 19:22:30 +00:00
|
|
|
# Add $out/share/jupyter to the list of paths that are used to search for
|
|
|
|
# various exporter templates
|
|
|
|
patches = [
|
|
|
|
./templates.patch
|
2022-08-21 13:32:41 +00:00
|
|
|
|
|
|
|
# Use mistune 2.x
|
|
|
|
(fetchpatch {
|
|
|
|
name = "support-mistune-2.x.patch";
|
|
|
|
url = "https://github.com/jupyter/nbconvert/commit/e870d9a4a61432a65bee5466c5fa80c9ee28966e.patch";
|
|
|
|
hash = "sha256-kdOmE7BnkRy2lsNQ2OVrEXXZntJUPJ//b139kSsfKmI=";
|
|
|
|
excludes = [ "pyproject.toml" ];
|
|
|
|
})
|
2022-10-06 18:32:54 +00:00
|
|
|
|
|
|
|
# patch nbconvert/filters/markdown_mistune.py
|
|
|
|
(fetchpatch {
|
|
|
|
name = "clean-up-markdown-parsing.patch";
|
|
|
|
url = "https://github.com/jupyter/nbconvert/commit/4df1f5451c9c3e8121036dfbc7e07f0095f4d524.patch";
|
|
|
|
hash = "sha256-O+VWUaQi8UMCpE9/h/IsrenmEuJ2ac/kBkUBq7GFJTY";
|
|
|
|
})
|
|
|
|
(fetchpatch {
|
|
|
|
name = "fix-markdown-table.patch";
|
|
|
|
url = "https://github.com/jupyter/nbconvert/commit/d3900ed4527f024138dc3a8658c6a1b1dfc43c09.patch";
|
|
|
|
hash = "sha256-AFE1Zhw29JMLB0Sj17zHcOfy7VEFqLekO8NYbyMLrdI=";
|
|
|
|
})
|
2021-03-23 19:22:30 +00:00
|
|
|
];
|
|
|
|
|
|
|
|
postPatch = ''
|
|
|
|
substituteAllInPlace ./nbconvert/exporters/templateexporter.py
|
2022-08-21 13:32:41 +00:00
|
|
|
|
|
|
|
# Use mistune 2.x
|
|
|
|
substituteInPlace setup.py \
|
|
|
|
--replace "mistune>=0.8.1,<2" "mistune>=2.0.3,<3"
|
2022-10-06 18:32:54 +00:00
|
|
|
|
|
|
|
# Equivalent of the upstream patch https://github.com/jupyter/nbconvert/commit/aec39288c9a6c614d659bcaf9f5cb36634d6b37b.patch
|
|
|
|
substituteInPlace share/jupyter/nbconvert/templates/lab/base.html.j2 \
|
|
|
|
--replace "{{ output.data['image/svg+xml'] | clean_html }}" "{{ output.data['image/svg+xml'].encode(\"utf-8\") | clean_html }}"
|
2021-03-23 19:22:30 +00:00
|
|
|
'';
|
|
|
|
|
2020-04-24 23:36:52 +00:00
|
|
|
propagatedBuildInputs = [
|
2022-05-18 14:49:53 +00:00
|
|
|
beautifulsoup4
|
|
|
|
bleach
|
|
|
|
defusedxml
|
|
|
|
jinja2
|
2020-12-07 07:45:13 +00:00
|
|
|
jupyterlab-pygments
|
2022-05-18 14:49:53 +00:00
|
|
|
markupsafe
|
|
|
|
mistune
|
|
|
|
nbclient
|
|
|
|
pandocfilters
|
|
|
|
tinycss2
|
2020-04-24 23:36:52 +00:00
|
|
|
];
|
|
|
|
|
2020-12-07 07:45:13 +00:00
|
|
|
preCheck = ''
|
2022-05-18 14:49:53 +00:00
|
|
|
export HOME=$(mktemp -d)
|
2020-04-24 23:36:52 +00:00
|
|
|
'';
|
|
|
|
|
2022-05-18 14:49:53 +00:00
|
|
|
checkInputs = [
|
|
|
|
ipywidgets
|
|
|
|
pyppeteer
|
|
|
|
pytestCheckHook
|
2020-12-07 07:45:13 +00:00
|
|
|
];
|
|
|
|
|
2022-05-18 14:49:53 +00:00
|
|
|
pytestFlagsArray = [
|
|
|
|
# DeprecationWarning: Support for bleach <5 will be removed in a future version of nbconvert
|
|
|
|
"-W ignore::DeprecationWarning"
|
|
|
|
];
|
2020-12-07 07:45:13 +00:00
|
|
|
|
|
|
|
disabledTests = [
|
2022-05-18 14:49:53 +00:00
|
|
|
# Attempts network access (Failed to establish a new connection: [Errno -3] Temporary failure in name resolution)
|
2020-12-07 07:45:13 +00:00
|
|
|
"test_export"
|
2022-05-18 14:49:53 +00:00
|
|
|
"test_webpdf_with_chromium"
|
2020-12-07 07:45:13 +00:00
|
|
|
];
|
|
|
|
|
2020-04-24 23:36:52 +00:00
|
|
|
# Some of the tests use localhost networking.
|
|
|
|
__darwinAllowLocalNetworking = true;
|
|
|
|
|
|
|
|
meta = {
|
|
|
|
description = "Converting Jupyter Notebooks";
|
|
|
|
homepage = "https://jupyter.org/";
|
|
|
|
license = lib.licenses.bsd3;
|
|
|
|
maintainers = with lib.maintainers; [ fridh ];
|
|
|
|
};
|
|
|
|
}
|