diff options
author | mattip <matti.picus@gmail.com> | 2019-06-20 13:51:07 +0300 |
---|---|---|
committer | mattip <matti.picus@gmail.com> | 2019-06-20 13:51:07 +0300 |
commit | 5e687255f5d10e11e39a818c2fcefb65e4952807 (patch) | |
tree | 8058dabe365f22ddccde8342578155814f883813 /tools | |
parent | 9fe7fec9a68c250b462a9cffdcdce185daaa9020 (diff) | |
download | numpy-5e687255f5d10e11e39a818c2fcefb65e4952807.tar.gz |
MAINT: add script to local repo
Diffstat (limited to 'tools')
-rw-r--r-- | tools/openblas_support.py | 42 |
1 files changed, 42 insertions, 0 deletions
diff --git a/tools/openblas_support.py b/tools/openblas_support.py new file mode 100644 index 000000000..52d283a6c --- /dev/null +++ b/tools/openblas_support.py @@ -0,0 +1,42 @@ +import os +import textwrap + +def make_init(dirname): + ''' + Create a _distributor_init.py file for OpenBlas + ''' + with open(os.path.join(dirname, '_distributor_init.py'), 'wt') as fid: + fid.write(textwrap.dedent(""" + ''' + Helper to preload windows dlls to prevent dll not found errors. + Once a DLL is preloaded, its namespace is made available to any + subsequent DLL. This file originated in the numpy-wheels repo, + and is created as part of the scripts that build the wheel. + ''' + import os + from ctypes import WinDLL + import glob + if os.name == 'nt': + # convention for storing / loading the DLL from + # numpy/.libs/, if present + try: + basedir = os.path.dirname(__file__) + except: + pass + else: + libs_dir = os.path.abspath(os.path.join(basedir, '.libs')) + DLL_filenames = [] + if os.path.isdir(libs_dir): + for filename in glob.glob(os.path.join(libs_dir, + '*openblas*dll')): + # NOTE: would it change behavior to load ALL + # DLLs at this path vs. the name restriction? + WinDLL(os.path.abspath(filename)) + DLL_filenames.append(filename) + if len(DLL_filenames) > 1: + import warnings + warnings.warn("loaded more than 1 DLL from .libs:\\n%s" % + "\\n".join(DLL_filenames), + stacklevel=1) + """)) + |