Skip to content

Commit d841e17

Browse files
committed
Make appdirs detect IronPython Windows
1 parent 2ccc5c0 commit d841e17

File tree

2 files changed

+32
-17
lines changed

2 files changed

+32
-17
lines changed

src/pip/_vendor/appdirs.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,10 @@
3737
# are actually checked for and the rest of the module expects
3838
# *sys.platform* style strings.
3939
system = 'linux2'
40+
elif sys.platform == 'cli' and os.name == 'nt':
41+
# Detect Windows in IronPython to match pip._internal.utils.compat.WINDOWS
42+
# Discusstion: https://github.com/pypa/pip/pull/7501
43+
system = 'win32'
4044
else:
4145
system = sys.platform
4246

tools/automation/vendoring/patches/appdirs.patch

Lines changed: 28 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,28 @@
11
diff --git a/src/pip/_vendor/appdirs.py b/src/pip/_vendor/appdirs.py
2-
index ae67001a..e9ff1aa4 100644
2+
index ae67001a..87a1e0a6 100644
33
--- a/src/pip/_vendor/appdirs.py
44
+++ b/src/pip/_vendor/appdirs.py
5-
@@ -64,7 +64,7 @@ def user_data_dir(appname=None, appauthor=None, version=None, roaming=False):
5+
@@ -37,6 +37,10 @@ if sys.platform.startswith('java'):
6+
# are actually checked for and the rest of the module expects
7+
# *sys.platform* style strings.
8+
system = 'linux2'
9+
+elif sys.platform == 'cli' and os.name == 'nt':
10+
+ # Detect Windows in IronPython to match pip._internal.utils.compat.WINDOWS
11+
+ # Discusstion: https://github.com/pypa/pip/pull/7501
12+
+ system = 'win32'
13+
else:
14+
system = sys.platform
15+
16+
@@ -64,7 +68,7 @@ def user_data_dir(appname=None, appauthor=None, version=None, roaming=False):
617
for a discussion of issues.
7-
18+
819
Typical user data directories are:
920
- Mac OS X: ~/Library/Application Support/<AppName>
1021
+ Mac OS X: ~/Library/Application Support/<AppName> # or ~/.config/<AppName>, if the other does not exist
1122
Unix: ~/.local/share/<AppName> # or in $XDG_DATA_HOME, if defined
1223
Win XP (not roaming): C:\Documents and Settings\<username>\Application Data\<AppAuthor>\<AppName>
1324
Win XP (roaming): C:\Documents and Settings\<username>\Local Settings\Application Data\<AppAuthor>\<AppName>
14-
@@ -88,6 +88,10 @@ def user_data_dir(appname=None, appauthor=None, version=None, roaming=False):
25+
@@ -88,6 +92,10 @@ def user_data_dir(appname=None, appauthor=None, version=None, roaming=False):
1526
path = os.path.expanduser('~/Library/Application Support/')
1627
if appname:
1728
path = os.path.join(path, appname)
@@ -22,25 +33,25 @@ index ae67001a..e9ff1aa4 100644
2233
else:
2334
path = os.getenv('XDG_DATA_HOME', os.path.expanduser("~/.local/share"))
2435
if appname:
25-
@@ -150,7 +154,7 @@ def site_data_dir(appname=None, appauthor=None, version=None, multipath=False):
36+
@@ -150,7 +158,7 @@ def site_data_dir(appname=None, appauthor=None, version=None, multipath=False):
2637
if appname:
2738
if version:
2839
appname = os.path.join(appname, version)
2940
- pathlist = [os.sep.join([x, appname]) for x in pathlist]
3041
+ pathlist = [os.path.join(x, appname) for x in pathlist]
31-
42+
3243
if multipath:
3344
path = os.pathsep.join(pathlist)
34-
@@ -203,6 +207,8 @@ def user_config_dir(appname=None, appauthor=None, version=None, roaming=False):
45+
@@ -203,6 +211,8 @@ def user_config_dir(appname=None, appauthor=None, version=None, roaming=False):
3546
return path
36-
37-
47+
48+
3849
+# for the discussion regarding site_config_dir locations
3950
+# see <https://github.com/pypa/pip/issues/1733>
4051
def site_config_dir(appname=None, appauthor=None, version=None, multipath=False):
4152
r"""Return full path to the user-shared data dir for this application.
42-
43-
@@ -241,11 +247,13 @@ def site_config_dir(appname=None, appauthor=None, version=None, multipath=False)
53+
54+
@@ -241,11 +251,13 @@ def site_config_dir(appname=None, appauthor=None, version=None, multipath=False)
4455
# XDG default for $XDG_CONFIG_DIRS
4556
# only first, if multipath is False
4657
path = os.getenv('XDG_CONFIG_DIRS', '/etc/xdg')
@@ -53,10 +64,10 @@ index ae67001a..e9ff1aa4 100644
5364
+ pathlist = [os.path.join(x, appname) for x in pathlist]
5465
+ # always look in /etc directly as well
5566
+ pathlist.append('/etc')
56-
67+
5768
if multipath:
5869
path = os.pathsep.join(pathlist)
59-
@@ -291,6 +299,10 @@ def user_cache_dir(appname=None, appauthor=None, version=None, opinion=True):
70+
@@ -291,6 +303,10 @@ def user_cache_dir(appname=None, appauthor=None, version=None, opinion=True):
6071
if appauthor is None:
6172
appauthor = appname
6273
path = os.path.normpath(_get_win_folder("CSIDL_LOCAL_APPDATA"))
@@ -67,8 +78,8 @@ index ae67001a..e9ff1aa4 100644
6778
if appname:
6879
if appauthor is not False:
6980
path = os.path.join(path, appauthor, appname)
70-
@@ -557,18 +569,32 @@ def _get_win_folder_with_jna(csidl_name):
71-
81+
@@ -557,18 +573,32 @@ def _get_win_folder_with_jna(csidl_name):
82+
7283
if system == "win32":
7384
try:
7485
- import win32com.shell
@@ -106,6 +117,6 @@ index ae67001a..e9ff1aa4 100644
106117
+ except (UnicodeEncodeError, LookupError):
107118
+ pass
108119
+ return path
109-
110-
120+
121+
111122
#---- self test code

0 commit comments

Comments
 (0)