summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAlfredo Tupone <tupone@gentoo.org>2022-06-26 12:03:25 +0200
committerAlfredo Tupone <tupone@gentoo.org>2022-06-26 12:03:25 +0200
commit332fddbf43e73b8695c25f5424a558373deb0657 (patch)
treefbd9daf323aac8f64aab7a880a61162e1362828d /sci-visualization/dash
parentdev-python/mistune: keyword 2.0.2-r1 for ~loong (diff)
downloadgentoo-332fddbf43e73b8695c25f5424a558373deb0657.tar.gz
gentoo-332fddbf43e73b8695c25f5424a558373deb0657.tar.bz2
gentoo-332fddbf43e73b8695c25f5424a558373deb0657.zip
sci-visualization/dash: fix werkzeug 2.1.0 import
Closes: https://bugs.gentoo.org/844142 Package-Manager: Portage-3.0.30, Repoman-3.0.3 Signed-off-by: Alfredo Tupone <tupone@gentoo.org>
Diffstat (limited to 'sci-visualization/dash')
-rw-r--r--sci-visualization/dash/dash-1.21.0-r1.ebuild38
-rw-r--r--sci-visualization/dash/files/0001-Fix-werkzeug-2.1.0-import-dev-tools-error-html-rende.patch98
2 files changed, 136 insertions, 0 deletions
diff --git a/sci-visualization/dash/dash-1.21.0-r1.ebuild b/sci-visualization/dash/dash-1.21.0-r1.ebuild
new file mode 100644
index 000000000000..9d388cb84220
--- /dev/null
+++ b/sci-visualization/dash/dash-1.21.0-r1.ebuild
@@ -0,0 +1,38 @@
+# Copyright 2021-2022 Gentoo Authors
+# Distributed under the terms of the GNU General Public License v2
+
+EAPI=7
+
+PYTHON_COMPAT=( python3_{8..10} )
+inherit distutils-r1
+
+DESCRIPTION="Python framework for building ML & data science web apps"
+HOMEPAGE="https://github.com/plotly/dash"
+SRC_URI="https://github.com/plotly/${PN}/archive/refs/tags/v${PV}.tar.gz
+ -> ${P}.tar.gz"
+
+LICENSE="MIT"
+SLOT="0"
+KEYWORDS="~amd64 ~x86"
+# Test need some packages not yet in the tree
+# flask_talisman
+# percy
+# ...
+RESTRICT="test"
+
+RDEPEND="
+ dev-python/future[${PYTHON_USEDEP}]
+ sci-visualization/dash-table[${PYTHON_USEDEP}]
+ sci-visualization/dash-html-components[${PYTHON_USEDEP}]
+ sci-visualization/dash-core-components[${PYTHON_USEDEP}]
+ dev-python/plotly[${PYTHON_USEDEP}]
+ dev-python/flask-compress[${PYTHON_USEDEP}]"
+DEPEND="${RDEPEND}
+ test? ( dev-python/beautifulsoup4 )"
+BDEPEND=""
+
+distutils_enable_tests pytest
+
+PATCHES=(
+ "${FILESDIR}"/0001-Fix-werkzeug-2.1.0-import-dev-tools-error-html-rende.patch
+)
diff --git a/sci-visualization/dash/files/0001-Fix-werkzeug-2.1.0-import-dev-tools-error-html-rende.patch b/sci-visualization/dash/files/0001-Fix-werkzeug-2.1.0-import-dev-tools-error-html-rende.patch
new file mode 100644
index 000000000000..7f19380dc7cb
--- /dev/null
+++ b/sci-visualization/dash/files/0001-Fix-werkzeug-2.1.0-import-dev-tools-error-html-rende.patch
@@ -0,0 +1,98 @@
+From f9079bfd8a9576947655e1fee0dc343171c21e37 Mon Sep 17 00:00:00 2001
+From: philippe <t4rk@outlook.com>
+Date: Tue, 29 Mar 2022 12:17:40 -0400
+Subject: [PATCH] Fix werkzeug 2.1.0 import & dev tools error html rendering.
+
+---
+ .../error/FrontEnd/FrontEndError.react.js | 2 +-
+ dash/dash.py | 42 +++++++++++++++----
+ 2 files changed, 34 insertions(+), 10 deletions(-)
+
+diff --git a/dash/dash-renderer/src/components/error/FrontEnd/FrontEndError.react.js b/dash/dash-renderer/src/components/error/FrontEnd/FrontEndError.react.js
+index 5703add4..49939ea1 100644
+--- a/dash/dash-renderer/src/components/error/FrontEnd/FrontEndError.react.js
++++ b/dash/dash-renderer/src/components/error/FrontEnd/FrontEndError.react.js
+@@ -110,7 +110,7 @@ function UnconnectedErrorContent({error, base}) {
+ )}
+ {/* Backend Error */}
+ {typeof error.html !== 'string' ? null : error.html.indexOf(
+- '<!DOCTYPE HTML'
++ '<!DOCTYPE'
+ ) === 0 ? (
+ <div className='dash-be-error__st'>
+ <div className='dash-backend-error'>
+diff --git a/dash/dash.py b/dash/dash.py
+index b4a3adf0..3d5dae25 100644
+--- a/dash/dash.py
++++ b/dash/dash.py
+@@ -19,7 +19,10 @@ from future.moves.urllib.parse import urlparse
+
+ import flask
+ from flask_compress import Compress
+-from werkzeug.debug.tbtools import get_current_traceback
++
++from werkzeug.debug import tbtools
++from werkzeug.security import gen_salt
++
+ from pkg_resources import get_distribution, parse_version
+
+ import plotly
+@@ -91,6 +94,30 @@ _re_index_scripts_id = 'src="[^"]*dash[-_]renderer[^"]*"', "dash-renderer"
+ _re_renderer_scripts_id = 'id="_dash-renderer', "new DashRenderer"
+
+
++def _get_traceback(secret, error):
++ def _get_skip(text):
++ skip = 0
++ for i, line in enumerate(text.splitlines()):
++ if "%% callback invoked %%" in line:
++ skip = int((i + 1) / 2)
++ break
++ return skip
++
++ # werkzeug<2.1.0
++ if hasattr(tbtools, "get_current_traceback"):
++ tb = tbtools.get_current_traceback()
++ skip = _get_skip(tb.plaintext)
++ return tbtools.get_current_traceback(skip=skip).render_full()
++
++ tb = tbtools.DebugTraceback(error) # pylint: disable=no-member
++ skip = _get_skip(tb.render_traceback_text())
++
++ # pylint: disable=no-member
++ return tbtools.DebugTraceback(error, skip=skip).render_debugger_html(
++ True, secret, True
++ )
++
++
+ class _NoUpdate(object):
+ # pylint: disable=too-few-public-methods
+ pass
+@@ -1463,19 +1490,16 @@ class Dash(object):
+
+ if debug and dev_tools.prune_errors:
+
++ secret = gen_salt(20)
++
+ @self.server.errorhandler(Exception)
+- def _wrap_errors(_):
++ def _wrap_errors(error):
+ # find the callback invocation, if the error is from a callback
+ # and skip the traceback up to that point
+ # if the error didn't come from inside a callback, we won't
+ # skip anything.
+- tb = get_current_traceback()
+- skip = 0
+- for i, line in enumerate(tb.plaintext.splitlines()):
+- if "%% callback invoked %%" in line:
+- skip = int((i + 1) / 2)
+- break
+- return get_current_traceback(skip=skip).render_full(), 500
++ tb = _get_traceback(secret, error)
++ return tb, 500
+
+ if debug and dev_tools.ui:
+
+--
+2.35.1
+