Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 2052e3b

Browse files
committed
Deprecate the MATPLOTLIBDATA environment variable.
The MATPLOTLIBDATA environment variable is only relevant to non-standard installs (e.g., debian) that move the mpl-data directory to a separate location (in debian's case, /usr/share/matplotlib/mpl-data); but for whoever is already patching Matplotlib to achieve this, they may as well also patch `get_data_path` to always return the new correct path (which debian already does in their `20_matplotlibrc_path_search_fix.patch`), reproduced here: diff --git a/lib/matplotlib/__init__.py b/lib/matplotlib/__init__.py index 9339707..563b0a8 100644 --- a/lib/matplotlib/__init__.py +++ b/lib/matplotlib/__init__.py @@ -738,10 +738,12 @@ def _get_data_path(): return 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 @@ -836,7 +838,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):
1 parent d7bd340 commit 2052e3b

File tree

2 files changed

+7
-0
lines changed

2 files changed

+7
-0
lines changed

doc/api/next_api_changes/2018-02-15-AL-deprecations.rst

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,3 +37,6 @@ The following classes, methods, functions, and attributes are deprecated:
3737

3838
The following rcParams are deprecated:
3939
- ``pgf.debug`` (the pgf backend relies on logging),
40+
41+
The following environment variables are deprecated:
42+
- ``MATPLOTLIBDATA``,

lib/matplotlib/__init__.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -701,6 +701,10 @@ def _get_data_path():
701701
if not os.path.isdir(path):
702702
raise RuntimeError('Path in environment MATPLOTLIBDATA not a '
703703
'directory')
704+
cbook.warn_deprecated(
705+
"3.0", "The MATPLOTLIBDATA environment variable is deprecated "
706+
"since Matplotlib 3.0 and will have no effect starting from "
707+
"Matplotlib 3.2.")
704708
return path
705709

706710
_file = _decode_filesystem_path(__file__)

0 commit comments

Comments
 (0)