|
|
62d04f9 |
From e318adb6b70cdb27eb8cd5235909b8e8430080d7 Mon Sep 17 00:00:00 2001
|
|
|
62d04f9 |
From: Elliott Sales de Andrade <quantum.analyst@gmail.com>
|
|
|
62d04f9 |
Date: Wed, 27 Sep 2017 19:35:59 -0400
|
|
|
62d04f9 |
Subject: [PATCH 1/3] matplotlibrc path search fix
|
|
|
62d04f9 |
|
|
|
62d04f9 |
Signed-off-by: Elliott Sales de Andrade <quantum.analyst@gmail.com>
|
|
|
62d04f9 |
---
|
|
|
62d04f9 |
lib/matplotlib/__init__.py | 8 +++++---
|
|
|
62d04f9 |
lib/matplotlib/tests/test_rcparams.py | 22 ++++++++++++++++------
|
|
|
62d04f9 |
2 files changed, 21 insertions(+), 9 deletions(-)
|
|
|
62d04f9 |
|
|
|
62d04f9 |
diff --git a/lib/matplotlib/__init__.py b/lib/matplotlib/__init__.py
|
|
|
62d04f9 |
index c5accc3c3..bc38f316c 100644
|
|
|
62d04f9 |
--- a/lib/matplotlib/__init__.py
|
|
|
62d04f9 |
+++ b/lib/matplotlib/__init__.py
|
|
|
62d04f9 |
@@ -738,9 +738,12 @@ def _get_data_path():
|
|
|
62d04f9 |
|
|
|
62d04f9 |
_file = _decode_filesystem_path(__file__)
|
|
|
62d04f9 |
path = os.sep.join([os.path.dirname(_file), 'mpl-data'])
|
|
|
62d04f9 |
+ path = '/usr/share/python2-matplotlib/mpl-data'
|
|
|
62d04f9 |
if os.path.isdir(path):
|
|
|
62d04f9 |
return path
|
|
|
62d04f9 |
|
|
|
62d04f9 |
+ raise RuntimeError('Could not find the matplotlib data files')
|
|
|
62d04f9 |
+
|
|
|
62d04f9 |
# setuptools' namespace_packages may highjack this init file
|
|
|
62d04f9 |
# so need to try something known to be in matplotlib, not basemap
|
|
|
62d04f9 |
import matplotlib.afm
|
|
|
62d04f9 |
@@ -821,8 +824,7 @@ def matplotlib_fname():
|
|
|
62d04f9 |
|
|
|
62d04f9 |
- `$HOME/.matplotlib/matplotlibrc` if `$HOME` is defined.
|
|
|
62d04f9 |
|
|
|
62d04f9 |
- - Lastly, it looks in `$MATPLOTLIBDATA/matplotlibrc` for a
|
|
|
62d04f9 |
- system-defined copy.
|
|
|
62d04f9 |
+ - Lastly, it looks in `/etc/python2-matplotlibrc` for a system-defined copy.
|
|
|
62d04f9 |
"""
|
|
|
62d04f9 |
|
|
|
62d04f9 |
def gen_candidates():
|
|
|
62d04f9 |
@@ -835,7 +837,7 @@ def matplotlib_fname():
|
|
|
62d04f9 |
yield matplotlibrc
|
|
|
62d04f9 |
yield os.path.join(matplotlibrc, 'matplotlibrc')
|
|
|
62d04f9 |
yield os.path.join(_get_configdir(), 'matplotlibrc')
|
|
|
62d04f9 |
- yield os.path.join(get_data_path(), 'matplotlibrc')
|
|
|
62d04f9 |
+ yield '/etc/python2-matplotlibrc'
|
|
|
62d04f9 |
|
|
|
62d04f9 |
for fname in gen_candidates():
|
|
|
62d04f9 |
if os.path.exists(fname):
|
|
|
62d04f9 |
diff --git a/lib/matplotlib/tests/test_rcparams.py b/lib/matplotlib/tests/test_rcparams.py
|
|
|
62d04f9 |
index c0378e1bf..7f14bcc46 100644
|
|
|
62d04f9 |
--- a/lib/matplotlib/tests/test_rcparams.py
|
|
|
62d04f9 |
+++ b/lib/matplotlib/tests/test_rcparams.py
|
|
|
62d04f9 |
@@ -424,14 +424,25 @@ def test_rcparams_reset_after_fail():
|
|
|
62d04f9 |
assert mpl.rcParams['text.usetex'] is False
|
|
|
62d04f9 |
|
|
|
62d04f9 |
|
|
|
62d04f9 |
-def test_if_rctemplate_is_up_to_date():
|
|
|
62d04f9 |
+@pytest.fixture
|
|
|
62d04f9 |
+def mplrc():
|
|
|
62d04f9 |
+ # This is the Fedora-specific location ...
|
|
|
62d04f9 |
+ if 'MATPLOTLIBDATA' in os.environ:
|
|
|
62d04f9 |
+ # ... in buildroot.
|
|
|
62d04f9 |
+ return os.path.join(os.environ['MATPLOTLIBDATA'],
|
|
|
62d04f9 |
+ '../../../../etc/python2-matplotlibrc')
|
|
|
62d04f9 |
+ else:
|
|
|
62d04f9 |
+ # ... on installed systems.
|
|
|
62d04f9 |
+ return '/etc/python2-matplotlibrc'
|
|
|
62d04f9 |
+
|
|
|
62d04f9 |
+
|
|
|
62d04f9 |
+def test_if_rctemplate_is_up_to_date(mplrc):
|
|
|
62d04f9 |
# This tests if the matplotlibrc.template file
|
|
|
62d04f9 |
# contains all valid rcParams.
|
|
|
62d04f9 |
dep1 = mpl._all_deprecated
|
|
|
62d04f9 |
dep2 = mpl._deprecated_set
|
|
|
62d04f9 |
deprecated = list(dep1.union(dep2))
|
|
|
62d04f9 |
- path_to_rc = os.path.join(mpl.get_data_path(), 'matplotlibrc')
|
|
|
62d04f9 |
- with open(path_to_rc, "r") as f:
|
|
|
62d04f9 |
+ with open(mplrc, "r") as f:
|
|
|
62d04f9 |
rclines = f.readlines()
|
|
|
62d04f9 |
missing = {}
|
|
|
62d04f9 |
for k, v in mpl.defaultParams.items():
|
|
|
62d04f9 |
@@ -453,11 +464,10 @@ def test_if_rctemplate_is_up_to_date():
|
|
|
62d04f9 |
.format(missing.items()))
|
|
|
62d04f9 |
|
|
|
62d04f9 |
|
|
|
62d04f9 |
-def test_if_rctemplate_would_be_valid(tmpdir):
|
|
|
62d04f9 |
+def test_if_rctemplate_would_be_valid(tmpdir, mplrc):
|
|
|
62d04f9 |
# This tests if the matplotlibrc.template file would result in a valid
|
|
|
62d04f9 |
# rc file if all lines are uncommented.
|
|
|
62d04f9 |
- path_to_rc = os.path.join(mpl.get_data_path(), 'matplotlibrc')
|
|
|
62d04f9 |
- with open(path_to_rc, "r") as f:
|
|
|
62d04f9 |
+ with open(mplrc, "r") as f:
|
|
|
62d04f9 |
rclines = f.readlines()
|
|
|
62d04f9 |
newlines = []
|
|
|
62d04f9 |
for line in rclines:
|
|
|
62d04f9 |
--
|
|
|
62d04f9 |
2.17.1
|
|
|
62d04f9 |
|