-
-
Notifications
You must be signed in to change notification settings - Fork 2.1k
Description
Description
This ticket does a few things:
- Attempts to synthesize various open tickets related to configuration system woes
- Proposes adding support for
ASTROPY_CONFIG_DIRandASTROPY_CACHE_DIRenvironment variables, allowing total customization of these paths by users if desired - De-emphasizes use of
XDG_environment variables for configuring where Astropy-related files go, as it is a somewhat system-biased solution and could cause problems for other apps when used by unwary users (while still maintaining support for the XDG directory specification and documenting it in more "intermediate" config documentation) - Ditto implementation of Consider using appdirs for config #8245 to vendor the appdirs module rather than maintaining our own config path code (or at least a more minimal amount).
I believe this proposal would, in one stroke, resolve:
- XDG_CONFIG_HOME failing silently caused confusion #6511
- Why doesn't astropy use ~/.config/astropy by default (on Unix-like systems)? #6803
- Use user-specified custom cache directory #10244
and maybe some others. Also related is #10090 which I don't think is in conflict with this proposal--it would still just suppress loading any config file. Originally I thought of incorporating #8245 into this, but upon further reflection I think it would be counter-productive.
Detailed proposal
Much of this proposal is already in line with the status quo, but I wanted to write out the logic clearly:
-
By default all Astropy-related directories remain under the path
~/.astropy/. This includes~/.astropy/config/and~/.astropy/cache; this is the current status quo, and is applicable to all platforms, where its platform-specific expansion depends on howos.path.expanduserworks on that platform (see also MNT: Change config home path logic #10705) -
Astropy will honor the XDG base directory specification if and only if
XDG_CONFIG_HOMEand/orXDG_CACHE_HOMEare explicitly set in the environment. Otherwise it falls back the the default behavior in 1. If either one of theXDG_*_HOMEvariables is set we commit to the XDG specification. For example ifXDG_CONFIG_HOMEis set, then the astropy config dir is$XDG_CONFIG_HOME/astropy, and the astropy cache dir is~/.cache/astropyand not~/.astropy/cache.- Use of
XDG_*environment variables will be de-emphasized in the docs, though this logic will be made clear in an admonition box for Linux/BSD users.
- Use of
-
If
ASTROPY_CONFIG_DIRis set, it overrides both 1. and 2. For example settingASTROPY_CONFIG_DIR=/etc/astropyfixes that path and overrides any other processing. Same forASTROPY_CACHE_DIR. These variables can both be used independently.- These will be documented as the recommended way to change astropy's default directories.
-
Suppress config loading with ASTROPY_SUPPRESS_CONFIG #10090 is maintained within this scheme as well. If
ASTROPY_SUPPRESS_CONFIGis set then all config file loading is suppressed, overriding all of 1., 2., and 3.