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

Skip to content

Commit 404ff5d

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 4754b58 commit 404ff5d

File tree

2 files changed

+5
-0
lines changed

2 files changed

+5
-0
lines changed

doc/api/next_api_changes/2018-08-17-AL-deprecations.rst

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,3 +7,6 @@ The following API elements are deprecated:
77
- ``backend_ps.PsBackendHelper``, ``backend_ps.ps_backend_helper``,
88
- ``cbook.iterable``,
99
- ``mlab.demean``,
10+
11+
The following environment variables are deprecated:
12+
- ``MATPLOTLIBDATA``,

lib/matplotlib/__init__.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -652,6 +652,8 @@ def _get_data_path():
652652
if not os.path.isdir(path):
653653
raise RuntimeError('Path in environment MATPLOTLIBDATA not a '
654654
'directory')
655+
cbook.warn_deprecated(
656+
"3.1", name="MATPLOTLIBDATA", obj_type="environment variable")
655657
return path
656658

657659
def get_candidate_paths():

0 commit comments

Comments
 (0)