summaryrefslogtreecommitdiff
path: root/numpy/distutils/system_info.py
diff options
context:
space:
mode:
Diffstat (limited to 'numpy/distutils/system_info.py')
-rw-r--r--numpy/distutils/system_info.py65
1 files changed, 65 insertions, 0 deletions
diff --git a/numpy/distutils/system_info.py b/numpy/distutils/system_info.py
index 2c1103d27..05eedfd3f 100644
--- a/numpy/distutils/system_info.py
+++ b/numpy/distutils/system_info.py
@@ -126,6 +126,7 @@ import os
import re
import copy
import warnings
+import atexit
from glob import glob
from functools import reduce
if sys.version_info[0] < 3:
@@ -469,6 +470,8 @@ class system_info(object):
verbosity = 1
saved_results = {}
+ shared_libs = set()
+
notfounderror = NotFoundError
def __init__(self,
@@ -1766,10 +1769,70 @@ class openblas_lapack_info(openblas_info):
_lib_names = ['openblas']
notfounderror = BlasNotFoundError
+ def create_msvc_openblas_lib(self, info):
+ from numpy.distutils.fcompiler import new_fcompiler
+
+ try:
+ c = distutils.ccompiler.new_compiler()
+ if c.compiler_type != "msvc":
+ return False
+
+ f = new_fcompiler(compiler="gnu95", c_compiler=c)
+ f.customize('')
+
+ libraries=info['libraries']
+ library_dirs=info['library_dirs']
+
+ # For each gfortran-compatible static library,
+ # we need to generate a dynamic library with
+ # no dependencies.
+
+ # First, find the full path to each library directory
+ library_paths = []
+ for library in libraries:
+ for library_dir in library_dirs:
+ # MinGW static ext will be .a
+ fullpath = os.path.join(library_dir, library + '.a')
+ if os.path.isfile(fullpath):
+ library_paths.append(fullpath)
+ break
+ else:
+ return False
+
+
+ tmpdir = tempfile.mkdtemp()
+ # Next, convert each library to MSVC format
+ for library, library_path in zip(libraries, library_paths):
+ mingw_lib = os.path.join(tmpdir, 'lib'+library+'.a')
+ shutil.copy(library_path, mingw_lib)
+ msvc_lib = f.link_wrapper_lib(['-Wl,--whole-archive',
+ mingw_lib,
+ '-Wl,--no-whole-archive',
+ ],
+ output_dir=tmpdir)
+
+ msvc_lib_path = library + '.lib'
+
+ # Now copy
+ print('copying ' + msvc_lib + ' -> ' + msvc_lib_path)
+ shutil.copy(msvc_lib, msvc_lib_path)
+
+ atexit.register(os.remove, msvc_lib_path)
+
+ system_info.shared_libs.add('')
+
+ return True
+ except:
+ return False
+
def check_embedded_lapack(self, info):
res = False
c = distutils.ccompiler.new_compiler()
c.customize('')
+
+ if c.compiler_type == "msvc" and not self.create_msvc_openblas_lib(info):
+ return False
+
tmpdir = tempfile.mkdtemp()
s = """void zungqr();
int main(int argc, const char *argv[])
@@ -1784,6 +1847,8 @@ class openblas_lapack_info(openblas_info):
extra_args = info['extra_link_args']
except Exception:
extra_args = []
+ if sys.version_info < (3, 5) and sys.version_info > (3, 0) and c.compiler_type == "msvc":
+ extra_args.append("/MANIFEST")
try:
with open(src, 'wt') as f:
f.write(s)