python-matplotlib/0001-matplotlibrc-path-search-fix.patch

102 lines
3.9 KiB
Diff
Raw Normal View History

2018-09-18 08:51:42 +00:00
From 2ff8ec9b9047b8197d96e651e038eab73e3a6cd2 Mon Sep 17 00:00:00 2001
2017-10-15 22:16:56 +00:00
From: Elliott Sales de Andrade <quantum.analyst@gmail.com>
Date: Wed, 27 Sep 2017 19:35:59 -0400
2018-03-31 07:28:44 +00:00
Subject: [PATCH 1/3] matplotlibrc path search fix
2017-10-15 22:16:56 +00:00
Signed-off-by: Elliott Sales de Andrade <quantum.analyst@gmail.com>
---
2018-08-17 21:37:11 +00:00
lib/matplotlib/__init__.py | 18 +++---------------
2018-08-14 01:27:10 +00:00
lib/matplotlib/tests/test_rcparams.py | 22 ++++++++++++++++------
2018-08-17 21:37:11 +00:00
2 files changed, 19 insertions(+), 21 deletions(-)
2017-10-15 22:16:56 +00:00
diff --git a/lib/matplotlib/__init__.py b/lib/matplotlib/__init__.py
2018-08-29 03:29:22 +00:00
index f7b37ee3b..508e1658d 100644
2017-10-15 22:16:56 +00:00
--- a/lib/matplotlib/__init__.py
+++ b/lib/matplotlib/__init__.py
2018-08-17 21:37:11 +00:00
@@ -664,18 +664,7 @@ def _get_data_path():
return path
2018-08-17 21:37:11 +00:00
def get_candidate_paths():
- yield Path(__file__).with_name('mpl-data')
- # setuptools' namespace_packages may highjack this init file
- # so need to try something known to be in Matplotlib, not basemap.
- import matplotlib.afm
- yield Path(matplotlib.afm.__file__).with_name('mpl-data')
- # py2exe zips pure python, so still need special check.
- if getattr(sys, 'frozen', None):
- yield Path(sys.executable).with_name('mpl-data')
- # Try again assuming we need to step up one more directory.
- yield Path(sys.executable).parent.with_name('mpl-data')
- # Try again assuming sys.path[0] is a dir not a exe.
- yield Path(sys.path[0]) / 'mpl-data'
+ yield Path('/usr/share/matplotlib/mpl-data')
for path in get_candidate_paths():
if path.is_dir():
@@ -727,8 +716,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():
2018-08-17 21:37:11 +00:00
@@ -741,7 +729,7 @@ def matplotlib_fname():
2017-09-27 05:29:13 +00:00
yield matplotlibrc
yield os.path.join(matplotlibrc, 'matplotlibrc')
2018-08-17 21:37:11 +00:00
yield os.path.join(get_configdir(), 'matplotlibrc')
2017-09-27 05:29:13 +00:00
- yield os.path.join(get_data_path(), 'matplotlibrc')
+ yield '/etc/matplotlibrc'
2017-09-27 05:29:13 +00:00
for fname in gen_candidates():
2018-03-31 07:28:44 +00:00
if os.path.exists(fname):
diff --git a/lib/matplotlib/tests/test_rcparams.py b/lib/matplotlib/tests/test_rcparams.py
2018-08-17 21:37:11 +00:00
index 7eec4d421..4c74619f6 100644
--- a/lib/matplotlib/tests/test_rcparams.py
+++ b/lib/matplotlib/tests/test_rcparams.py
2018-08-17 21:37:11 +00:00
@@ -451,11 +451,22 @@ 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):
2018-08-17 21:37:11 +00:00
# This tests if the matplotlibrc.template file contains all valid rcParams.
deprecated = {*mpl._all_deprecated, *mpl._deprecated_remain_as_none}
2018-08-14 01:27:10 +00:00
- 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 = {}
2018-08-14 01:27:10 +00:00
for k, v in mpl.defaultParams.items():
2018-08-17 21:37:11 +00:00
@@ -478,11 +489,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.
2018-08-14 01:27:10 +00:00
- 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:
2017-10-15 22:16:56 +00:00
--
2018-08-14 01:27:10 +00:00
2.17.1
2017-10-15 22:16:56 +00:00