Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Matplotlib useable on clusters with read-only resp. non-existing home directories on compute nodes. #2695

Closed
wants to merge 1 commit into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
35 changes: 20 additions & 15 deletions lib/matplotlib/__init__.py
Expand Up @@ -531,11 +531,12 @@ def _get_xdg_config_dir():
base directory spec
<http://standards.freedesktop.org/basedir-spec/basedir-spec-latest.html>`_.
"""
home = get_home()
if home is None:
return None
else:
return os.environ.get('XDG_CONFIG_HOME', os.path.join(home, '.config'))
path = os.environ.get('XDG_CONFIG_HOME')
if not path:
path = get_home()
if path:
path = os.path.join(path, '.config')
return path


def _get_xdg_cache_dir():
Expand All @@ -544,11 +545,12 @@ def _get_xdg_cache_dir():
base directory spec
<http://standards.freedesktop.org/basedir-spec/basedir-spec-latest.html>`_.
"""
home = get_home()
if home is None:
return None
else:
return os.environ.get('XDG_CACHE_HOME', os.path.join(home, '.cache'))
path = os.environ.get('XDG_CACHE_HOME')
if not path:
path = get_home()
if path:
path = os.path.join(path, '.cache')
return path


def _get_config_or_cache_dir(xdg_base):
Expand All @@ -566,13 +568,16 @@ def _get_config_or_cache_dir(xdg_base):

p = None
h = get_home()
if h is not None:
if h:
p = os.path.join(h, '.matplotlib')
if (sys.platform.startswith('linux') and
xdg_base is not None):
p = os.path.join(xdg_base, 'matplotlib')
if sys.platform.startswith('linux') and not os.path.exists(p):
# no old config exists
if xdg_base:
p = os.path.join(xdg_base, 'matplotlib')
else:
p = None

if p is not None:
if p:
if os.path.exists(p):
if _is_writable_dir(p):
return p
Expand Down