Skip to content

Commit d83b1bd

Browse files
committed
Remove dependency on pywin32 as ctypes should always be available
1 parent b261954 commit d83b1bd

File tree

1 file changed

+3
-35
lines changed

1 file changed

+3
-35
lines changed

pip/utils/appdirs.py

Lines changed: 3 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@
77
import os
88
import sys
99

10-
from pip._vendor import six
1110
from pip.compat import WINDOWS
1211

1312

@@ -225,33 +224,6 @@ def _get_win_folder_from_registry(csidl_name):
225224
return directory
226225

227226

228-
def _get_win_folder_with_pywin32(csidl_name):
229-
from win32com.shell import shellcon, shell
230-
directory = shell.SHGetFolderPath(0, getattr(shellcon, csidl_name), 0, 0)
231-
# Try to make this a unicode path because SHGetFolderPath does
232-
# not return unicode strings when there is unicode data in the
233-
# path.
234-
try:
235-
directory = six.text_type(directory)
236-
237-
# Downgrade to short path name if have highbit chars. See
238-
# <http://bugs.activestate.com/show_bug.cgi?id=85099>.
239-
has_high_char = False
240-
for c in directory:
241-
if ord(c) > 255:
242-
has_high_char = True
243-
break
244-
if has_high_char:
245-
try:
246-
import win32api
247-
directory = win32api.GetShortPathName(directory)
248-
except ImportError:
249-
pass
250-
except UnicodeError:
251-
pass
252-
return directory
253-
254-
255227
def _get_win_folder_with_ctypes(csidl_name):
256228
csidl_const = {
257229
"CSIDL_APPDATA": 26,
@@ -278,11 +250,7 @@ def _get_win_folder_with_ctypes(csidl_name):
278250

279251
if WINDOWS:
280252
try:
281-
import win32com.shell # noqa
282-
_get_win_folder = _get_win_folder_with_pywin32
253+
import ctypes
254+
_get_win_folder = _get_win_folder_with_ctypes
283255
except ImportError:
284-
try:
285-
import ctypes
286-
_get_win_folder = _get_win_folder_with_ctypes
287-
except ImportError:
288-
_get_win_folder = _get_win_folder_from_registry
256+
_get_win_folder = _get_win_folder_from_registry

0 commit comments

Comments
 (0)