@@ -17,24 +17,36 @@ def user_cache_dir(appname: str) -> str:
17
17
return _appdirs .user_cache_dir (appname , appauthor = False )
18
18
19
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
+
20
34
def user_config_dir (appname : str , roaming : bool = True ) -> str :
21
- path = _appdirs .user_config_dir (appname , appauthor = False , roaming = roaming )
22
- if sys .platform == "darwin" and not os .path .isdir (path ):
23
- path = os .path .expanduser ("~/.config/" )
24
- if appname :
25
- path = os .path .join (path , appname )
26
- return path
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 )
27
39
28
40
29
41
# for the discussion regarding site_config_dir locations
30
42
# see <https://github.com/pypa/pip/issues/1733>
31
43
def site_config_dirs (appname : str ) -> List [str ]:
32
- dirval = _appdirs .site_config_dir (appname , appauthor = False , multipath = True )
33
44
if sys .platform == "darwin" :
34
- # always look in /Library/Application Support/pip as well
35
- return dirval .split (os .pathsep ) + ["/Library/Application Support/pip" ]
36
- elif sys .platform == "win32" :
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" :
37
49
return [dirval ]
38
- else :
39
- # always look in /etc directly as well
40
- return dirval .split (os .pathsep ) + ["/etc" ]
50
+
51
+ # Unix-y system. Look in /etc as well.
52
+ return dirval .split (os .pathsep ) + ["/etc" ]
0 commit comments