Path: blob/main/test/lib/python3.9/site-packages/pip/_internal/utils/appdirs.py
4804 views
"""1This code wraps the vendored appdirs module to so the return values are2compatible for the current pip code base.34The intention is to rewrite current usages gradually, keeping the tests pass,5and eventually drop this after all usages are changed.6"""78import os9import sys10from typing import List1112from pip._vendor import platformdirs as _appdirs131415def user_cache_dir(appname: str) -> str:16return _appdirs.user_cache_dir(appname, appauthor=False)171819def _macos_user_config_dir(appname: str, roaming: bool = True) -> str:20# Use ~/Application Support/pip, if the directory exists.21path = _appdirs.user_data_dir(appname, appauthor=False, roaming=roaming)22if os.path.isdir(path):23return path2425# Use a Linux-like ~/.config/pip, by default.26linux_like_path = "~/.config/"27if appname:28linux_like_path = os.path.join(linux_like_path, appname)2930return os.path.expanduser(linux_like_path)313233def user_config_dir(appname: str, roaming: bool = True) -> str:34if sys.platform == "darwin":35return _macos_user_config_dir(appname, roaming)3637return _appdirs.user_config_dir(appname, appauthor=False, roaming=roaming)383940# for the discussion regarding site_config_dir locations41# see <https://github.com/pypa/pip/issues/1733>42def site_config_dirs(appname: str) -> List[str]:43if sys.platform == "darwin":44return [_appdirs.site_data_dir(appname, appauthor=False, multipath=True)]4546dirval = _appdirs.site_config_dir(appname, appauthor=False, multipath=True)47if sys.platform == "win32":48return [dirval]4950# Unix-y system. Look in /etc as well.51return dirval.split(os.pathsep) + ["/etc"]525354