01-arcadia.patch 2.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253
  1. --- contrib/python/matplotlib/py3/matplotlib/__init__.py (index)
  2. +++ contrib/python/matplotlib/py3/matplotlib/__init__.py (working tree)
  3. @@ -529,1 +529,1 @@ def _get_data_path():
  4. - return str(Path(__file__).with_name("mpl-data"))
  5. + return _get_internal_mpl_data()
  6. @@ -530,4 +530,18 @@ def get_cachedir():
  7. +def _get_internal_mpl_data():
  8. + import tempfile
  9. + import __res
  10. +
  11. + tmp_dir = tempfile.mkdtemp(prefix='mpl-temp', dir=tempfile.gettempdir())
  12. + for key, rel_path in __res.iter_keys(b"resfs/file/contrib/python/matplotlib/py3/matplotlib/mpl-data/"):
  13. + filename = f"{tmp_dir}/{str(rel_path, 'ascii')}"
  14. + os.makedirs(os.path.dirname(filename), exist_ok=True)
  15. + with open(filename, 'wb') as f:
  16. + f.write(__res.find(key))
  17. +
  18. + return tmp_dir
  19. +
  20. +
  21. def matplotlib_fname():
  22. """
  23. --- contrib/python/matplotlib/py3/matplotlib/backends/backend_nbagg.py (index)
  24. +++ contrib/python/matplotlib/py3/matplotlib/backends/backend_nbagg.py (working tree)
  25. @@ -111,9 +111,9 @@ class FigureManagerNbAgg(FigureManagerWebAgg):
  26. else:
  27. output = stream
  28. super().get_javascript(stream=output)
  29. - output.write((pathlib.Path(__file__).parent
  30. - / "web_backend/js/nbagg_mpl.js")
  31. - .read_text(encoding="utf-8"))
  32. + import pkgutil
  33. + data = pkgutil.get_data(__package__, "web_backend/js/nbagg_mpl.js").decode("utf-8")
  34. + output.write(data)
  35. if stream is None:
  36. return output.getvalue()
  37. --- contrib/python/matplotlib/py3/matplotlib/backends/backend_webagg_core.py (index)
  38. +++ contrib/python/matplotlib/py3/matplotlib/backends/backend_webagg_core.py (working tree)
  39. @@ -505,8 +505,9 @@ class FigureManagerWebAgg(backend_bases.FigureManagerBase):
  40. else:
  41. output = stream
  42. - output.write((Path(__file__).parent / "web_backend/js/mpl.js")
  43. - .read_text(encoding="utf-8"))
  44. + import pkgutil
  45. + data = pkgutil.get_data(__package__, "web_backend/js/mpl.js").decode("utf-8")
  46. + output.write(data)
  47. toolitems = []
  48. for name, tooltip, image, method in cls.ToolbarCls.toolitems: