forked from matthew-brett/manylinux-builds
-
Notifications
You must be signed in to change notification settings - Fork 0
/
openblas_1.8.1.patch
109 lines (101 loc) · 3.74 KB
/
openblas_1.8.1.patch
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
diff --git a/numpy/distutils/system_info.py b/numpy/distutils/system_info.py
index fbdd164..48c92c5 100644
--- a/numpy/distutils/system_info.py
+++ b/numpy/distutils/system_info.py
@@ -137,6 +137,9 @@ from numpy.distutils.misc_util import is_sequence, is_string, \
get_shared_lib_extension
from numpy.distutils.command.config import config as cmd_config
from numpy.distutils.compat import get_exception
+import distutils.ccompiler
+import tempfile
+import shutil
# Determine number of bits
@@ -271,7 +274,7 @@ def get_standard_file(fname):
# Home directory
# And look for the user config file
try:
- f = os.environ['HOME']
+ f = os.path.expanduser('~')
except KeyError:
pass
else:
@@ -300,7 +303,10 @@ def get_info(name, notfound_action=0):
'lapack_atlas': lapack_atlas_info, # use lapack_opt instead
'lapack_atlas_threads': lapack_atlas_threads_info, # ditto
'mkl': mkl_info,
+ # openblas which may or may not have embedded lapack
'openblas': openblas_info, # use blas_opt instead
+ # openblas with embedded lapack
+ 'openblas_lapack': openblas_lapack_info, # use blas_opt instead
'lapack_mkl': lapack_mkl_info, # use lapack_opt instead
'blas_mkl': blas_mkl_info, # use blas_opt instead
'x11': x11_info,
@@ -449,7 +455,6 @@ class system_info:
self.__class__.info = {}
self.local_prefixes = []
defaults = {}
- defaults['libraries'] = ''
defaults['library_dirs'] = os.pathsep.join(default_lib_dirs)
defaults['include_dirs'] = os.pathsep.join(default_include_dirs)
defaults['src_dirs'] = os.pathsep.join(default_src_dirs)
@@ -1368,7 +1373,7 @@ class lapack_opt_info(system_info):
def calc_info(self):
- openblas_info = get_info('openblas')
+ openblas_info = get_info('openblas_lapack')
if openblas_info:
self.set_info(**openblas_info)
return
@@ -1561,6 +1566,9 @@ class openblas_info(blas_info):
_lib_names = ['openblas']
notfounderror = BlasNotFoundError
+ def check_embedded_lapack(self, info):
+ return True
+
def calc_info(self):
lib_dirs = self.get_lib_dirs()
@@ -1570,10 +1578,47 @@ class openblas_info(blas_info):
info = self.check_libs(lib_dirs, openblas_libs, [])
if info is None:
return
+
+ if not self.check_embedded_lapack(info):
+ return None
+
info['language'] = 'f77' # XXX: is it generally true?
self.set_info(**info)
+class openblas_lapack_info(openblas_info):
+ section = 'openblas'
+ dir_env_var = 'OPENBLAS'
+ _lib_names = ['openblas']
+ notfounderror = BlasNotFoundError
+
+ def check_embedded_lapack(self, info):
+ res = False
+ c = distutils.ccompiler.new_compiler()
+ tmpdir = tempfile.mkdtemp()
+ s = """void zungqr();
+ int main(int argc, const char *argv[])
+ {
+ zungqr_();
+ return 0;
+ }"""
+ src = os.path.join(tmpdir, 'source.c')
+ out = os.path.join(tmpdir, 'a.out')
+ try:
+ with open(src, 'wt') as f:
+ f.write(s)
+ obj = c.compile([src], output_dir=tmpdir)
+ try:
+ c.link_executable(obj, out, libraries=info['libraries'],
+ library_dirs=info['library_dirs'])
+ res = True
+ except distutils.ccompiler.LinkError:
+ res = False
+ finally:
+ shutil.rmtree(tmpdir)
+ return res
+
+
class blas_src_info(system_info):
section = 'blas_src'
dir_env_var = 'BLAS_SRC'