summaryrefslogtreecommitdiff
path: root/dev-python/nbconvert
diff options
context:
space:
mode:
authorV3n3RiX <venerix@redcorelinux.org>2020-06-13 10:39:22 +0100
committerV3n3RiX <venerix@redcorelinux.org>2020-06-13 10:39:22 +0100
commit9452a6e87b6c2c70513bc47a2470bf9f1168920e (patch)
tree8ac67e26b45f34d71c5aab3621813b100a0d5f00 /dev-python/nbconvert
parentf516638b7fe9592837389826a6152a7e1b251c54 (diff)
gentoo resync : 13.06.2020
Diffstat (limited to 'dev-python/nbconvert')
-rw-r--r--dev-python/nbconvert/Manifest6
-rw-r--r--dev-python/nbconvert/files/nbconvert-5.6.1-inkscape-1.patch159
-rw-r--r--dev-python/nbconvert/files/nbconvert-5.6.1-py39.patch27
-rw-r--r--dev-python/nbconvert/metadata.xml8
-rw-r--r--dev-python/nbconvert/nbconvert-5.6.1.ebuild70
5 files changed, 265 insertions, 5 deletions
diff --git a/dev-python/nbconvert/Manifest b/dev-python/nbconvert/Manifest
index 96c99eca9994..0df0127104c1 100644
--- a/dev-python/nbconvert/Manifest
+++ b/dev-python/nbconvert/Manifest
@@ -1,5 +1,9 @@
+AUX nbconvert-5.6.1-inkscape-1.patch 6526 BLAKE2B f3baf2b80321e63a261ad281c81818d95bde8f719382cb8a4b2a2d4511e7c102658fcfec9f86067bb0c296caf9b164842986bb664ca7dc9184206e2a76b20221 SHA512 880385a0c42e185f01521ee26fe9d859c99c6ba3477e5b71d292cc0f6b4998a2b9c4ec0dcff5a30ca3fce261769c3481ec320b6c0ca0e0f46dd493e72b7267b3
+AUX nbconvert-5.6.1-py39.patch 1199 BLAKE2B 7ddcc42c81e9d86007142f3f5c6ce9a88b1ead4400c1e65f3c816e97fbc707eea3bd71a5bf64e6266678c1935a678321230a30d92522f6188f19d3273028647a SHA512 f9590d808cadea8a2c95079dbfe4aac4339ecddcb204e7b57a8c62f4cfd0545d17961b01599ec3f4ce52d772175be43ad441a0ebc56d52e6332fda11110f5463
DIST nbconvert-5.2.1.tar.gz 510937 BLAKE2B aade38372775b032287f420ea4d335ad949a80afc0df63859db5a4f520bbaa22fcd17bf4318b05fa042fe94c2f65890aa2ed2365206abe8cdfb357817b056ac7 SHA512 c71c95d6c7bda4b55afad792d108d48c27857e060531dc8ec262673971c258ff9480821bd78ee5cbdbb19f107d5f8d19a49eac88819f20a09b450c26681335fa
DIST nbconvert-5.5.0.tar.gz 583216 BLAKE2B fce42d68fcfb5439607fcb0fa8475462e929a5ddb9d160985956a85e09c7561e1a966be633b4d59e6afe873fb7f1300997c97bdbf4690290401d14bbe351c47a SHA512 4d10cbd6d6854d7672537cfb2e0a79854be1ed4adf96f805b1a0ec0dde0e149ed465a26ceec8d7c325f7011c30ff646054585b65d1e83540622e25a96cc207bf
+DIST nbconvert-5.6.1.tar.gz 703233 BLAKE2B e75d558aee6c66fe8e7455ecf22dbbcd2a0698380ffec80eff15aea6c70bc853daa9ab2fd1d114453bd5dfe7e75617afb9f5c1075704bfadbb59fef34bca88a9 SHA512 0c68adcb9f28ead9ec058fc2e02a9a1e6f65818709c99f7a006a59a7562b5f5ee74afe5287e41568c35542898dc1b43c4543d2386cc05a721b3f99d5cc789435
EBUILD nbconvert-5.2.1.ebuild 2119 BLAKE2B a08f56ff246159f89f487e7d4f671d55d64c1e5f0e1fb1ade29d211c84774731f166f0005f25958c560a49f95ff3fe6ea836c556455669e77c4b7c8aee623b8c SHA512 320938050a6f3a3bf7ec2430e04c76443e2410981ce7622d7dca8deaacd2e4e33a8c1b081d3a354e3deb64df333b16fc3e81177a53bc9a343601e09fb35b876e
EBUILD nbconvert-5.5.0.ebuild 2103 BLAKE2B 45671ea644d557087eae45329e1dc1c869ff2f9ba347de47c5cb1d50497d3af39a6d4f927d75447e3f86988137a25e24edff1bc845b5a97957d5cdf245cf638e SHA512 4ced8cead706d1341d4edacf163f78223855096a48245d619792d80c80ea67bdb43b1fa8f2073d2a124ff4cc5cb72aab7a7df5bf8eb4c34eed0a398197d2f8f1
-MISC metadata.xml 534 BLAKE2B 011d472737f4929968f44c9ab3beaaff8938a4550096b8abc2bc7dc72acfbde4eb745527a6f9ce3d1188bdc09f11607db2d9515a89b53793a88259513cf0056c SHA512 8a00c8bf80e0e9477a531b70d9f2fbba1fc8c8bc09246a6a2263d94170d294e65e6a20f8ab84974e97b346c96b22e2ca648ef5021fc9316a023532ca34bd07d8
+EBUILD nbconvert-5.6.1.ebuild 1776 BLAKE2B 73e15c1584cbf8b935319cdbfe4e5362d686eb4c752ffbf6d4dc43b21fff9930dadfe2e3772ddb2624e9fcb68357d35c7ad5700984091a5e610fd53ea34167a4 SHA512 bb202323abdc76426cf5b5c754909451925b1002f1968a9fde7571b76ea9176bf79ee53d5f4358d5cc1cee6c52d42ea3858bb258445865904f55ac058c51b5ea
+MISC metadata.xml 501 BLAKE2B a99beea687357c74454ec232dea268f95e9b775c882b1ea29e196ec124e829b9749d5fbc4c585f88e46c16bc868d57a757b6f9043545bc5905e0dc86c7f0b44a SHA512 d0735c82e490860baf8ae76f78058a9981dc345d7f5b06d54bbdfd1741a7619f68dbca3386f7bba12b58df46a1125384935de85dff3ad883fb11781df933a866
diff --git a/dev-python/nbconvert/files/nbconvert-5.6.1-inkscape-1.patch b/dev-python/nbconvert/files/nbconvert-5.6.1-inkscape-1.patch
new file mode 100644
index 000000000000..1f997a3c3a32
--- /dev/null
+++ b/dev-python/nbconvert/files/nbconvert-5.6.1-inkscape-1.patch
@@ -0,0 +1,159 @@
+diff --git a/nbconvert/preprocessors/svg2pdf.py b/nbconvert/preprocessors/svg2pdf.py
+index aff14d9f..de51f3b8 100644
+--- a/nbconvert/preprocessors/svg2pdf.py
++++ b/nbconvert/preprocessors/svg2pdf.py
+@@ -1,4 +1,4 @@
+-"""Module containing a preprocessor that converts outputs in the notebook from
++"""Module containing a preprocessor that converts outputs in the notebook from
+ one format to another.
+ """
+
+@@ -17,11 +17,7 @@ from traitlets import Unicode, default
+
+ from .convertfigures import ConvertFiguresPreprocessor
+
+-if sys.version_info >= (3,3):
+- from shutil import which
+- get_inkscape_path = which('inkscape')
+-else:
+- get_inkscape_path = None
++from shutil import which
+
+
+ INKSCAPE_APP = '/Applications/Inkscape.app/Contents/Resources/bin/inkscape'
+@@ -46,26 +42,49 @@ class SVG2PDFPreprocessor(ConvertFiguresPreprocessor):
+ def _to_format_default(self):
+ return 'application/pdf'
+
++ inkscape_version = Unicode(
++ help="""The version of inkscpae being used.
++
++ This affects how the conversion command is run.
++ """
++ ).tag(config=True)
++
++ @default('inkscape_version')
++ def _inkscape_version_default(self):
++ p = subprocess.Popen([self.inkscape, '--version'],
++ stdout=subprocess.PIPE,
++ stderr=subprocess.PIPE)
++ output, _ = p.communicate()
++ if p.returncode != 0:
++ raise RuntimeError("Unable to find inkscape executable --version")
++ return output.decode('utf-8').split(' ')[1]
++
+ command = Unicode(
+ help="""The command to use for converting SVG to PDF
+-
++
+ This string is a template, which will be formatted with the keys
+ to_filename and from_filename.
+-
++
+ The conversion call must read the SVG from {from_filename},
+ and write a PDF to {to_filename}.
+ """).tag(config=True)
+
+ @default('command')
+ def _command_default(self):
+- return self.inkscape + \
+- ' --without-gui --export-pdf="{to_filename}" "{from_filename}"'
+-
++ major_verison = self.inkscape_version.split('.')[0]
++ export_option = ' --export-filename' if int(major_verison) > 0 else ' --export-pdf'
++ gui_option = '' if int(major_verison) > 0 else ' --without-gui'
++
++ return '{inkscape}{gui_option}{export_option}='.format(
++ inkscape=self.inkscape, export_option=export_option, gui_option=gui_option
++ ) + '"{to_filename}" "{from_filename}"'
++
+ inkscape = Unicode(help="The path to Inkscape, if necessary").tag(config=True)
+ @default('inkscape')
+ def _inkscape_default(self):
+- if get_inkscape_path is not None:
+- return get_inkscape_path
++ inkscape_path = which('inkscape')
++ if inkscape_path is not None:
++ return inkscape_path
+ if sys.platform == "darwin":
+ if os.path.isfile(INKSCAPE_APP):
+ return INKSCAPE_APP
+@@ -85,22 +104,22 @@ class SVG2PDFPreprocessor(ConvertFiguresPreprocessor):
+ Convert a single SVG figure to PDF. Returns converted data.
+ """
+
+- #Work in a temporary directory
++ # Work in a temporary directory
+ with TemporaryDirectory() as tmpdir:
+-
+- #Write fig to temp file
++
++ # Write fig to temp file
+ input_filename = os.path.join(tmpdir, 'figure.svg')
+ # SVG data is unicode text
+ with io.open(input_filename, 'w', encoding='utf8') as f:
+ f.write(cast_unicode_py2(data))
+
+- #Call conversion application
++ # Call conversion application
+ output_filename = os.path.join(tmpdir, 'figure.pdf')
+- shell = self.command.format(from_filename=input_filename,
++ shell = self.command.format(from_filename=input_filename,
+ to_filename=output_filename)
+- subprocess.call(shell, shell=True) #Shell=True okay since input is trusted.
++ subprocess.call(shell, shell=True) # Shell=True okay since input is trusted.
+
+- #Read output from drive
++ # Read output from drive
+ # return value expects a filename
+ if os.path.isfile(output_filename):
+ with open(output_filename, 'rb') as f:
+diff --git a/nbconvert/preprocessors/tests/test_svg2pdf.py b/nbconvert/preprocessors/tests/test_svg2pdf.py
+index c42222c7..d9ccec8c 100644
+--- a/nbconvert/preprocessors/tests/test_svg2pdf.py
++++ b/nbconvert/preprocessors/tests/test_svg2pdf.py
+@@ -4,6 +4,7 @@
+ # Distributed under the terms of the Modified BSD License.
+
+ from nbformat import v4 as nbformat
++from unittest.mock import patch, Mock
+
+ from .base import PreprocessorTestsBase
+ from ..svg2pdf import SVG2PDFPreprocessor
+@@ -51,9 +52,9 @@ class Testsvg2pdf(PreprocessorTestsBase):
+ return nbformat.new_notebook(cells=cells)
+
+
+- def build_preprocessor(self):
++ def build_preprocessor(self, **kwargs):
+ """Make an instance of a preprocessor"""
+- preprocessor = SVG2PDFPreprocessor()
++ preprocessor = SVG2PDFPreprocessor(**kwargs)
+ preprocessor.enabled = True
+ return preprocessor
+
+@@ -71,4 +72,23 @@ class Testsvg2pdf(PreprocessorTestsBase):
+ preprocessor = self.build_preprocessor()
+ nb, res = preprocessor(nb, res)
+ self.assertIn('application/pdf', nb.cells[0].outputs[0].data)
+-
++
++ @patch('subprocess.Popen')
++ def test_inkscape_version_default(self, mock_popen):
++ mock_popen().communicate.return_value = (b'Inkscape 0.92.3 (2405546, 2018-03-11)', b'')
++ mock_popen().returncode = 0
++
++ preprocessor = self.build_preprocessor()
++ self.assertEquals(preprocessor.inkscape_version, '0.92.3')
++
++ def test_inkscape_pre_v1_command(self):
++ preprocessor = self.build_preprocessor(inkscape_version='0.92.3')
++ self.assertEquals(preprocessor.command, '0.92.3')
++
++ def test_inkscape_pre_v1_command(self):
++ preprocessor = self.build_preprocessor(inkscape='fake-inkscape', inkscape_version='0.92.3')
++ self.assertEquals(preprocessor.command, 'fake-inkscape --without-gui --export-pdf="{to_filename}" "{from_filename}"')
++
++ def test_inkscape_v1_command(self):
++ preprocessor = self.build_preprocessor(inkscape='fake-inkscape', inkscape_version='1.0beta2')
++ self.assertEquals(preprocessor.command, 'fake-inkscape --export-filename="{to_filename}" "{from_filename}"')
diff --git a/dev-python/nbconvert/files/nbconvert-5.6.1-py39.patch b/dev-python/nbconvert/files/nbconvert-5.6.1-py39.patch
new file mode 100644
index 000000000000..822c32753f83
--- /dev/null
+++ b/dev-python/nbconvert/files/nbconvert-5.6.1-py39.patch
@@ -0,0 +1,27 @@
+diff --git a/nbconvert/filters/strings.py b/nbconvert/filters/strings.py
+index 2673d661..9ae82a13 100755
+--- a/nbconvert/filters/strings.py
++++ b/nbconvert/filters/strings.py
+@@ -19,8 +19,8 @@ except ImportError:
+ from urllib2 import quote # Py 2
+
+ # defusedxml does safe(r) parsing of untrusted XML data
+-from defusedxml import cElementTree as ElementTree
+-from xml.etree.cElementTree import Element
++from defusedxml import ElementTree
++from xml.etree.ElementTree import Element
+
+ from ipython_genutils import py3compat
+
+diff --git a/nbconvert/preprocessors/svg2pdf.py b/nbconvert/preprocessors/svg2pdf.py
+index aff14d9f..b689b1bc 100644
+--- a/nbconvert/preprocessors/svg2pdf.py
++++ b/nbconvert/preprocessors/svg2pdf.py
+@@ -105,6 +105,6 @@ class SVG2PDFPreprocessor(ConvertFiguresPreprocessor):
+ if os.path.isfile(output_filename):
+ with open(output_filename, 'rb') as f:
+ # PDF is a nb supported binary, data type, so base64 encode.
+- return base64.encodestring(f.read())
++ return base64.encodebytes(f.read())
+ else:
+ raise TypeError("Inkscape svg to pdf conversion failed")
diff --git a/dev-python/nbconvert/metadata.xml b/dev-python/nbconvert/metadata.xml
index 71b87397b7e0..d47832d4ed86 100644
--- a/dev-python/nbconvert/metadata.xml
+++ b/dev-python/nbconvert/metadata.xml
@@ -5,10 +5,10 @@
<email>sci@gentoo.org</email>
<name>Gentoo Science Project</name>
</maintainer>
- <longdescription>
- Jupyter NBConvert converts Jupyter notebooks to various other
- formats via Jinja templates.
- </longdescription>
+ <maintainer type="project">
+ <email>python@gentoo.org</email>
+ <name>Python</name>
+ </maintainer>
<upstream>
<remote-id type="pypi">nbconvert</remote-id>
<remote-id type="github">jupyter/nbconvert</remote-id>
diff --git a/dev-python/nbconvert/nbconvert-5.6.1.ebuild b/dev-python/nbconvert/nbconvert-5.6.1.ebuild
new file mode 100644
index 000000000000..594d35db111d
--- /dev/null
+++ b/dev-python/nbconvert/nbconvert-5.6.1.ebuild
@@ -0,0 +1,70 @@
+# Copyright 1999-2020 Gentoo Authors
+# Distributed under the terms of the GNU General Public License v2
+
+EAPI=7
+
+PYTHON_COMPAT=( python3_{6..9} )
+
+inherit distutils-r1
+
+DESCRIPTION="Converting Jupyter Notebooks"
+HOMEPAGE="https://nbconvert.readthedocs.io/"
+SRC_URI="mirror://pypi/${PN:0:1}/${PN}/${P}.tar.gz"
+
+LICENSE="BSD"
+SLOT="0"
+KEYWORDS="~amd64 ~arm64 ~x86 ~amd64-linux ~x86-linux"
+IUSE="test"
+
+RDEPEND="
+ dev-python/bleach[${PYTHON_USEDEP}]
+ dev-python/defusedxml[${PYTHON_USEDEP}]
+ >=dev-python/entrypoints-0.2.2[${PYTHON_USEDEP}]
+ dev-python/jinja[${PYTHON_USEDEP}]
+ dev-python/jupyter_core[${PYTHON_USEDEP}]
+ >=dev-python/mistune-0.7.4[${PYTHON_USEDEP}]
+ dev-python/nbformat[${PYTHON_USEDEP}]
+ >=dev-python/pandocfilters-1.4.1[${PYTHON_USEDEP}]
+ dev-python/pygments[${PYTHON_USEDEP}]
+ >=dev-python/traitlets-4.2.1[${PYTHON_USEDEP}]
+ dev-python/testpath[${PYTHON_USEDEP}]
+ www-servers/tornado[${PYTHON_USEDEP}]
+"
+BDEPEND="
+ test? (
+ dev-python/pebble[${PYTHON_USEDEP}]
+ dev-python/ipykernel[${PYTHON_USEDEP}]
+ dev-python/ipywidgets[${PYTHON_USEDEP}]
+ >=dev-python/jupyter_client-4.2[${PYTHON_USEDEP}]
+ media-gfx/inkscape
+ )
+"
+
+distutils_enable_tests pytest
+
+PATCHES=(
+ "${FILESDIR}"/${P}-inkscape-1.patch
+ "${FILESDIR}"/${P}-py39.patch
+)
+
+src_prepare() {
+ # assumes old inkscape output?
+ sed -i -e '/SVG\.ipynb/d' \
+ nbconvert/preprocessors/tests/test_execute.py || die
+
+ distutils-r1_src_prepare
+}
+
+python_test() {
+ distutils_install_for_testing bdist_egg
+ cd "${TEST_DIR}"/lib || die
+ pytest -vv --pyargs nbconvert || die
+}
+
+pkg_postinst() {
+ if ! has_version app-text/pandoc ; then
+ einfo "Pandoc is required for converting to formats other than Python,"
+ einfo "HTML, and Markdown. If you need this functionality, install"
+ einfo "app-text/pandoc."
+ fi
+}