diff options
author | Charles Harris <charlesr.harris@gmail.com> | 2019-06-26 10:09:55 -0700 |
---|---|---|
committer | GitHub <noreply@github.com> | 2019-06-26 10:09:55 -0700 |
commit | 880651c846f7fe901c279c93e06c470b68e95902 (patch) | |
tree | 263c4fc3598b41303937249939a98e5750313c04 /tools/openblas_support.py | |
parent | 34224c13a17c3f6f720c5eb2b953ebb3ad6b9f4a (diff) | |
parent | 5e687255f5d10e11e39a818c2fcefb65e4952807 (diff) | |
download | numpy-880651c846f7fe901c279c93e06c470b68e95902.tar.gz |
Merge pull request #13772 from mattip/windll
BUILD: use numpy-wheels/openblas_support.py to create _distributor_init.py
Diffstat (limited to 'tools/openblas_support.py')
-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) + """)) + |