get_cache_dir#

astropy.config.get_cache_dir(rootname='astropy', *, ensure_exists=True)[source]#

Determines the cache directory associated with a namespace and, optionally, creates the directory if it doesn’t exist.

This directory is typically $XDG_CACHE_HOME/<namespace>, but can be overwritten with the ASTROPY_CACHE_DIR environment variable, or with temporary_cache_dir_path().

Changed in version 8.0: In previous versions, the return value pointed to $HOME/.astropy/cache by default. A new environment variable ASTROPY_CACHE_DIR is now supported. Symlinks are no longer created in any situation.

Parameters:
rootnamepython:str, optional

Namespace associated with the directory. For example, for 'pkgname', the directory would be $XDG_CACHE_HOME/pkgname. Default: 'astropy'

ensure_existsbool, keyword-only, optional

Whether to create the directory (and its parents) if it’s missing. Default: True

Added in version 8.0.0.

Returns:
python:str

The absolute path to the cache directory.

See also

get_cache_dir_path

same as this function, except that the return value is a pathlib.Path