Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 8 additions & 13 deletions win32/Lib/pywintypes.py
Original file line number Diff line number Diff line change
Expand Up @@ -87,23 +87,18 @@ def __import_pywin32_system_module__(modname, globs):
# In a worst-case, it means, say 'python -c "import win32api"'
# will not work but 'python -c "import pywintypes, win32api"' will,
# but it's better than nothing.
# We prefer the "user" site-packages if it exists...
if found is None:
import site

maybe = os.path.join(site.USER_SITE, "pywin32_system32", filename)
if os.path.isfile(maybe):
found = maybe
# We use the same logic as pywin32_bootstrap to find potential location for the dll
# Simply import pywin32_system32 and look in the paths in pywin32_system32.__path__

# Or the "global" site-packages.
if found is None:
import sysconfig
import pywin32_system32

maybe = os.path.join(
sysconfig.get_paths()["platlib"], "pywin32_system32", filename
)
if os.path.isfile(maybe):
found = maybe
for path in pywin32_system32.__path__:
maybe = os.path.join(path, filename)
if os.path.isfile(maybe):
found = maybe
break

if found is None:
# give up in disgust.
Expand Down