Brian Silverman | 6470f44 | 2018-08-05 12:08:16 -0700 | [diff] [blame] | 1 | --- 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 Kuszmaul | 58683ed | 2020-01-25 20:33:11 -0800 | [diff] [blame] | 11 | @@ -110,6 +111,31 @@ |
Brian Silverman | 6470f44 | 2018-08-05 12:08:16 -0700 | [diff] [blame] | 12 | __version__ = str('1.4.2') |
| 13 | __version__numpy__ = str('1.6') # minimum required numpy version |
| 14 | |
James Kuszmaul | 58683ed | 2020-01-25 20:33:11 -0800 | [diff] [blame] | 15 | +_matplotlib_base = os.path.join(os.path.dirname(os.path.dirname(__file__)), "..") |
Brian Silverman | 6470f44 | 2018-08-05 12:08:16 -0700 | [diff] [blame] | 16 | + |
| 17 | +# Hack to point matplotlib at its data. |
| 18 | +os.environ['MATPLOTLIBDATA'] = \ |
| 19 | + os.path.join( \ |
Brian Silverman | b0ebf1d | 2018-10-17 23:36:40 -0700 | [diff] [blame] | 20 | + _matplotlib_base, |
James Kuszmaul | 58683ed | 2020-01-25 20:33:11 -0800 | [diff] [blame] | 21 | + "usr", "share", "matplotlib", "mpl-data") |
Brian Silverman | 6470f44 | 2018-08-05 12:08:16 -0700 | [diff] [blame] | 22 | +# 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 Silverman | b0ebf1d | 2018-10-17 23:36:40 -0700 | [diff] [blame] | 30 | +# 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 Kuszmaul | 58683ed | 2020-01-25 20:33:11 -0800 | [diff] [blame] | 32 | +os.environ['TCL_LIBRARY'] = os.path.join(_matplotlib_base, 'usr', 'share', |
Brian Silverman | b0ebf1d | 2018-10-17 23:36:40 -0700 | [diff] [blame] | 33 | + 'tcltk', 'tcl8.6') |
| 34 | + |
James Kuszmaul | 58683ed | 2020-01-25 20:33:11 -0800 | [diff] [blame] | 35 | +# 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 Silverman | 6470f44 | 2018-08-05 12:08:16 -0700 | [diff] [blame] | 40 | try: |
| 41 | import dateutil |
| 42 | except ImportError: |