From 222c2c7dbc362a1a3e284a3900c9290d83054945 Mon Sep 17 00:00:00 2001 From: Elliott Sales de Andrade Date: Wed, 27 Sep 2017 19:35:59 -0400 Subject: [PATCH 1/2] matplotlibrc path search fix Signed-off-by: Elliott Sales de Andrade --- lib/matplotlib/__init__.py | 28 ++++------------------------ 1 file changed, 4 insertions(+), 24 deletions(-) diff --git a/lib/matplotlib/__init__.py b/lib/matplotlib/__init__.py index 1c47973f15..202acce525 100644 --- a/lib/matplotlib/__init__.py +++ b/lib/matplotlib/__init__.py @@ -536,33 +536,11 @@ def get_data_path(*, _from_rc=None): @_logged_cached('(private) matplotlib data path: %s') def _get_data_path(): - 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(): - # setuptools' namespace_packages may hijack 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' - - for path in get_candidate_paths(): - if path.is_dir(): - defaultParams['datapath'][0] = str(path) - return str(path) - raise RuntimeError('Could not find the matplotlib data files') @@ -583,6 +561,7 @@ def matplotlib_fname(): is not defined) - On other platforms, - ``$HOME/.matplotlib/matplotlibrc`` if ``$HOME`` is defined + - ``/etc/matplotlibrc`` - Lastly, it looks in ``$MATPLOTLIBDATA/matplotlibrc``, which should always exist. """ @@ -597,6 +576,7 @@ def matplotlib_fname(): yield matplotlibrc yield os.path.join(matplotlibrc, 'matplotlibrc') yield os.path.join(get_configdir(), 'matplotlibrc') + yield '/etc/matplotlibrc' yield os.path.join(_get_data_path(), 'matplotlibrc') for fname in gen_candidates(): -- 2.26.2