From f6afa1a15423566c7e16ce8de97e32bdc9b8843d Mon Sep 17 00:00:00 2001 From: Tzu-ping Chung Date: Fri, 20 Dec 2019 15:21:34 +0800 Subject: [PATCH] Make appdirs detect IronPython Windows --- src/pip/_vendor/appdirs.py | 4 ++ .../vendoring/patches/appdirs.patch | 45 ++++++++++++------- 2 files changed, 32 insertions(+), 17 deletions(-) diff --git a/src/pip/_vendor/appdirs.py b/src/pip/_vendor/appdirs.py index e9ff1aa4f..c3db25de3 100644 --- a/src/pip/_vendor/appdirs.py +++ b/src/pip/_vendor/appdirs.py @@ -37,6 +37,10 @@ if sys.platform.startswith('java'): # are actually checked for and the rest of the module expects # *sys.platform* style strings. system = 'linux2' +elif sys.platform == 'cli' and os.name == 'nt': + # Detect Windows in IronPython to match pip._internal.utils.compat.WINDOWS + # Discussion: + system = 'win32' else: system = sys.platform diff --git a/tools/automation/vendoring/patches/appdirs.patch b/tools/automation/vendoring/patches/appdirs.patch index 6c6f37b45..1c8d087af 100644 --- a/tools/automation/vendoring/patches/appdirs.patch +++ b/tools/automation/vendoring/patches/appdirs.patch @@ -1,17 +1,28 @@ diff --git a/src/pip/_vendor/appdirs.py b/src/pip/_vendor/appdirs.py -index ae67001a..e9ff1aa4 100644 +index ae67001a..87a1e0a6 100644 --- a/src/pip/_vendor/appdirs.py +++ b/src/pip/_vendor/appdirs.py -@@ -64,7 +64,7 @@ def user_data_dir(appname=None, appauthor=None, version=None, roaming=False): +@@ -37,6 +37,10 @@ if sys.platform.startswith('java'): + # are actually checked for and the rest of the module expects + # *sys.platform* style strings. + system = 'linux2' ++elif sys.platform == 'cli' and os.name == 'nt': ++ # Detect Windows in IronPython to match pip._internal.utils.compat.WINDOWS ++ # Discussion: ++ system = 'win32' + else: + system = sys.platform + +@@ -64,7 +68,7 @@ def user_data_dir(appname=None, appauthor=None, version=None, roaming=False): for a discussion of issues. - + Typical user data directories are: - Mac OS X: ~/Library/Application Support/ + Mac OS X: ~/Library/Application Support/ # or ~/.config/, if the other does not exist Unix: ~/.local/share/ # or in $XDG_DATA_HOME, if defined Win XP (not roaming): C:\Documents and Settings\\Application Data\\ Win XP (roaming): C:\Documents and Settings\\Local Settings\Application Data\\ -@@ -88,6 +88,10 @@ def user_data_dir(appname=None, appauthor=None, version=None, roaming=False): +@@ -88,6 +92,10 @@ def user_data_dir(appname=None, appauthor=None, version=None, roaming=False): path = os.path.expanduser('~/Library/Application Support/') if appname: path = os.path.join(path, appname) @@ -22,25 +33,25 @@ index ae67001a..e9ff1aa4 100644 else: path = os.getenv('XDG_DATA_HOME', os.path.expanduser("~/.local/share")) if appname: -@@ -150,7 +154,7 @@ def site_data_dir(appname=None, appauthor=None, version=None, multipath=False): +@@ -150,7 +158,7 @@ def site_data_dir(appname=None, appauthor=None, version=None, multipath=False): if appname: if version: appname = os.path.join(appname, version) - pathlist = [os.sep.join([x, appname]) for x in pathlist] + pathlist = [os.path.join(x, appname) for x in pathlist] - + if multipath: path = os.pathsep.join(pathlist) -@@ -203,6 +207,8 @@ def user_config_dir(appname=None, appauthor=None, version=None, roaming=False): +@@ -203,6 +211,8 @@ def user_config_dir(appname=None, appauthor=None, version=None, roaming=False): return path - - + + +# for the discussion regarding site_config_dir locations +# see def site_config_dir(appname=None, appauthor=None, version=None, multipath=False): r"""Return full path to the user-shared data dir for this application. - -@@ -241,11 +247,13 @@ def site_config_dir(appname=None, appauthor=None, version=None, multipath=False) + +@@ -241,11 +251,13 @@ def site_config_dir(appname=None, appauthor=None, version=None, multipath=False) # XDG default for $XDG_CONFIG_DIRS # only first, if multipath is False path = os.getenv('XDG_CONFIG_DIRS', '/etc/xdg') @@ -53,10 +64,10 @@ index ae67001a..e9ff1aa4 100644 + pathlist = [os.path.join(x, appname) for x in pathlist] + # always look in /etc directly as well + pathlist.append('/etc') - + if multipath: path = os.pathsep.join(pathlist) -@@ -291,6 +299,10 @@ def user_cache_dir(appname=None, appauthor=None, version=None, opinion=True): +@@ -291,6 +303,10 @@ def user_cache_dir(appname=None, appauthor=None, version=None, opinion=True): if appauthor is None: appauthor = appname path = os.path.normpath(_get_win_folder("CSIDL_LOCAL_APPDATA")) @@ -67,8 +78,8 @@ index ae67001a..e9ff1aa4 100644 if appname: if appauthor is not False: path = os.path.join(path, appauthor, appname) -@@ -557,18 +569,32 @@ def _get_win_folder_with_jna(csidl_name): - +@@ -557,18 +573,32 @@ def _get_win_folder_with_jna(csidl_name): + if system == "win32": try: - import win32com.shell @@ -106,6 +117,6 @@ index ae67001a..e9ff1aa4 100644 + except (UnicodeEncodeError, LookupError): + pass + return path - - + + #---- self test code