public inbox for gentoo-commits@lists.gentoo.org
 help / color / mirror / Atom feed
* [gentoo-commits] repo/gentoo:master commit in: dev-python/nbconvert/files/, dev-python/nbconvert/
@ 2020-06-10  6:03 Michał Górny
  0 siblings, 0 replies; 2+ messages in thread
From: Michał Górny @ 2020-06-10  6:03 UTC (permalink / raw
  To: gentoo-commits

commit:     f98144fc46bc93d25acb728dfc2c91fad61b7382
Author:     Michał Górny <mgorny <AT> gentoo <DOT> org>
AuthorDate: Wed Jun 10 05:57:50 2020 +0000
Commit:     Michał Górny <mgorny <AT> gentoo <DOT> org>
CommitDate: Wed Jun 10 05:57:50 2020 +0000
URL:        https://gitweb.gentoo.org/repo/gentoo.git/commit/?id=f98144fc

dev-python/nbconvert: Backport inkscape-1+ fix

Thanks to sam_c for finding out.

Signed-off-by: Michał Górny <mgorny <AT> gentoo.org>

 .../files/nbconvert-5.6.1-inkscape-1.patch         | 40 ++++++++++++++++++++++
 dev-python/nbconvert/nbconvert-5.6.1.ebuild        |  4 +++
 2 files changed, 44 insertions(+)

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 00000000000..06e8d06c935
--- /dev/null
+++ b/dev-python/nbconvert/files/nbconvert-5.6.1-inkscape-1.patch
@@ -0,0 +1,40 @@
+From 61757ce936ab37855a5289d31ef59ef898061bcf Mon Sep 17 00:00:00 2001
+From: =?UTF-8?q?Miro=20Hron=C4=8Dok?= <miro@hroncok.cz>
+Date: Sun, 3 May 2020 15:41:07 +0200
+Subject: [PATCH] Fix CLI options given to Inkscape 1.0rc1+
+
+Fixes https://github.com/jupyter/nbconvert/issues/1246
+---
+ nbconvert/preprocessors/svg2pdf.py            | 7 ++++---
+ nbconvert/preprocessors/tests/test_svg2pdf.py | 2 +-
+ 2 files changed, 5 insertions(+), 4 deletions(-)
+
+diff --git a/nbconvert/preprocessors/svg2pdf.py b/nbconvert/preprocessors/svg2pdf.py
+index d4c48af6..af6a7dea 100644
+--- a/nbconvert/preprocessors/svg2pdf.py
++++ b/nbconvert/preprocessors/svg2pdf.py
+@@ -76,10 +76,11 @@ def _inkscape_version_default(self):
+     @default('command')
+     def _command_default(self):
+         major_verison = self.inkscape_version.split('.')[0]
+-        export_option = '--export-file' if int(major_verison) > 0 else '--export-pdf'
++        export_option = ' --export-filename' if int(major_verison) > 0 else ' --export-pdf'
++        gui_option = '' if int(major_verison) > 0 else ' --without-gui'
+ 
+-        return '{inkscape} --without-gui {export_option}='.format(
+-            inkscape=self.inkscape, export_option=export_option
++        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)
+diff --git a/nbconvert/preprocessors/tests/test_svg2pdf.py b/nbconvert/preprocessors/tests/test_svg2pdf.py
+index 5e13b282..d9ccec8c 100644
+--- a/nbconvert/preprocessors/tests/test_svg2pdf.py
++++ b/nbconvert/preprocessors/tests/test_svg2pdf.py
+@@ -91,4 +91,4 @@ def test_inkscape_pre_v1_command(self):
+ 
+     def test_inkscape_v1_command(self):
+         preprocessor = self.build_preprocessor(inkscape='fake-inkscape', inkscape_version='1.0beta2')
+-        self.assertEquals(preprocessor.command, 'fake-inkscape --without-gui --export-file="{to_filename}" "{from_filename}"')
++        self.assertEquals(preprocessor.command, 'fake-inkscape --export-filename="{to_filename}" "{from_filename}"')

diff --git a/dev-python/nbconvert/nbconvert-5.6.1.ebuild b/dev-python/nbconvert/nbconvert-5.6.1.ebuild
index 64b91a7af87..c2041fa935c 100644
--- a/dev-python/nbconvert/nbconvert-5.6.1.ebuild
+++ b/dev-python/nbconvert/nbconvert-5.6.1.ebuild
@@ -44,6 +44,10 @@ distutils_enable_sphinx docs \
 	dev-python/{ipython,jupyter_client,nbsphinx,sphinx_rtd_theme}
 distutils_enable_tests pytest
 
+PATCHES=(
+	"${FILESDIR}"/${P}-inkscape-1.patch
+)
+
 python_test() {
 	distutils_install_for_testing bdist_egg
 	cd "${TEST_DIR}"/lib || die


^ permalink raw reply related	[flat|nested] 2+ messages in thread

* [gentoo-commits] repo/gentoo:master commit in: dev-python/nbconvert/files/, dev-python/nbconvert/
@ 2021-01-05 23:26 Michał Górny
  0 siblings, 0 replies; 2+ messages in thread
From: Michał Górny @ 2021-01-05 23:26 UTC (permalink / raw
  To: gentoo-commits

commit:     fc7b6914b0aa80f0cb13a256a25936702a245813
Author:     Michał Górny <mgorny <AT> gentoo <DOT> org>
AuthorDate: Tue Jan  5 23:24:51 2021 +0000
Commit:     Michał Górny <mgorny <AT> gentoo <DOT> org>
CommitDate: Tue Jan  5 23:26:40 2021 +0000
URL:        https://gitweb.gentoo.org/repo/gentoo.git/commit/?id=fc7b6914

dev-python/nbconvert: Remove old

Signed-off-by: Michał Górny <mgorny <AT> gentoo.org>

 dev-python/nbconvert/Manifest                      |   1 -
 .../files/nbconvert-5.6.1-inkscape-1.patch         | 159 ---------------------
 .../nbconvert/files/nbconvert-5.6.1-py39.patch     |  27 ----
 dev-python/nbconvert/nbconvert-5.6.1.ebuild        |  70 ---------
 4 files changed, 257 deletions(-)

diff --git a/dev-python/nbconvert/Manifest b/dev-python/nbconvert/Manifest
index 5c7f2522953..88f54fefe08 100644
--- a/dev-python/nbconvert/Manifest
+++ b/dev-python/nbconvert/Manifest
@@ -1,2 +1 @@
-DIST nbconvert-5.6.1.tar.gz 703233 BLAKE2B e75d558aee6c66fe8e7455ecf22dbbcd2a0698380ffec80eff15aea6c70bc853daa9ab2fd1d114453bd5dfe7e75617afb9f5c1075704bfadbb59fef34bca88a9 SHA512 0c68adcb9f28ead9ec058fc2e02a9a1e6f65818709c99f7a006a59a7562b5f5ee74afe5287e41568c35542898dc1b43c4543d2386cc05a721b3f99d5cc789435
 DIST nbconvert-6.0.7.tar.gz 896833 BLAKE2B 1b5b39144509aa9f61dc1e9675b112d69ed2e2f9859f3ce7ccfac517d89fff0010062c03ded1c3db571c84dd8d4f8ba12e4851245f370d2e671d24921dd50ab6 SHA512 3c78fa4d777a79a08606a39bb31f6b329dc9d28c1ef2ea9f3253746dce853a295e8fe85b14c65b04762aa5acd5facc879232a375875a2ca6dc9477cc1ab88786

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
deleted file mode 100644
index 1f997a3c3a3..00000000000
--- a/dev-python/nbconvert/files/nbconvert-5.6.1-inkscape-1.patch
+++ /dev/null
@@ -1,159 +0,0 @@
-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
deleted file mode 100644
index 822c32753f8..00000000000
--- a/dev-python/nbconvert/files/nbconvert-5.6.1-py39.patch
+++ /dev/null
@@ -1,27 +0,0 @@
-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/nbconvert-5.6.1.ebuild b/dev-python/nbconvert/nbconvert-5.6.1.ebuild
deleted file mode 100644
index 3efa859bc6b..00000000000
--- a/dev-python/nbconvert/nbconvert-5.6.1.ebuild
+++ /dev/null
@@ -1,70 +0,0 @@
-# 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
-}


^ permalink raw reply related	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2021-01-05 23:26 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2020-06-10  6:03 [gentoo-commits] repo/gentoo:master commit in: dev-python/nbconvert/files/, dev-python/nbconvert/ Michał Górny
  -- strict thread matches above, loose matches on Subject: below --
2021-01-05 23:26 Michał Górny

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox