]>
jfr.im git - dlqueue.git/blob - venv/lib/python3.11/site-packages/pip/_internal/utils/appdirs.py
2 This code wraps the vendored appdirs module to so the return values are
3 compatible for the current pip code base.
5 The intention is to rewrite current usages gradually, keeping the tests pass,
6 and eventually drop this after all usages are changed.
11 from typing
import List
13 from pip
._vendor
import platformdirs
as _appdirs
16 def user_cache_dir(appname
: str) -> str:
17 return _appdirs
.user_cache_dir(appname
, appauthor
=False)
20 def _macos_user_config_dir(appname
: str, roaming
: bool = True) -> str:
21 # Use ~/Application Support/pip, if the directory exists.
22 path
= _appdirs
.user_data_dir(appname
, appauthor
=False, roaming
=roaming
)
23 if os
.path
.isdir(path
):
26 # Use a Linux-like ~/.config/pip, by default.
27 linux_like_path
= "~/.config/"
29 linux_like_path
= os
.path
.join(linux_like_path
, appname
)
31 return os
.path
.expanduser(linux_like_path
)
34 def user_config_dir(appname
: str, roaming
: bool = True) -> str:
35 if sys
.platform
== "darwin":
36 return _macos_user_config_dir(appname
, roaming
)
38 return _appdirs
.user_config_dir(appname
, appauthor
=False, roaming
=roaming
)
41 # for the discussion regarding site_config_dir locations
42 # see <https://github.com/pypa/pip/issues/1733>
43 def site_config_dirs(appname
: str) -> List
[str]:
44 if sys
.platform
== "darwin":
45 return [_appdirs
.site_data_dir(appname
, appauthor
=False, multipath
=True)]
47 dirval
= _appdirs
.site_config_dir(appname
, appauthor
=False, multipath
=True)
48 if sys
.platform
== "win32":
51 # Unix-y system. Look in /etc as well.
52 return dirval
.split(os
.pathsep
) + ["/etc"]