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