@@ -431,16 +431,6 @@ def get_home():
431
431
return None
432
432
433
433
434
- def _create_tmp_config_or_cache_dir ():
435
- """
436
- If the config or cache directory cannot be created, create a temporary one.
437
- """
438
- configdir = os .environ ['MPLCONFIGDIR' ] = (
439
- tempfile .mkdtemp (prefix = 'matplotlib-' ))
440
- atexit .register (shutil .rmtree , configdir )
441
- return configdir
442
-
443
-
444
434
def _get_xdg_config_dir ():
445
435
"""
446
436
Return the XDG configuration directory, according to the XDG base
@@ -475,7 +465,19 @@ def _get_config_or_cache_dir(xdg_base):
475
465
else :
476
466
if os .access (str (configdir ), os .W_OK ) and configdir .is_dir ():
477
467
return str (configdir )
478
- return _create_tmp_config_or_cache_dir ()
468
+ # If the config or cache directory cannot be created or is not a writable
469
+ # directory, create a temporary one.
470
+ tmpdir = os .environ ["MPLCONFIGDIR" ] = \
471
+ tempfile .mkdtemp (prefix = "matplotlib-" )
472
+ atexit .register (shutil .rmtree , tmpdir )
473
+ _log .warning (
474
+ "Matplotlib created a temporary config/cache directory at %s because "
475
+ "the default path (%s) is not a writable directory; it is highly "
476
+ "recommended to set the MPLCONFIGDIR environment variable to a "
477
+ "writable directory, in particular to speed up the import of "
478
+ "Matplotlib and to better support multiprocessing." ,
479
+ configdir , tmpdir )
480
+ return tmpdir
479
481
480
482
481
483
@_logged_cached ('CONFIGDIR=%s' )
0 commit comments