[RFC]: Use appdirs for platform-specific configuration directories. by Julian · Pull Request #1907 · streamlit/streamlit
Hi there!
What's the precedence of the selection of the directory? e.g. what does appdir do in terms of allowing a user to specify overrides to defaults? Or application-specified (meaning, Streamlit-specified) configurations?
If I follow this question correctly -- on its own appdirs doesn't specifically provide anything there across all operating systems (on Linux, where appdirs is essentially respecting the XDG specification, a user could customize things by modifying e.g. XDG_CONFIG_HOME as they would for any XDG-compliant app, but that only works on Linux).
But a common thing to do is to pair appdirs with a single environment variable, e.g. STREAMLIT_CONFIG, which if set by a user is the path to a config file, and if not set, then you use the path specified by appdirs. Let me know if I misunderstood the question though.
Can you write out a migration plan (can reference code blocks to change) that details how we move from what we have now to a world in which we're using appdirs instead? Needs to include documentation changes.
Certainly. I didn't do so yet thinking it's something that needs agreeing on, so will list it out here to confirm, but happy to then add some documentation on it:
- after this PR, the default path now becomes e.g.
~/.config/streamliton Linux (and on other OSes the OS-specific path there provided by appdirs) - ~/.streamlit is still read as a fallback, so no users' configs should break
- ~/.streamlit can either be deprecated in favor of only the above or be left forever as an alternate path on all OSes (there's precedence for this; some tools either which went through this change or which just want to support an alternate path that works on all OSes will let you use either, and just prioritize one over the other)
- should ~/.streamlit be deprecated, streamlit can either help move a directory found there to ~/.config/streamlit or warn and ask users to move it themselves (typically tools do the latter from what I've seen)
- after a deprecation period (say a year), streamlit then only reads from ~/.config/streamlit
What other alternatives to appdirs exist and should be remarked upon, if appdirs is the first choice here?
So the most relevant one is certainly the config option above, which can be done even without implementing appdirs (where streamlit respects a STREAMLIT_CONFIG option as a path to the config file). This allows users who want the config to live elsewhere for any reason to just put it where they want and set the environment variable to tell streamlit where to look.
appdirs though is fairly pervasive. As a sample, pip itself uses appdirs (which it vendors, but it's here: https://github.com/pypa/pip/blob/master/src/pip/_vendor/appdirs.py), so pip itself has the behavior from this PR.
But certainly the environment variable is another option to consider on its own.
Thanks! I'd also like to say that we don't currently have an RFC process, as such, so thanks for getting the ball rolling for us in terms of thinking about how we'd create one.
:) 👍
Lemme know what you folks think! And thanks for making streamlit.