Skip to content

Commit

Permalink
BUG: distutils: use AddDllDirectory where available
Browse files Browse the repository at this point in the history
This should reduce some DLL hell scenarios, namely scipy/scipy#8064.

partial credits to @carlkl
  • Loading branch information
xoviat authored and hanjohn committed Feb 15, 2018
1 parent 1710b1b commit 1fcb194
Showing 1 changed file with 18 additions and 3 deletions.
21 changes: 18 additions & 3 deletions numpy/distutils/misc_util.py
Original file line number Diff line number Diff line change
Expand Up @@ -2289,10 +2289,25 @@ def generate_config_py(target):

# For gfortran+msvc combination, extra shared libraries may exist
f.write("""
import os
extra_dll_dir = os.path.join(os.path.dirname(__file__), '.libs')
if os.path.isdir(extra_dll_dir):
os.environ["PATH"] += os.pathsep + extra_dll_dir
import sys
extra_dll_dir = os.path.join(os.path.dirname(__file__), 'extra-dll')
if os.path.isdir(extra_dll_dir) and sys.platform == 'win32':
try:
from ctypes import windll, c_wchar_p
_AddDllDirectory = windll.kernel32.AddDllDirectory
_AddDllDirectory.argtypes = [c_wchar_p]
# Needed to initialize AddDllDirectory modifications
windll.kernel32.SetDefaultDllDirectories(0x1000)
except AttributeError:
def _AddDllDirectory(dll_directory):
os.environ["PATH"] += os.pathsep + dll_directory
_AddDllDirectory(extra_dll_dir)
""")

for k, i in system_info.saved_results.items():
Expand Down

0 comments on commit 1fcb194

Please sign in to comment.