blob: 8d67dc6707fa1ba8cc8674a8a77d3bf4ba7b4d5e [file] [log] [blame]
Brian Silverman6470f442018-08-05 12:08:16 -07001--- a/__init__.py 2018-07-11 15:57:58.086509489 -0700
2+++ b/__init__.py 2018-07-11 16:04:15.004795500 -0700
3@@ -102,6 +102,7 @@
4 from __future__ import (absolute_import, division, print_function,
5 unicode_literals)
6
7+import os
8 import six
9 import sys
10 import distutils.version
James Kuszmaul58683ed2020-01-25 20:33:11 -080011@@ -110,6 +111,31 @@
Brian Silverman6470f442018-08-05 12:08:16 -070012 __version__ = str('1.4.2')
13 __version__numpy__ = str('1.6') # minimum required numpy version
14
James Kuszmaul58683ed2020-01-25 20:33:11 -080015+_matplotlib_base = os.path.join(os.path.dirname(os.path.dirname(__file__)), "..")
Brian Silverman6470f442018-08-05 12:08:16 -070016+
17+# Hack to point matplotlib at its data.
18+os.environ['MATPLOTLIBDATA'] = \
19+ os.path.join( \
Brian Silvermanb0ebf1d2018-10-17 23:36:40 -070020+ _matplotlib_base,
James Kuszmaul58683ed2020-01-25 20:33:11 -080021+ "usr", "share", "matplotlib", "mpl-data")
Brian Silverman6470f442018-08-05 12:08:16 -070022+# Avoid reading /etc/matplotlib in all cases. Matplotlib is pretty happy to
23+# escape the sandbox by using absolute paths.
24+os.environ['MATPLOTLIBRC'] = os.environ['MATPLOTLIBDATA']
25+# There's a bug where the temp directory gets set if MATPLOTLIBRC isn't set.
26+# That causes the directory to not be created in time. We set the variable
27+# manually here to work around the bug.
28+os.environ['MPLCONFIGDIR'] = '/tmp/matplotlib-nobody'
29+
Brian Silvermanb0ebf1d2018-10-17 23:36:40 -070030+# Tell Tcl where to find the sandboxed version. Otherwise, it will try using
31+# one from the host system, even if that's an incompatible version.
James Kuszmaul58683ed2020-01-25 20:33:11 -080032+os.environ['TCL_LIBRARY'] = os.path.join(_matplotlib_base, 'usr', 'share',
Brian Silvermanb0ebf1d2018-10-17 23:36:40 -070033+ 'tcltk', 'tcl8.6')
34+
James Kuszmaul58683ed2020-01-25 20:33:11 -080035+# Tell fontconfig where to find matplotlib's sandboxed font files.
36+os.environ["FONTCONFIG_PATH"] = os.path.join(_matplotlib_base, "etc/fonts/")
37+os.environ["FONTCONFIG_FILE"] = os.path.join(_matplotlib_base, "etc/fonts/fonts.conf")
38+os.environ["FONTCONFIG_SYSROOT"] = _matplotlib_base
39+
Brian Silverman6470f442018-08-05 12:08:16 -070040 try:
41 import dateutil
42 except ImportError: