]> jfr.im git - dlqueue.git/blob - venv/lib/python3.11/site-packages/pip/_internal/utils/appdirs.py
init: venv aand flask
[dlqueue.git] / venv / lib / python3.11 / site-packages / pip / _internal / utils / appdirs.py
1 """
2 This code wraps the vendored appdirs module to so the return values are
3 compatible for the current pip code base.
4
5 The intention is to rewrite current usages gradually, keeping the tests pass,
6 and eventually drop this after all usages are changed.
7 """
8
9 import os
10 import sys
11 from typing import List
12
13 from pip._vendor import platformdirs as _appdirs
14
15
16 def user_cache_dir(appname: str) -> str:
17 return _appdirs.user_cache_dir(appname, appauthor=False)
18
19
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):
24 return path
25
26 # Use a Linux-like ~/.config/pip, by default.
27 linux_like_path = "~/.config/"
28 if appname:
29 linux_like_path = os.path.join(linux_like_path, appname)
30
31 return os.path.expanduser(linux_like_path)
32
33
34 def user_config_dir(appname: str, roaming: bool = True) -> str:
35 if sys.platform == "darwin":
36 return _macos_user_config_dir(appname, roaming)
37
38 return _appdirs.user_config_dir(appname, appauthor=False, roaming=roaming)
39
40
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)]
46
47 dirval = _appdirs.site_config_dir(appname, appauthor=False, multipath=True)
48 if sys.platform == "win32":
49 return [dirval]
50
51 # Unix-y system. Look in /etc as well.
52 return dirval.split(os.pathsep) + ["/etc"]