2020-03-04 04:05:13 +00:00
|
|
|
From 4fa2feb3b74904723c038c80303cddb52b68718d 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
|
2019-05-31 05:44:54 +00:00
|
|
|
Subject: [PATCH 1/4] matplotlibrc path search fix
|
2017-10-15 22:16:56 +00:00
|
|
|
|
|
|
|
Signed-off-by: Elliott Sales de Andrade <quantum.analyst@gmail.com>
|
|
|
|
---
|
2020-03-04 04:05:13 +00:00
|
|
|
lib/matplotlib/__init__.py | 30 ++++-----------------------
|
|
|
|
lib/matplotlib/tests/test_rcparams.py | 15 ++++++++++----
|
|
|
|
2 files changed, 15 insertions(+), 30 deletions(-)
|
2017-10-15 22:16:56 +00:00
|
|
|
|
|
|
|
diff --git a/lib/matplotlib/__init__.py b/lib/matplotlib/__init__.py
|
2020-03-04 04:05:13 +00:00
|
|
|
index c4dba5f29..c56f5ca14 100644
|
2017-10-15 22:16:56 +00:00
|
|
|
--- a/lib/matplotlib/__init__.py
|
|
|
|
+++ b/lib/matplotlib/__init__.py
|
2020-03-04 04:05:13 +00:00
|
|
|
@@ -631,32 +631,11 @@ def _get_data_path():
|
|
|
|
"3.1", name="MATPLOTLIBDATA", obj_type="environment variable")
|
2014-01-28 16:50:22 +00:00
|
|
|
return path
|
|
|
|
|
2020-03-04 04:05:13 +00:00
|
|
|
- path = Path(__file__).with_name("mpl-data")
|
|
|
|
+ path = (Path(__file__).parent.parent.parent.parent.parent /
|
|
|
|
+ 'share/matplotlib/mpl-data')
|
|
|
|
if path.is_dir():
|
|
|
|
return str(path)
|
|
|
|
|
|
|
|
- cbook.warn_deprecated(
|
|
|
|
- "3.2", message="Matplotlib installs where the data is not in the "
|
|
|
|
- "mpl-data subdirectory of the package are deprecated since %(since)s "
|
|
|
|
- "and support for them will be removed %(removal)s.")
|
|
|
|
-
|
|
|
|
- def get_candidate_paths():
|
2019-05-31 05:44:54 +00:00
|
|
|
- # setuptools' namespace_packages may hijack this init file
|
2018-08-17 21:37:11 +00:00
|
|
|
- # 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'
|
2020-03-04 04:05:13 +00:00
|
|
|
-
|
|
|
|
- for path in get_candidate_paths():
|
|
|
|
- if path.is_dir():
|
|
|
|
- return str(path)
|
|
|
|
-
|
|
|
|
raise RuntimeError('Could not find the matplotlib data files')
|
|
|
|
|
2018-08-17 21:37:11 +00:00
|
|
|
|
2020-03-04 04:05:13 +00:00
|
|
|
@@ -694,8 +673,7 @@ def matplotlib_fname():
|
2019-05-31 05:44:54 +00:00
|
|
|
is not defined)
|
|
|
|
- On other platforms,
|
2020-03-04 04:05:13 +00:00
|
|
|
- ``$HOME/.matplotlib/matplotlibrc`` if ``$HOME`` is defined
|
2019-05-31 05:44:54 +00:00
|
|
|
- - Lastly, it looks in ``$MATPLOTLIBDATA/matplotlibrc``, which should always
|
|
|
|
- exist.
|
|
|
|
+ - Lastly, it looks in ``/etc/matplotlibrc``, which should always exist.
|
2018-03-31 07:28:44 +00:00
|
|
|
"""
|
|
|
|
|
|
|
|
def gen_candidates():
|
2020-03-04 04:05:13 +00:00
|
|
|
@@ -708,7 +686,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'
|
2014-01-28 16:50:22 +00:00
|
|
|
|
2017-09-27 05:29:13 +00:00
|
|
|
for fname in gen_candidates():
|
2019-05-31 05:44:54 +00:00
|
|
|
if os.path.exists(fname) and not os.path.isdir(fname):
|
2018-03-31 07:28:44 +00:00
|
|
|
diff --git a/lib/matplotlib/tests/test_rcparams.py b/lib/matplotlib/tests/test_rcparams.py
|
2020-03-04 04:05:13 +00:00
|
|
|
index 87dfbeceb..54885da47 100644
|
2018-03-31 07:28:44 +00:00
|
|
|
--- a/lib/matplotlib/tests/test_rcparams.py
|
|
|
|
+++ b/lib/matplotlib/tests/test_rcparams.py
|
2020-03-04 04:05:13 +00:00
|
|
|
@@ -460,10 +460,17 @@ def test_rcparams_reset_after_fail():
|
2018-03-31 07:28:44 +00:00
|
|
|
assert mpl.rcParams['text.usetex'] is False
|
|
|
|
|
|
|
|
|
|
|
|
-def test_if_rctemplate_is_up_to_date():
|
|
|
|
+@pytest.fixture
|
|
|
|
+def mplrc():
|
2019-05-31 05:44:54 +00:00
|
|
|
+ # This is the Fedora-specific location.
|
|
|
|
+ return (Path(__file__).parent.parent.parent.parent.parent.parent.parent /
|
|
|
|
+ 'etc/matplotlibrc')
|
2018-03-31 07:28:44 +00:00
|
|
|
+
|
|
|
|
+
|
|
|
|
+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}
|
2020-03-04 04:05:13 +00:00
|
|
|
- with cbook._get_data_path('matplotlibrc').open() as file:
|
|
|
|
+ with mplrc.open() as file:
|
|
|
|
rclines = file.readlines()
|
2018-03-31 07:28:44 +00:00
|
|
|
missing = {}
|
2018-08-14 01:27:10 +00:00
|
|
|
for k, v in mpl.defaultParams.items():
|
2020-03-04 04:05:13 +00:00
|
|
|
@@ -483,10 +490,10 @@ def test_if_rctemplate_is_up_to_date():
|
2018-03-31 07:28:44 +00:00
|
|
|
.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.
|
2020-03-04 04:05:13 +00:00
|
|
|
- with cbook._get_data_path('matplotlibrc').open() as file:
|
|
|
|
+ with mplrc.open() as file:
|
|
|
|
rclines = file.readlines()
|
2018-03-31 07:28:44 +00:00
|
|
|
newlines = []
|
|
|
|
for line in rclines:
|
2017-10-15 22:16:56 +00:00
|
|
|
--
|
2020-03-04 04:05:13 +00:00
|
|
|
2.21.1
|
2017-10-15 22:16:56 +00:00
|
|
|
|