From d83b1bd204eb5239adb51e9cb1f13f43d5d1d47f Mon Sep 17 00:00:00 2001 From: Paul Moore Date: Mon, 2 Mar 2015 10:06:55 +0000 Subject: [PATCH] Remove dependency on pywin32 as ctypes should always be available --- pip/utils/appdirs.py | 38 +++----------------------------------- 1 file changed, 3 insertions(+), 35 deletions(-) diff --git a/pip/utils/appdirs.py b/pip/utils/appdirs.py index 4ecc1979c9b..d9100702084 100644 --- a/pip/utils/appdirs.py +++ b/pip/utils/appdirs.py @@ -7,7 +7,6 @@ import os import sys -from pip._vendor import six from pip.compat import WINDOWS @@ -225,33 +224,6 @@ def _get_win_folder_from_registry(csidl_name): return directory -def _get_win_folder_with_pywin32(csidl_name): - from win32com.shell import shellcon, shell - directory = shell.SHGetFolderPath(0, getattr(shellcon, csidl_name), 0, 0) - # Try to make this a unicode path because SHGetFolderPath does - # not return unicode strings when there is unicode data in the - # path. - try: - directory = six.text_type(directory) - - # Downgrade to short path name if have highbit chars. See - # . - has_high_char = False - for c in directory: - if ord(c) > 255: - has_high_char = True - break - if has_high_char: - try: - import win32api - directory = win32api.GetShortPathName(directory) - except ImportError: - pass - except UnicodeError: - pass - return directory - - def _get_win_folder_with_ctypes(csidl_name): csidl_const = { "CSIDL_APPDATA": 26, @@ -278,11 +250,7 @@ def _get_win_folder_with_ctypes(csidl_name): if WINDOWS: try: - import win32com.shell # noqa - _get_win_folder = _get_win_folder_with_pywin32 + import ctypes + _get_win_folder = _get_win_folder_with_ctypes except ImportError: - try: - import ctypes - _get_win_folder = _get_win_folder_with_ctypes - except ImportError: - _get_win_folder = _get_win_folder_from_registry + _get_win_folder = _get_win_folder_from_registry