Skip to content

Commit 1fcb194

Browse files
xoviathanjohn
authored andcommitted
BUG: distutils: use AddDllDirectory where available
This should reduce some DLL hell scenarios, namely scipy/scipy#8064. partial credits to @carlkl
1 parent 1710b1b commit 1fcb194

File tree

1 file changed

+18
-3
lines changed

1 file changed

+18
-3
lines changed

numpy/distutils/misc_util.py

Lines changed: 18 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2289,10 +2289,25 @@ def generate_config_py(target):
22892289

22902290
# For gfortran+msvc combination, extra shared libraries may exist
22912291
f.write("""
2292+
22922293
import os
2293-
extra_dll_dir = os.path.join(os.path.dirname(__file__), '.libs')
2294-
if os.path.isdir(extra_dll_dir):
2295-
os.environ["PATH"] += os.pathsep + extra_dll_dir
2294+
import sys
2295+
2296+
extra_dll_dir = os.path.join(os.path.dirname(__file__), 'extra-dll')
2297+
2298+
if os.path.isdir(extra_dll_dir) and sys.platform == 'win32':
2299+
try:
2300+
from ctypes import windll, c_wchar_p
2301+
_AddDllDirectory = windll.kernel32.AddDllDirectory
2302+
_AddDllDirectory.argtypes = [c_wchar_p]
2303+
# Needed to initialize AddDllDirectory modifications
2304+
windll.kernel32.SetDefaultDllDirectories(0x1000)
2305+
except AttributeError:
2306+
def _AddDllDirectory(dll_directory):
2307+
os.environ["PATH"] += os.pathsep + dll_directory
2308+
2309+
_AddDllDirectory(extra_dll_dir)
2310+
22962311
""")
22972312

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

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy