1
1
diff --git a/src/pip/_vendor/appdirs.py b/src/pip/_vendor/appdirs.py
2
- index ae67001a..87a1e0a6 100644
2
+ index ae67001a..3a52b758 100644
3
3
--- a/src/pip/_vendor/appdirs.py
4
4
+++ b/src/pip/_vendor/appdirs.py
5
5
@@ -37,6 +37,10 @@ if sys.platform.startswith('java'):
@@ -12,10 +12,10 @@ index ae67001a..87a1e0a6 100644
12
12
+ system = 'win32'
13
13
else:
14
14
system = sys.platform
15
-
15
+
16
16
@@ -64,7 +68,7 @@ def user_data_dir(appname=None, appauthor=None, version=None, roaming=False):
17
17
for a discussion of issues.
18
-
18
+
19
19
Typical user data directories are:
20
20
- Mac OS X: ~/Library/Application Support/<AppName>
21
21
+ Mac OS X: ~/Library/Application Support/<AppName> # or ~/.config/<AppName>, if the other does not exist
@@ -39,23 +39,29 @@ index ae67001a..87a1e0a6 100644
39
39
appname = os.path.join(appname, version)
40
40
- pathlist = [os.sep.join([x, appname]) for x in pathlist]
41
41
+ pathlist = [os.path.join(x, appname) for x in pathlist]
42
-
42
+
43
43
if multipath:
44
44
path = os.pathsep.join(pathlist)
45
45
@@ -203,6 +211,8 @@ def user_config_dir(appname=None, appauthor=None, version=None, roaming=False):
46
46
return path
47
-
48
-
47
+
48
+
49
49
+ # for the discussion regarding site_config_dir locations
50
50
+ # see <https://github.com/pypa/pip/issues/1733>
51
51
def site_config_dir(appname=None, appauthor=None, version=None, multipath=False):
52
52
r"""Return full path to the user-shared data dir for this application.
53
-
54
- @@ -241,11 +251,13 @@ def site_config_dir(appname=None, appauthor=None, version=None, multipath=False)
55
- # XDG default for $XDG_CONFIG_DIRS
53
+
54
+ @@ -238,14 +248,17 @@ def site_config_dir(appname=None, appauthor=None, version=None, multipath=False)
55
+ if appname and version:
56
+ path = os.path.join(path, version)
57
+ else:
58
+ - # XDG default for $XDG_CONFIG_DIRS
59
+ + # XDG default for $XDG_CONFIG_DIRS (missing or empty)
60
+ + # see <https://github.com/pypa/pip/pull/7501#discussion_r360624829>
56
61
# only first, if multipath is False
57
- path = os.getenv('XDG_CONFIG_DIRS', '/etc/xdg')
62
+ - path = os.getenv('XDG_CONFIG_DIRS', '/etc/xdg')
58
63
- pathlist = [os.path.expanduser(x.rstrip(os.sep)) for x in path.split(os.pathsep)]
64
+ + path = os.getenv('XDG_CONFIG_DIRS') or '/etc/xdg'
59
65
+ pathlist = [os.path.expanduser(x.rstrip(os.sep)) for x in path.split(os.pathsep) if x]
60
66
if appname:
61
67
if version:
@@ -64,10 +70,10 @@ index ae67001a..87a1e0a6 100644
64
70
+ pathlist = [os.path.join(x, appname) for x in pathlist]
65
71
+ # always look in /etc directly as well
66
72
+ pathlist.append('/etc')
67
-
73
+
68
74
if multipath:
69
75
path = os.pathsep.join(pathlist)
70
- @@ -291,6 +303 ,10 @@ def user_cache_dir(appname=None, appauthor=None, version=None, opinion=True):
76
+ @@ -291,6 +304 ,10 @@ def user_cache_dir(appname=None, appauthor=None, version=None, opinion=True):
71
77
if appauthor is None:
72
78
appauthor = appname
73
79
path = os.path.normpath(_get_win_folder("CSIDL_LOCAL_APPDATA"))
@@ -78,8 +84,8 @@ index ae67001a..87a1e0a6 100644
78
84
if appname:
79
85
if appauthor is not False:
80
86
path = os.path.join(path, appauthor, appname)
81
- @@ -557,18 +573 ,32 @@ def _get_win_folder_with_jna(csidl_name):
82
-
87
+ @@ -557,18 +574 ,32 @@ def _get_win_folder_with_jna(csidl_name):
88
+
83
89
if system == "win32":
84
90
try:
85
91
- import win32com.shell
@@ -117,6 +123,6 @@ index ae67001a..87a1e0a6 100644
117
123
+ except (UnicodeEncodeError, LookupError):
118
124
+ pass
119
125
+ return path
120
-
121
-
126
+
127
+
122
128
#---- self test code
0 commit comments