mirror of https://github.com/pypa/pip
Make appdirs detect IronPython Windows
This commit is contained in:
parent
2ccc5c055d
commit
f6afa1a154
|
@ -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: <https://github.com/pypa/pip/pull/7501>
|
||||
system = 'win32'
|
||||
else:
|
||||
system = sys.platform
|
||||
|
||||
|
|
|
@ -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: <https://github.com/pypa/pip/pull/7501>
|
||||
+ 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/<AppName>
|
||||
+ Mac OS X: ~/Library/Application Support/<AppName> # or ~/.config/<AppName>, if the other does not exist
|
||||
Unix: ~/.local/share/<AppName> # or in $XDG_DATA_HOME, if defined
|
||||
Win XP (not roaming): C:\Documents and Settings\<username>\Application Data\<AppAuthor>\<AppName>
|
||||
Win XP (roaming): C:\Documents and Settings\<username>\Local Settings\Application Data\<AppAuthor>\<AppName>
|
||||
@@ -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 <https://github.com/pypa/pip/issues/1733>
|
||||
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
|
||||
|
|
Loading…
Reference in New Issue