Description: deal with the case where there are no writable directories. Author: Michael Droettboom Bug-Debian: http://bugs.debian.org/719384 Origin: https://github.com/mdboom/matplotlib/commit/1e8d592ed0439ac6fe8fc08d5efe522799acf4fe Reviewed-By: Anton Gladky Last-Update: 2013-09-29 --- matplotlib-1.3.0.orig/lib/matplotlib/font_manager.py +++ matplotlib-1.3.0/lib/matplotlib/font_manager.py @@ -1324,6 +1324,8 @@ if USE_FONTCONFIG and sys.platform != 'w return result else: + _fmcache = None + if not 'TRAVIS' in os.environ: cachedir = get_cachedir() if cachedir is not None: @@ -1331,8 +1333,6 @@ else: _fmcache = os.path.join(cachedir, 'fontList.py3k.cache') else: _fmcache = os.path.join(cachedir, 'fontList.cache') - else: - _fmcache = None fontManager = None --- matplotlib-1.3.0.orig/lib/matplotlib/__init__.py +++ matplotlib-1.3.0/lib/matplotlib/__init__.py @@ -518,7 +518,11 @@ def _get_xdg_config_dir(): base directory spec `_. """ - return os.environ.get('XDG_CONFIG_HOME', os.path.join(get_home(), '.config')) + home = get_home() + if home is None: + return None + else: + return os.environ.get('XDG_CONFIG_HOME', os.path.join(home, '.config')) def _get_xdg_cache_dir(): @@ -527,7 +531,11 @@ def _get_xdg_cache_dir(): base directory spec `_. """ - return os.environ.get('XDG_CACHE_HOME', os.path.join(get_home(), '.cache')) + home = get_home() + if home is None: + return None + else: + return os.environ.get('XDG_CACHE_HOME', os.path.join(home, '.cache')) def _get_config_or_cache_dir(xdg_base): @@ -543,22 +551,28 @@ def _get_config_or_cache_dir(xdg_base): return _create_tmp_config_dir() return configdir + p = None h = get_home() - p = os.path.join(h, '.matplotlib') - if (sys.platform.startswith('linux') and - not os.path.exists(p)): - p = os.path.join(xdg_base, 'matplotlib') - - if os.path.exists(p): - if not _is_writable_dir(p): - return _create_tmp_config_dir() - else: - try: - mkdirs(p) - except OSError: - return _create_tmp_config_dir() + if h is not None: + p = os.path.join(h, '.matplotlib') + if (sys.platform.startswith('linux') and + not os.path.exists(p) and + xdg_base is not None): + p = os.path.join(xdg_base, 'matplotlib') + + if p is not None: + if os.path.exists(p): + if _is_writable_dir(p): + return p + else: + try: + mkdirs(p) + except OSError: + pass + else: + return p - return p + return _create_tmp_config_dir() def _get_configdir(): @@ -716,9 +730,11 @@ def matplotlib_fname(): if configdir is not None: fname = os.path.join(configdir, 'matplotlibrc') if os.path.exists(fname): + home = get_home() if (sys.platform.startswith('linux') and + home is not None and fname == os.path.join( - get_home(), '.matplotlib', 'matplotlibrc')): + home, '.matplotlib', 'matplotlibrc')): warnings.warn( "Found matplotlib configuration in ~/.matplotlib/. " "To conform with the XDG base directory standard, "