Repository: numpy/numpy

Issue:
include this patch for building with openblas?
Maybe I'm going about it the wrong way, but I have to apply this patch each time I want to be able to build numpy with openblas. Is there a reason not to add it to numpy distutils?

https://github.com/akesandgren/numpy/commit/363339dd3a9826f3e3e7dc4248c258d3c4dfcd7c

I can then build fine with this in `site.cfg`

```
[openblas]
libraries = openblas

[lapack_opt]
libraries = openblas
```



Discussion:
Don't think so, something like this should be added. It was submitted as gh-3163 but never finished.


Resolving patch:
diff --git a/numpy/distutils/system_info.py b/numpy/distutils/system_info.py
--- a/numpy/distutils/system_info.py
+++ b/numpy/distutils/system_info.py
@@ -12,6 +12,7 @@
   lapack_atlas_info
   blas_info
   lapack_info
+  openblas_info
   blas_opt_info       # usage recommended
   lapack_opt_info     # usage recommended
   fftw_info,dfftw_info,sfftw_info
@@ -119,7 +120,6 @@
 import warnings
 from glob import glob
 from functools import reduce
-
 if sys.version_info[0] < 3:
     from ConfigParser import NoOptionError, ConfigParser
 else:
@@ -298,6 +298,7 @@ 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': openblas_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,
@@ -1366,7 +1367,22 @@ class lapack_opt_info(system_info):
 
     def calc_info(self):
 
-        if sys.platform == 'darwin' and not os.environ.get('ATLAS', None):
+        openblas_info = get_info('openblas')
+        if openblas_info:
+            self.set_info(**openblas_info)
+            return
+
+        lapack_mkl_info = get_info('lapack_mkl')
+        if lapack_mkl_info:
+            self.set_info(**lapack_mkl_info)
+            return
+
+        atlas_info = get_info('atlas_threads')
+        if not atlas_info:
+            atlas_info = get_info('atlas')
+
+        if sys.platform == 'darwin' and not atlas_info:
+            # Use the system lapack from Accelerate or vecLib under OSX
             args = []
             link_args = []
             if get_platform()[-4:] == 'i386' or 'intel' in get_platform() or \
@@ -1394,14 +1410,6 @@ def calc_info(self):
                               define_macros=[('NO_ATLAS_INFO', 3)])
                 return
 
-        lapack_mkl_info = get_info('lapack_mkl')
-        if lapack_mkl_info:
-            self.set_info(**lapack_mkl_info)
-            return
-
-        atlas_info = get_info('atlas_threads')
-        if not atlas_info:
-            atlas_info = get_info('atlas')
         #atlas_info = {} ## uncomment for testing
         need_lapack = 0
         need_blas = 0
@@ -1455,7 +1463,22 @@ class blas_opt_info(system_info):
 
     def calc_info(self):
 
-        if sys.platform == 'darwin' and not os.environ.get('ATLAS', None):
+        blas_mkl_info = get_info('blas_mkl')
+        if blas_mkl_info:
+            self.set_info(**blas_mkl_info)
+            return
+
+        openblas_info = get_info('openblas')
+        if openblas_info:
+            self.set_info(**openblas_info)
+            return
+
+        atlas_info = get_info('atlas_blas_threads')
+        if not atlas_info:
+            atlas_info = get_info('atlas_blas')
+
+        if sys.platform == 'darwin'and not atlas_info:
+            # Use the system BLAS from Accelerate or vecLib under OSX
             args = []
             link_args = []
             if get_platform()[-4:] == 'i386' or 'intel' in get_platform() or \
@@ -1487,14 +1510,6 @@ def calc_info(self):
                               define_macros=[('NO_ATLAS_INFO', 3)])
                 return
 
-        blas_mkl_info = get_info('blas_mkl')
-        if blas_mkl_info:
-            self.set_info(**blas_mkl_info)
-            return
-
-        atlas_info = get_info('atlas_blas_threads')
-        if not atlas_info:
-            atlas_info = get_info('atlas_blas')
         need_blas = 0
         info = {}
         if atlas_info:
@@ -1537,6 +1552,23 @@ def calc_info(self):
         self.set_info(**info)
 
 
+class openblas_info(blas_info):
+    section = 'openblas'
+    dir_env_var = 'OPENBLAS'
+    _lib_names = ['openblas']
+    notfounderror = BlasNotFoundError
+
+    def calc_info(self):
+        lib_dirs = self.get_lib_dirs()
+
+        openblas_libs = self.get_libs('openblas_libs', self._lib_names)
+        info = self.check_libs(lib_dirs, openblas_libs, [])
+        if info is None:
+            return
+        info['language'] = 'f77'  # XXX: is it generally true?
+        self.set_info(**info)
+
+
 class blas_src_info(system_info):
     section = 'blas_src'
     dir_env_var = 'BLAS_SRC'


Test patch: