Skip to content

remove check under linux for ~/.matplotlib #7195

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

Merged
merged 3 commits into from
Oct 3, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 5 additions & 4 deletions doc/faq/environment_variables_faq.rst
Original file line number Diff line number Diff line change
Expand Up @@ -25,10 +25,11 @@ Environment Variables

This is the directory used to store user customizations to matplotlib, as
well as some caches to improve performance. If :envvar:`MPLCONFIGDIR` is not
defined, :file:`{HOME}/.matplotlib` is used if it is writable.
Otherwise, the python standard library :func:`tempfile.gettmpdir` is
used to find a base directory in which the :file:`matplotlib`
subdirectory is created.
defined, :file:`{HOME}/.config/matplotlib` is generally used on unix-like
systems and :file:`{HOME}/.matplotlib` is used on other platforms, if they are
writable. Otherwise, the python standard library :func:`tempfile.gettempdir`
is used to find a base directory in which the :file:`matplotlib` subdirectory
is created.

.. envvar:: MPLBACKEND

Expand Down
32 changes: 8 additions & 24 deletions lib/matplotlib/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -639,8 +639,10 @@ def _get_config_or_cache_dir(xdg_base):
h = get_home()
if h is not None:
p = os.path.join(h, '.matplotlib')
if (sys.platform.startswith('linux') and xdg_base):
p = os.path.join(xdg_base, 'matplotlib')
if sys.platform.startswith('linux'):
p = None
if xdg_base is not None:
p = os.path.join(xdg_base, 'matplotlib')

if p is not None:
if os.path.exists(p):
Expand All @@ -665,9 +667,8 @@ def _get_configdir():

1. If the MPLCONFIGDIR environment variable is supplied, choose that.

2a. On Linux, if `$HOME/.matplotlib` exists, choose that, but warn that
that is the old location. Barring that, follow the XDG specification
and look first in `$XDG_CONFIG_HOME`, if defined, or `$HOME/.config`.
2a. On Linux, follow the XDG specification and look first in
`$XDG_CONFIG_HOME`, if defined, or `$HOME/.config`.

2b. On other platforms, choose `$HOME/.matplotlib`.

Expand Down Expand Up @@ -794,9 +795,7 @@ def matplotlib_fname():

- On Linux,

- `$HOME/.matplotlib/matplotlibrc`, if it exists

- or `$XDG_CONFIG_HOME/matplotlib/matplotlibrc` (if
- `$XDG_CONFIG_HOME/matplotlib/matplotlibrc` (if
$XDG_CONFIG_HOME is defined)

- or `$HOME/.config/matplotlib/matplotlibrc` (if
Expand Down Expand Up @@ -827,24 +826,9 @@ def matplotlib_fname():
return fname

configdir = _get_configdir()
if configdir is not None:
if os.path.exists(configdir):
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
os.path.exists(os.path.join(
home, '.matplotlib', 'matplotlibrc'))):
warnings.warn(
"Found matplotlib configuration in ~/.matplotlib/. "
"To conform with the XDG base directory standard, "
"this configuration location has been deprecated "
"on Linux, and the new location is now %s/matplotlib/. "
"Please move your configuration there to ensure that "
"matplotlib will continue to find it in the future." %
_get_xdg_config_dir())
return os.path.join(
home, '.matplotlib', 'matplotlibrc')
return fname

path = get_data_path() # guaranteed to exist or raise
Expand Down