-
Notifications
You must be signed in to change notification settings - Fork 798
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Change how the directory with the pywin32 DLLs is treated at startup.
This directory is now added to the start of PATH for version 3.7 and earlier, and passed to os.add_dll_directory() on 3.8 and later. This will hopefully work around problems loading pywintypes.dll in various situations. Fixes #1432, fixes #1431
- Loading branch information
Showing
3 changed files
with
29 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
# Imported by pywin32.pth to bootstrap the pywin32 environment in "portable" | ||
# environments or any other case where the post-install script isn't run. | ||
# | ||
# In short, there's a directory installed by pywin32 named 'pywin32_system32' | ||
# with some important DLLs which need to be found by Python when some pywin32 | ||
# modules are imported. | ||
# If Python has `os.add_dll_directory()`, we need to call it with this path. | ||
# Otherwise, we add this path to PATH. | ||
import os | ||
import site | ||
import sys | ||
|
||
# The directory should be installed under site-packages. | ||
for maybe in site.getsitepackages(): | ||
pywin32_system32=os.path.join(maybe,"pywin32_system32") | ||
if os.path.isdir(pywin32_system32): | ||
if hasattr(os, "add_dll_directory"): | ||
os.add_dll_directory(pywin32_system32) | ||
else: | ||
os.environ["PATH"] = pywin32_system32 + ";" + os.environ["PATH"] | ||
|