Gentoo Archives: gentoo-commits

From: Alfredo Tupone <tupone@g.o>
To: gentoo-commits@l.g.o
Subject: [gentoo-commits] repo/gentoo:master commit in: sci-visualization/dash/, sci-visualization/dash/files/
Date: Sun, 26 Jun 2022 10:03:41
Message-Id: 1656237805.332fddbf43e73b8695c25f5424a558373deb0657.tupone@gentoo
1 commit: 332fddbf43e73b8695c25f5424a558373deb0657
2 Author: Alfredo Tupone <tupone <AT> gentoo <DOT> org>
3 AuthorDate: Sun Jun 26 10:03:25 2022 +0000
4 Commit: Alfredo Tupone <tupone <AT> gentoo <DOT> org>
5 CommitDate: Sun Jun 26 10:03:25 2022 +0000
6 URL: https://gitweb.gentoo.org/repo/gentoo.git/commit/?id=332fddbf
7
8 sci-visualization/dash: fix werkzeug 2.1.0 import
9
10 Closes: https://bugs.gentoo.org/844142
11 Package-Manager: Portage-3.0.30, Repoman-3.0.3
12 Signed-off-by: Alfredo Tupone <tupone <AT> gentoo.org>
13
14 sci-visualization/dash/dash-1.21.0-r1.ebuild | 38 +++++++++
15 ...g-2.1.0-import-dev-tools-error-html-rende.patch | 98 ++++++++++++++++++++++
16 2 files changed, 136 insertions(+)
17
18 diff --git a/sci-visualization/dash/dash-1.21.0-r1.ebuild b/sci-visualization/dash/dash-1.21.0-r1.ebuild
19 new file mode 100644
20 index 000000000000..9d388cb84220
21 --- /dev/null
22 +++ b/sci-visualization/dash/dash-1.21.0-r1.ebuild
23 @@ -0,0 +1,38 @@
24 +# Copyright 2021-2022 Gentoo Authors
25 +# Distributed under the terms of the GNU General Public License v2
26 +
27 +EAPI=7
28 +
29 +PYTHON_COMPAT=( python3_{8..10} )
30 +inherit distutils-r1
31 +
32 +DESCRIPTION="Python framework for building ML & data science web apps"
33 +HOMEPAGE="https://github.com/plotly/dash"
34 +SRC_URI="https://github.com/plotly/${PN}/archive/refs/tags/v${PV}.tar.gz
35 + -> ${P}.tar.gz"
36 +
37 +LICENSE="MIT"
38 +SLOT="0"
39 +KEYWORDS="~amd64 ~x86"
40 +# Test need some packages not yet in the tree
41 +# flask_talisman
42 +# percy
43 +# ...
44 +RESTRICT="test"
45 +
46 +RDEPEND="
47 + dev-python/future[${PYTHON_USEDEP}]
48 + sci-visualization/dash-table[${PYTHON_USEDEP}]
49 + sci-visualization/dash-html-components[${PYTHON_USEDEP}]
50 + sci-visualization/dash-core-components[${PYTHON_USEDEP}]
51 + dev-python/plotly[${PYTHON_USEDEP}]
52 + dev-python/flask-compress[${PYTHON_USEDEP}]"
53 +DEPEND="${RDEPEND}
54 + test? ( dev-python/beautifulsoup4 )"
55 +BDEPEND=""
56 +
57 +distutils_enable_tests pytest
58 +
59 +PATCHES=(
60 + "${FILESDIR}"/0001-Fix-werkzeug-2.1.0-import-dev-tools-error-html-rende.patch
61 +)
62
63 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
64 new file mode 100644
65 index 000000000000..7f19380dc7cb
66 --- /dev/null
67 +++ b/sci-visualization/dash/files/0001-Fix-werkzeug-2.1.0-import-dev-tools-error-html-rende.patch
68 @@ -0,0 +1,98 @@
69 +From f9079bfd8a9576947655e1fee0dc343171c21e37 Mon Sep 17 00:00:00 2001
70 +From: philippe <t4rk@×××××××.com>
71 +Date: Tue, 29 Mar 2022 12:17:40 -0400
72 +Subject: [PATCH] Fix werkzeug 2.1.0 import & dev tools error html rendering.
73 +
74 +---
75 + .../error/FrontEnd/FrontEndError.react.js | 2 +-
76 + dash/dash.py | 42 +++++++++++++++----
77 + 2 files changed, 34 insertions(+), 10 deletions(-)
78 +
79 +diff --git a/dash/dash-renderer/src/components/error/FrontEnd/FrontEndError.react.js b/dash/dash-renderer/src/components/error/FrontEnd/FrontEndError.react.js
80 +index 5703add4..49939ea1 100644
81 +--- a/dash/dash-renderer/src/components/error/FrontEnd/FrontEndError.react.js
82 ++++ b/dash/dash-renderer/src/components/error/FrontEnd/FrontEndError.react.js
83 +@@ -110,7 +110,7 @@ function UnconnectedErrorContent({error, base}) {
84 + )}
85 + {/* Backend Error */}
86 + {typeof error.html !== 'string' ? null : error.html.indexOf(
87 +- '<!DOCTYPE HTML'
88 ++ '<!DOCTYPE'
89 + ) === 0 ? (
90 + <div className='dash-be-error__st'>
91 + <div className='dash-backend-error'>
92 +diff --git a/dash/dash.py b/dash/dash.py
93 +index b4a3adf0..3d5dae25 100644
94 +--- a/dash/dash.py
95 ++++ b/dash/dash.py
96 +@@ -19,7 +19,10 @@ from future.moves.urllib.parse import urlparse
97 +
98 + import flask
99 + from flask_compress import Compress
100 +-from werkzeug.debug.tbtools import get_current_traceback
101 ++
102 ++from werkzeug.debug import tbtools
103 ++from werkzeug.security import gen_salt
104 ++
105 + from pkg_resources import get_distribution, parse_version
106 +
107 + import plotly
108 +@@ -91,6 +94,30 @@ _re_index_scripts_id = 'src="[^"]*dash[-_]renderer[^"]*"', "dash-renderer"
109 + _re_renderer_scripts_id = 'id="_dash-renderer', "new DashRenderer"
110 +
111 +
112 ++def _get_traceback(secret, error):
113 ++ def _get_skip(text):
114 ++ skip = 0
115 ++ for i, line in enumerate(text.splitlines()):
116 ++ if "%% callback invoked %%" in line:
117 ++ skip = int((i + 1) / 2)
118 ++ break
119 ++ return skip
120 ++
121 ++ # werkzeug<2.1.0
122 ++ if hasattr(tbtools, "get_current_traceback"):
123 ++ tb = tbtools.get_current_traceback()
124 ++ skip = _get_skip(tb.plaintext)
125 ++ return tbtools.get_current_traceback(skip=skip).render_full()
126 ++
127 ++ tb = tbtools.DebugTraceback(error) # pylint: disable=no-member
128 ++ skip = _get_skip(tb.render_traceback_text())
129 ++
130 ++ # pylint: disable=no-member
131 ++ return tbtools.DebugTraceback(error, skip=skip).render_debugger_html(
132 ++ True, secret, True
133 ++ )
134 ++
135 ++
136 + class _NoUpdate(object):
137 + # pylint: disable=too-few-public-methods
138 + pass
139 +@@ -1463,19 +1490,16 @@ class Dash(object):
140 +
141 + if debug and dev_tools.prune_errors:
142 +
143 ++ secret = gen_salt(20)
144 ++
145 + @self.server.errorhandler(Exception)
146 +- def _wrap_errors(_):
147 ++ def _wrap_errors(error):
148 + # find the callback invocation, if the error is from a callback
149 + # and skip the traceback up to that point
150 + # if the error didn't come from inside a callback, we won't
151 + # skip anything.
152 +- tb = get_current_traceback()
153 +- skip = 0
154 +- for i, line in enumerate(tb.plaintext.splitlines()):
155 +- if "%% callback invoked %%" in line:
156 +- skip = int((i + 1) / 2)
157 +- break
158 +- return get_current_traceback(skip=skip).render_full(), 500
159 ++ tb = _get_traceback(secret, error)
160 ++ return tb, 500
161 +
162 + if debug and dev_tools.ui:
163 +
164 +--
165 +2.35.1
166 +