Skip to content
This repository has been archived by the owner on Jan 30, 2023. It is now read-only.

Commit

Permalink
29056: make numpy find openblas from Homebrew
Browse files Browse the repository at this point in the history
For numpy to find Homebrew's openblas on macOS, this ticket adds an
`[openblas]` section to numpy's site.cfg if Sage is using openblas.

This is also what Homebrew's
[https://github.com/Homebrew/homebrew-core/blob/f2463cbba086689c872cddd3a8bc242976a603ff/Formula/numpy.rb#L25-L30
numpy formula] does.

See also the upstream
[https://github.com/numpy/numpy/blob/2199ba7fb7f8bb383552fdcd6feec4faee7ae394/site.cfg.example#L129-L132
site.cfg.example].
  • Loading branch information
mwageringel committed Jan 25, 2020
1 parent dde78cb commit 052c06c
Showing 1 changed file with 16 additions and 4 deletions.
20 changes: 16 additions & 4 deletions build/pkgs/numpy/lapack_conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,18 +16,30 @@
pc_blas = pkgconfig.parse('cblas blas')
pc_lapack = pkgconfig.parse('lapack')

if not (os.environ['UNAME'] == 'Darwin'):
if os.environ['UNAME'] == 'Darwin':
# on macOS, if openblas is available (the default), use it instead of the
# macOS Accelerate framework
if 'openblas' in pc_blas.get('libraries', []):
conf_file.write('[openblas]\n')
conf_file.write('libraries = '+', '.join(pc_blas['libraries'])+'\n')
inc_dir = pc_blas['include_dirs']
if len(inc_dir) > 0:
conf_file.write('include_dirs = '+ ':'.join(inc_dir)+'\n')
lib_dir = pc_blas['library_dirs']
if len(lib_dir) > 0:
conf_file.write('library_dirs = '+ ':'.join(lib_dir)+'\n')
else:
conf_file.write('[blas]\n')
inc_dir = pc_blas['include_dirs']
if len(inc_dir) > 0 :
if len(inc_dir) > 0:
conf_file.write('include_dirs = '+ ':'.join(inc_dir)+'\n')
lib_dir = pc_blas['library_dirs']
if len(lib_dir) > 0 :
if len(lib_dir) > 0:
conf_file.write('library_dirs = '+ ':'.join(lib_dir)+'\n')
conf_file.write('blas_libs = '+', '.join(pc_blas['libraries'])+'\n')
conf_file.write('[lapack]\n')
lib_dir = pc_lapack['library_dirs']
if len(lib_dir) > 0 :
if len(lib_dir) > 0:
conf_file.write('library_dirs = '+ ':'.join(lib_dir)+'\n')
conf_file.write('lapack_libs = '+', '.join(pc_lapack['libraries'])+'\n')

Expand Down

0 comments on commit 052c06c

Please sign in to comment.