def get_cache_base(suffix=None):
if suffix is None:<EOL><INDENT>suffix = '<STR_LIT>'<EOL><DEDENT>if os.name == '<STR_LIT>' and '<STR_LIT>' in os.environ:<EOL><INDENT>result = os.path.expandvars('<STR_LIT>')<EOL><DEDENT>else:<EOL><INDENT>result = os.path.expanduser('<STR_LIT>')<EOL><DEDENT>if os.path.isdir(result):<EOL><INDENT>usable = os.access(result, os.W_OK)<EOL>if not usable:<EOL><INDENT>logger.warning('<STR_LIT>', result)<EOL><DEDENT><DEDENT>else:<EOL><INDENT>try:<EOL><INDENT>os.makedirs(result)<EOL>usable = True<EOL><DEDENT>except OSError:<EOL><INDENT>logger.warning('<STR_LIT>', result, exc_info=True)<EOL>usable = False<EOL><DEDENT><DEDENT>if not usable:<EOL><INDENT>result = tempfile.mkdtemp()<EOL>logger.warning('<STR_LIT>', result)<EOL><DEDENT>return os.path.join(result, suffix)<EOL>
Return the default base location for distlib caches. If the directory does
not exist, it is created. Use the suffix provided for the base directory,
and default to '.distlib' if it isn't provided.

On Windows, if LOCALAPPDATA is defined in the environment, then it is
assumed to be a directory, and will be the parent directory of the result.
On POSIX, and on Windows if LOCALAPPDATA is not defined, the user's home
directory - using os.expanduser('~') - will be the parent directory of
the result.

The result is just the directory '.distlib' in the parent directory as
determined above, or with the name specified with ``suffix``.