FazBrowse GitHub Viewer | Trending |
URL:
| Home
Tools: [Download Repo ZIP]   [Original HTTPS Page]

switch to using `appdirs` to find config and data paths · Issue #12549 · matplotlib/matplotlib · GitHub

Repository navigation

switch to using appdirs to find config and data paths #12549

Open

Description

See https://pypi.org/project/appdirs/

This will allow us to drop all of the custom config / data / ... path code we currently own.

This is suggested by @zooba in a talk on how to make sure your project works well on all operating systems.

Activity

  1. added this to the v3.1 milestone on Oct 17, 2018
  2. changed the title [-]switch to using `appdirs` to [/-] [+]switch to using `appdirs` to find config and data paths[/+] on Oct 17, 2018
  3. WeatherGod commented on Oct 17, 2018

    Member
  4. anntzer commented on Oct 18, 2018

    Contributor

    For data I'd much prefer we merge #11241 and use standard packaging tools to ship and retrieve our (static) data...
    For config and cache dirs, sure... except that we also have $MPLCONFIGDIR and $MATPLOTLIBRC to handle anyways, or deprecate. I think having both of them is a bit overkill as the main use I can think of is to point to a temporary matplotlibrc, so just keeping $MATPLOTLIBRC and only allowing it to point to a file(-like) (as opposed to a directory containing a matplotlibrc file) seems enough.
    If we switch to appdirs but keep all the custom code to handle $MPLCONFIGDIR and $MATPLOTLIBRC, I'm not convinced we'd have gained a lot.

  5. zooba commented on Nov 6, 2018

    Contributor

    What you gain is better defaults, and defaults that make sense for the platform the user is currently using. That's worth a lot, as is having the overrides (for the reason you mention), so I'd expect you to have both.

  6. anntzer commented on Nov 7, 2018

    Contributor

    I guess what appdirs gives you for the cachedir is fine, and I am actually happy that Matplotlib follows XDG on Linux.
    However I think it'd be a misfeature to put the matplotlibrc file in ApplicationData on Windows (I think that's what appdirs gives you for user_data_dir?): it's a file that's intended to be edited by the end users, but ApplicationData is a hidden directory (by default, AFAIK), so putting it there doesn't look very user-friendly.

  7. zooba commented on Nov 7, 2018

    Contributor

    If it's meant to be user visible, it should go in "Documents" then. Personally I dislike this, but I live inside AppData (unlike most people).

    It's just as hard to get to the user profile directory as the AppData directory, and the AppData directory is specifically for these kinds of files. And AppData/Local and AppData/Roaming have different behaviours on some systems, as they are designed specifically for different types of app settings, so using them is actually the feature, rather than a misfeature. (The documents folder will also roam when configured, which gives the user better control over their settings.)

    Another helpful thing is to offer a command line option/equivalent to open the file wherever it is located and/or in the user's default text editor (a big advantage of using a ".txt" or ".ini" file for configuration, rather than a "hidden" dotfile).

  8. anntzer commented on Nov 7, 2018

    Contributor

    If it's meant to be user visible, it should go in "Documents" then. Personally I dislike this, but I live inside AppData (unlike most people).

    No strong opinion about putting it in Documents (but I don't think it's something in the appdirs model?), I can't say I have a good idea of what the average Windows user expects. But if we move it to AppData you get to field the questions on the issue tracker about how to get there :-)

    It's just as hard to get to the user profile directory as the AppData directory, and the AppData directory is specifically for these kinds of files.

    Well, C:/Users/<user>/.matplotlib is not hidden by default on Windows, so I don't understand what you mean by "as hard"?

    And AppData/Local and AppData/Roaming have different behaviours on some systems, as they are designed specifically for different types of app settings, so using them is actually the feature, rather than a misfeature. (The documents folder will also roam when configured, which gives the user better control over their settings.)

    Actually I'd rather have matplotlibrc follow $PYTHONPATH (to have it per-venv), but that's a side issue...

    Another helpful thing is to offer a command line option/equivalent to open the file wherever it is located and/or in the user's default text editor (a big advantage of using a ".txt" or ".ini" file for configuration, rather than a "hidden" dotfile).

    If it was matplotlibrc.txt then we could do something like webbrowser.open(matplotlib.matplotlibrc_fname()) (which would open the text editor, despite what the module name says) but in the absence of extension this indeed gets opened by, well, the webbrowser.
    I don't particularly care about the extension, to be honest (I guess .conf would be the normal thing).

  9. zooba commented on Nov 7, 2018

    Contributor

    By "as hard", I mean that if you know the buttons to click to get as far as C:\Users\<user>, and you know to look there, getting to C:\Users\<user>\AppData isn't a big ask. And the quickest way to get to these is to type %APPDATA% or %LOCALAPPDATA% into the address bar (or %USERPROFILE%, but again, the profile directory is not where settings are supposed to be stored).

    I also like configuration files that follow PYTHONPATH (or at least sys.prefix), but yeah, it's not the core issue here :)

    For opening the file, there's also os.startfile on Windows, and this is one of the few good uses for subprocess.call(…, shell=True) (which with just a filename should be consistent across OS's - it only gets difficult when trying to pass multiple filenames).

  10. anntzer commented on Nov 7, 2018

    Contributor

    By "as hard", I mean that if you know the buttons to click to get as far as C:\Users\<user>, and you know to look there, getting to C:\Users\<user>\AppData isn't a big ask. And the quickest way to get to these is to type %APPDATA% or %LOCALAPPDATA% into the address bar (or %USERPROFILE%, but again, the profile directory is not where settings are supposed to be stored).

    I don't have a Windows machine under my hand to check right now (but do use one nearly daily), but IIRC C:\Users\<user> is just opening the explorer, clicking on C:, then on Users, then on <user>, no? Which is definitely simpler than typing anything in the addressbar (OK, actually it's easier for both of us to type something in the addressbar but we're not the constituency here...).

    For opening the file, there's also os.startfile on Windows, and this is one of the few good uses for subprocess.call(…, shell=True) (which with just a filename should be consistent across OS's - it only gets difficult when trying to pass multiple filenames).

    eh?

    [ins] In [1]: subprocess.call("foo.txt", shell=True)
    /bin/sh: foo.txt: command not found
    
  11. zooba commented on Nov 7, 2018

    Contributor

    Okay, guess shell doesn't do what I thought there. But it does on Windows (though startfile is preferable) :)

    The point is less about making it easy for users to find (in which case Documents wins, as does C:\ and C:\Users\<user>\Desktop) and more about not storing files in random places against the design of the OS. Windows has designated locations to store app-specific settings files, which are often ignored out of ignorance. Now that ignorance is no longer an excuse (sorry!), you can choose to violate the design deliberately or you can change your default, it's up to you.

  12. anntzer commented on Nov 7, 2018

    Contributor

    I don't have anything (modulo code churn, more-than-one-way-to-do-it vs deprecation period, yada yada) against putting it in e.g. Documents/matplotlib/matplotlibrc if that's the Windows expectation.
    But I guess that's waiting for ActiveState/appdirs#57 :p (if we do want to pick up a dependency on appdirs...)

  13. modified the milestones: v3.1.0, v3.2.0 on Mar 18, 2019
  14. github-actions commented on May 20, 2023

    This issue has been marked "inactive" because it has been 365 days since the last comment. If this issue is still present in recent Matplotlib releases, or the feature request is still wanted, please leave a comment and this label will be removed. If there are no updates in another 30 days, this issue will be automatically closed, but you are free to re-open or create a new issue if needed. We value issue reports, and this procedure is meant to help us resurface and prioritize issues that have not been addressed yet, not make them disappear. Thanks for your help!

  15. NeilGirdhar commented on May 20, 2023

    It would be good to rename this issue to switch to platformdirs, which is the maintained fork of appdirs. Incidentally, it has platformdirs.user_documents_dir, which @anntzer suggested in his last comment.

  16. github-actions commented on Oct 18, 2024

    This issue has been marked "inactive" because it has been 365 days since the last comment. If this issue is still present in recent Matplotlib releases, or the feature request is still wanted, please leave a comment and this label will be removed. If there are no updates in another 30 days, this issue will be automatically closed, but you are free to re-open or create a new issue if needed. We value issue reports, and this procedure is meant to help us resurface and prioritize issues that have not been addressed yet, not make them disappear. Thanks for your help!

  17. NeilGirdhar commented on Oct 18, 2024

    Please reopen.

  18. added
    keepItems to be ignored by the “Stale” Github Action
    and removed
    status: inactiveMarked by the “Stale” Github Action
    on Oct 18, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    keepItems to be ignored by the “Stale” Github Action

    Type

    No type

    Projects

    No projects

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions


      Back | FazBrowse Home | New Git URL