11diff --git a/src/pip/_vendor/appdirs.py b/src/pip/_vendor/appdirs.py
2- index ae67001a..87a1e0a6 100644
2+ index ae67001a..3a52b758 100644
33--- a/src/pip/_vendor/appdirs.py
44+++ b/src/pip/_vendor/appdirs.py
55@@ -37,6 +37,10 @@ if sys.platform.startswith('java'):
@@ -12,10 +12,10 @@ index ae67001a..87a1e0a6 100644
1212+ system = 'win32'
1313 else:
1414 system = sys.platform
15-
15+
1616@@ -64,7 +68,7 @@ def user_data_dir(appname=None, appauthor=None, version=None, roaming=False):
1717 for a discussion of issues.
18-
18+
1919 Typical user data directories are:
2020- Mac OS X: ~/Library/Application Support/<AppName>
2121+ Mac OS X: ~/Library/Application Support/<AppName> # or ~/.config/<AppName>, if the other does not exist
@@ -39,23 +39,29 @@ index ae67001a..87a1e0a6 100644
3939 appname = os.path.join(appname, version)
4040- pathlist = [os.sep.join([x, appname]) for x in pathlist]
4141+ pathlist = [os.path.join(x, appname) for x in pathlist]
42-
42+
4343 if multipath:
4444 path = os.pathsep.join(pathlist)
4545@@ -203,6 +211,8 @@ def user_config_dir(appname=None, appauthor=None, version=None, roaming=False):
4646 return path
47-
48-
47+
48+
4949+ # for the discussion regarding site_config_dir locations
5050+ # see <https://github.com/pypa/pip/issues/1733>
5151 def site_config_dir(appname=None, appauthor=None, version=None, multipath=False):
5252 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>
5661 # only first, if multipath is False
57- path = os.getenv('XDG_CONFIG_DIRS', '/etc/xdg')
62+ - path = os.getenv('XDG_CONFIG_DIRS', '/etc/xdg')
5863- 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'
5965+ pathlist = [os.path.expanduser(x.rstrip(os.sep)) for x in path.split(os.pathsep) if x]
6066 if appname:
6167 if version:
@@ -64,10 +70,10 @@ index ae67001a..87a1e0a6 100644
6470+ pathlist = [os.path.join(x, appname) for x in pathlist]
6571+ # always look in /etc directly as well
6672+ pathlist.append('/etc')
67-
73+
6874 if multipath:
6975 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):
7177 if appauthor is None:
7278 appauthor = appname
7379 path = os.path.normpath(_get_win_folder("CSIDL_LOCAL_APPDATA"))
@@ -78,8 +84,8 @@ index ae67001a..87a1e0a6 100644
7884 if appname:
7985 if appauthor is not False:
8086 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+
8389 if system == "win32":
8490 try:
8591- import win32com.shell
@@ -117,6 +123,6 @@ index ae67001a..87a1e0a6 100644
117123+ except (UnicodeEncodeError, LookupError):
118124+ pass
119125+ return path
120-
121-
126+
127+
122128 #---- self test code
0 commit comments