@@ -619,8 +619,9 @@ def get_cachedir():
619619 return _get_config_or_cache_dir (_get_xdg_cache_dir ())
620620
621621
622- def _get_data_path ():
623- """Return the path to matplotlib data."""
622+ @_logged_cached ('matplotlib data path: %s' )
623+ def get_data_path ():
624+ """Return the path to Matplotlib data."""
624625
625626 if 'MATPLOTLIBDATA' in os .environ :
626627 path = os .environ ['MATPLOTLIBDATA' ]
@@ -633,6 +634,7 @@ def _get_data_path():
633634
634635 path = Path (__file__ ).with_name ("mpl-data" )
635636 if path .is_dir ():
637+ defaultParams ['datapath' ][0 ] = str (path )
636638 return str (path )
637639
638640 cbook .warn_deprecated (
@@ -655,18 +657,12 @@ def get_candidate_paths():
655657
656658 for path in get_candidate_paths ():
657659 if path .is_dir ():
660+ defaultParams ['datapath' ][0 ] = str (path )
658661 return str (path )
659662
660663 raise RuntimeError ('Could not find the matplotlib data files' )
661664
662665
663- @_logged_cached ('matplotlib data path: %s' )
664- def get_data_path ():
665- if defaultParams ['datapath' ][0 ] is None :
666- defaultParams ['datapath' ][0 ] = _get_data_path ()
667- return defaultParams ['datapath' ][0 ]
668-
669-
670666@cbook .deprecated ("3.1" )
671667def get_py2exe_datafiles ():
672668 data_path = Path (get_data_path ())
@@ -736,6 +732,7 @@ def gen_candidates():
736732 'savefig.frameon' : ('3.1' ,),
737733 'verbose.fileo' : ('3.1' ,),
738734 'verbose.level' : ('3.1' ,),
735+ 'datapath' : ('3.2.1' ,),
739736}
740737
741738
@@ -973,8 +970,9 @@ def rc_params_from_file(fname, fail_on_error=False, use_default_template=True):
973970 if key not in _all_deprecated ])
974971 config .update (config_from_file )
975972
976- if config ['datapath' ] is None :
977- config ['datapath' ] = get_data_path ()
973+ with cbook ._suppress_matplotlib_deprecation_warning ():
974+ if config ['datapath' ] is None :
975+ config ['datapath' ] = get_data_path ()
978976
979977 if "" .join (config ['text.latex.preamble' ]):
980978 _log .info ("""
0 commit comments