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

Use a subdirectory of $XDG_CONFIG_HOME instead of ~/.matplotlibrc on Linux #454

Merged
merged 2 commits into from May 28, 2013

Conversation

mdboom
Copy link
Member

@mdboom mdboom commented May 21, 2013

The latest version of the XDG basedir spec seems to recommend this.

http://standards.freedesktop.org/basedir-spec/basedir-spec-latest.html

Is this something we want to do? Will it only add to confusion for platforms that don't use this (presumably Mac OS-X)?

@fperez
Copy link
Member

fperez commented Sep 6, 2011

FWIW, here's what we've done on this topic:

http://ipython.org/ipython-doc/dev/config/overview.html#configuration-file-location

It is indeed a little more information to provide, since osx is now different than linux, but people felt that following the xdg standard was a good idea.

@jkseppan
Copy link
Member

jkseppan commented Sep 7, 2011

On Mac OS X, this kind of files tend to go in ~/Library/Application Support. I think that directory is strictly meant for applications, not libraries, so e.g. a hypothetical application named Pylab.app might place its files in ~/Library/Application Support/org.scipy.Pylab.

Even more strictly, application configuration should go in ~/Library/Preferences and be managed with the appropriate OS X APIs.

http://developer.apple.com/library/mac/#documentation/FileManagement/Conceptual/FileSystemProgrammingGUide/MacOSXDirectories/MacOSXDirectories.html

A lot of common Unix programs do keep their configuration in dotfiles in the home directory, though.

@WeatherGod
Copy link
Member

Could we have it so that if that environment variable is set, then use it. Otherwise, stick with the old location for now?

However, there might be some issues if a person already has an rc file in both locations, how do we know which one to use?

@pelson
Copy link
Member

pelson commented Aug 19, 2012

Sounds like a good idea. Shall we get on and implement it? Anyone keen to give it a shot?

@mdboom
Copy link
Member Author

mdboom commented Dec 10, 2012

+1 on doing this. This has obviously just fallen through the cracks. I think we should plan this for the next major release (I've added a milestone).

@eheintzmann
Copy link

According to XDG Base directory specification:
User data should go into $XDG_DATA_HOME (which default to ~/.local/share),
user preferences should go into $XDG_CONFIG_HOME (which default to ~/.config)
and cached data should go to $XDG_CACHE_HOME (which default to ~/.cache).
More details at :
http://ploum.net/post/207-modify-your-application-to-use-xdg-folders
https://live.gnome.org/GnomeGoals/XDGConfigFolders

Full specification can be found at:
http://standards.freedesktop.org/basedir-spec/latest/

The Freedesktop.org XDG base directory specification have good de facto adoption.
It has been adopted by:

I think that matplotlib should use same locations than the vast majority of Desktop environment and applications.

There are real advantages of following this specification :

  • a lot less cluttered $HOME
  • Make backups a lot more safer and easier.
    Backuping your $XDG_DATA_HOME along with your files is enough
    (or just excluding $XDG_CACHE_HOME)
  • A lot easier to reset a default configuration if you want/need it (and
    without any risk to loose informations). Even for the software itself
    could choose to reset $XDG_CONFIG_HOME if needed.
  • Avoid some strange bugs that happens because you had a old version of
    some configuration file
  • A lot more of flexibility and portability because no path are hardcoded.

@mdboom
Copy link
Member Author

mdboom commented May 21, 2013

@eheintzmann, @fperez: Anyone willing to test this, to make sure the migration path works? I'd like to get this in for 1.3. If a ~/.matplotlib/matplotlibrc file already exists on Linux, it will continue to use that, but display a big fat warning. I think this is better than just going on to use the new location and having users scratch their heads as to why their config appears to be "missing". It's just a matter of moving it to the new location (.config/matplotlib) and it should be quiet, though.

@WeatherGod: I deliberately didn't change behavior on OS-X. We could consider ~/Library/Applications etc., but I think that should be a follow-on PR.

@pelson
Copy link
Member

pelson commented May 24, 2013

@mdboom - the warning was good. But I wonder if we can do this migration automatically? Especially given that the only files in my .matplotlib folder are automatically generated caches anyway.

@mdboom
Copy link
Member Author

mdboom commented May 24, 2013

Most of the files in ~/.matplotlib are auto-generated caches, but the most important one, matplotlibrc is not.

With this PR, all of the cache files will automatically (and silently) start being created and used in ~/.cache/matplotlib. It is only when the human-written matplotlibrc file exists in the old location that this warning will be generated. I'm not a fan of automatically moving the config file. I, for example, have the config files I care about as symlinks into a git repository so they get version controlled and backed up. If this file were to get moved, it might escape that process, (moving a symlink is probably fine, but we can't assume everyone works the way I do) and I would only get the warning that it was moved the first time (which might be easy to miss).

@pelson
Copy link
Member

pelson commented May 24, 2013

It is only when the human-written matplotlibrc file exists in the old location that this warning will be generated.

That was not my experience (I didn't look at the code, just ran it...). I'm happy with the approach you discuss though.


p = os.path.join(h, '.matplotlib')
if os.path.exists(p):
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is the bit which causes the warning for people with a cache but not necessarily a matplotlibrc.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah, I see. I'll fix that up.

mdboom added a commit that referenced this pull request May 28, 2013
Use a subdirectory of $XDG_CONFIG_HOME instead of ~/.matplotlibrc on Linux
@mdboom mdboom merged commit f870c35 into matplotlib:master May 28, 2013
mdboom added a commit that referenced this pull request May 28, 2013
Use a subdirectory of $XDG_CONFIG_HOME instead of ~/.matplotlibrc on Linux
herr-biber added a commit to herr-biber/matplotlib that referenced this pull request Mar 20, 2014
@mdboom mdboom deleted the xdg_config branch August 7, 2014 13:52
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

6 participants