aboutsummaryrefslogtreecommitdiffstats
path: root/contrib/python/matplotlib/py3/patches/04-fix-relative-paths-web-backend.patch
diff options
context:
space:
mode:
authorAlexander Smirnov <alex@ydb.tech>2025-05-14 00:51:55 +0000
committerAlexander Smirnov <alex@ydb.tech>2025-05-14 00:51:55 +0000
commitb2d03716ee053cd32dccb8dd189d0b4bc3540d90 (patch)
treed329b3f92d5f80b8a76cac17d9e30bd1c8dc4b06 /contrib/python/matplotlib/py3/patches/04-fix-relative-paths-web-backend.patch
parent645c59acc8ced6d89eb8559e26a7405d42ae9fb4 (diff)
parent0bf9db6399352012396e7791bcfd762e944b33c2 (diff)
downloadydb-b2d03716ee053cd32dccb8dd189d0b4bc3540d90.tar.gz
Merge branch 'rightlib' into merge-libs-250514-0050
Diffstat (limited to 'contrib/python/matplotlib/py3/patches/04-fix-relative-paths-web-backend.patch')
-rw-r--r--contrib/python/matplotlib/py3/patches/04-fix-relative-paths-web-backend.patch50
1 files changed, 50 insertions, 0 deletions
diff --git a/contrib/python/matplotlib/py3/patches/04-fix-relative-paths-web-backend.patch b/contrib/python/matplotlib/py3/patches/04-fix-relative-paths-web-backend.patch
new file mode 100644
index 00000000000..af93c725bff
--- /dev/null
+++ b/contrib/python/matplotlib/py3/patches/04-fix-relative-paths-web-backend.patch
@@ -0,0 +1,50 @@
+--- contrib/python/matplotlib/py3/matplotlib/backends/backend_webagg.py (f7af9e31ba1993f2d29753345505773d8e71ca62)
++++ contrib/python/matplotlib/py3/matplotlib/backends/backend_webagg.py (working tree)
+@@ -19,6 +19,10 @@ import random
+ import sys
+ import signal
+ import threading
++import tempfile
++import os
++
++from library.python.resource import iteritems
+
+ try:
+ import tornado
+@@ -177,12 +181,14 @@ class WebAggApplication(tornado.web.Application):
+ assert url_prefix[0] == '/' and url_prefix[-1] != '/', \
+ 'url_prefix must start with a "/" and not end with one.'
+
++ self._store_resources()
++ package_resources_abspath = os.path.join(self._stored_package_path, core.FigureManagerWebAgg.get_static_file_path())
+ super().__init__(
+ [
+ # Static files for the CSS and JS
+ (url_prefix + r'/_static/(.*)',
+ tornado.web.StaticFileHandler,
+- {'path': core.FigureManagerWebAgg.get_static_file_path()}),
++ {'path': package_resources_abspath}),
+
+ # Static images for the toolbar
+ (url_prefix + r'/_images/(.*)',
+@@ -210,7 +216,19 @@ class WebAggApplication(tornado.web.Application):
+ (url_prefix + r'/([0-9]+)/download.([a-z0-9.]+)',
+ self.Download),
+ ],
+- template_path=core.FigureManagerWebAgg.get_static_file_path())
++ template_path=package_resources_abspath)
++
++ def _store_resources(self):
++ self._stored_package_dir = tempfile.TemporaryDirectory()
++ self._stored_package_path = self._stored_package_dir.name
++ package_path = os.path.join(*"contrib/python/matplotlib/py3/".split("/"))
++ for key, data in iteritems(prefix="resfs/file/" + package_path, strip_prefix=True):
++ path = os.path.join(self._stored_package_path, *os.path.split(package_path), *os.path.split(key))
++ dir = os.path.dirname(path)
++ if not os.path.exists(dir):
++ os.makedirs(dir)
++ with open(path, "wb") as file:
++ file.write(data)
+
+ @classmethod
+ def initialize(cls, url_prefix='', port=None, address=None):