Skip to content

Instantly share code, notes, and snippets.

@carlkl
Created June 21, 2016 14:22
Show Gist options
  • Save carlkl/077c6b1d6ca55a6fbe929dd12727a462 to your computer and use it in GitHub Desktop.
Save carlkl/077c6b1d6ca55a6fbe929dd12727a462 to your computer and use it in GitHub Desktop.
def _init_numpy_mkl():
# Numpy+MKL on Windows only
import os
import ctypes
if os.name != 'nt':
return
# disable Intel Fortran default console event handler
env = 'FOR_DISABLE_CONSOLE_CTRL_HANDLER'
if env not in os.environ:
os.environ[env] = '1'
# extend DLL search order with numpy.core
# See https://github.com/numpy/numpy/wiki/windows-dll-notes#python-dlls
# and https://pytools.codeplex.com/workitem/1627
try:
_AddDllDirectory = ctypes.windll.kernel32.AddDllDirectory
_AddDllDirectory.argtypes = [ctypes.c_wchar_p]
# Needed to initialize AddDllDirectory modifications
ctypes.windll.kernel32.SetDefaultDllDirectories(0x1000)
except AttributeError:
_AddDllDirectory = ctypes.windll.kernel32.SetDllDirectoryW
_AddDllDirectory.argtypes = [ctypes.c_wchar_p]
try:
_core = os.path.join(os.path.abspath(os.path.dirname(__file__)), 'core')
_AddDllDirectory(_core)
except Exception:
pass
_init_numpy_mkl()
del _init_numpy_mkl
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment