Skip to content

Commit

Permalink
Fix DLL search path on Windows with Python 3.8
Browse files Browse the repository at this point in the history
Python 3.8 no longer looks for DLLs in the insecure
search path, i.e. it ignores %PATH%. Add the necessary
directory using os.add_dll_directory() to make this
work again.
  • Loading branch information
benmwebb committed Oct 21, 2019
1 parent 65d912f commit d247202
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions tools/w32/add_search_path.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,9 @@ def _add_pyext_to_path():
# Add DLL directory to PATH so Windows can find them
if dlldir not in os.environ['PATH']:
os.environ['PATH'] = dlldir + ';' + os.environ['PATH']
# Python 3.8 or later don't look in PATH for DLLs
if hasattr(os, 'add_dll_directory'):
__dll_directory = os.add_dll_directory(dlldir)
_add_pyext_to_path()
"""
Expand All @@ -60,6 +63,9 @@ def _add_pyext_to_path():
# Add DLL directory to PATH so Windows can find them
if dlldir not in os.environ['PATH']:
os.environ['PATH'] = dlldir + ';' + os.environ['PATH']
# Python 3.8 or later don't look in PATH for DLLs
if hasattr(os, 'add_dll_directory'):
__dll_directory = os.add_dll_directory(dlldir)
_add_pyext_to_path()
"""
Expand Down

0 comments on commit d247202

Please sign in to comment.