math/py-numpy16: bring BLAS usage into line with math/py-numpy

This old version for PY27 now behaves just like the modern one
regarding usage of BLAS and actually CBLAS.
This commit is contained in:
thor 2021-04-20 20:58:39 +00:00
parent 0d84ffedd2
commit 5025334842
3 changed files with 79 additions and 34 deletions

View file

@ -1,8 +1,8 @@
# $NetBSD: Makefile,v 1.5 2020/10/12 21:52:03 bacon Exp $
# $NetBSD: Makefile,v 1.6 2021/04/20 20:58:39 thor Exp $
DISTNAME= numpy-1.16.6
PKGNAME= ${PYPKGPREFIX}-${DISTNAME}
PKGREVISION= 1
PKGREVISION= 2
CATEGORIES= math python
MASTER_SITES= ${MASTER_SITE_PYPI:=n/numpy/}
EXTRACT_SUFX= .zip
@ -21,7 +21,8 @@ TEST_DEPENDS+= ${PYPKGPREFIX}-nose-[0-9]*:../../devel/py-nose
PYTHON_VERSIONED_DEPENDENCIES= test:test
USE_LANGUAGES= c fortran
MAKE_ENV+= ATLAS=None
.include "../../math/py-numpy/Makefile.make_env"
REPLACE_PYTHON+= *.py */*.py */*/*.py */*/*/*.py */*/*/*/*.py
@ -59,9 +60,5 @@ BUILDLINK_API_DEPENDS.py-cython+= ${PYPKGPREFIX}-cython>=0.29.2
.include "../../lang/python/application.mk"
.include "../../lang/python/egg.mk"
.include "../../lang/python/versioned_dependencies.mk"
# Consider allowing mk/blas.buildlink3.mk to handle Accelerate.framework
.if ${OPSYS} != "Darwin"
# blas and lapack are not needed; numpy will use Accelerate.framework
.include "../../mk/blas.buildlink3.mk"
.endif
.include "../../math/cblas/buildlink3.mk"
.include "../../mk/bsd.pkg.mk"

View file

@ -1,4 +1,4 @@
$NetBSD: distinfo,v 1.2 2020/10/13 08:27:02 leot Exp $
$NetBSD: distinfo,v 1.3 2021/04/20 20:58:39 thor Exp $
SHA1 (numpy-1.16.6.zip) = 99bc8b723639066168cca0c9a3b68c36c73bddc2
RMD160 (numpy-1.16.6.zip) = af2c5ec5956986b061a5cf067de5685098b6846f
@ -7,5 +7,5 @@ Size (numpy-1.16.6.zip) = 5143340 bytes
SHA1 (patch-numpy_distutils_fcompiler_____init____.py) = 49d070da5b48bd9818b37ac3254341fa68503c53
SHA1 (patch-numpy_distutils_fcompiler_g95.py) = be73b64a3e551df998b6a904d6db762bf28a98ed
SHA1 (patch-numpy_distutils_fcompiler_gnu.py) = 893b0556f869543074cb74d5d4385d2f155004ec
SHA1 (patch-numpy_distutils_system__info.py) = f6414ce220c7f8ba7e139f5619080a78f6de8066
SHA1 (patch-numpy_distutils_system__info.py) = 80659989fd4a8189a27e7f20802dda2151a4c4e1
SHA1 (patch-numpy_linalg_lapack__litemodule.c) = b421455fdbb666c8075d8bffbeb59533434d23e6

View file

@ -1,30 +1,78 @@
$NetBSD: patch-numpy_distutils_system__info.py,v 1.2 2020/10/12 21:52:03 bacon Exp $
$NetBSD: patch-numpy_distutils_system__info.py,v 1.3 2021/04/20 20:58:39 thor Exp $
Disable openblas detection. In pkgsrc, use mk/blas.buildlink.mk.
--- numpy/distutils/system_info.py.orig 2018-04-02 21:18:11.535155000 +0000
--- numpy/distutils/system_info.py.orig 2021-04-20 20:11:02.731971594 +0000
+++ numpy/distutils/system_info.py
@@ -1531,12 +1531,12 @@ class lapack_opt_info(system_info):
@@ -82,6 +82,19 @@ The order of finding the locations of re
3. ALL section in site.cfg
Only the first complete match is returned.
+Note that blas_opt_info and lapack_opt_info honor the NPY_BLAS_ORDER
+and NPY_LAPACK_ORDER environment variables to determine the order in which
+specific BLAS and LAPACK libraries are searched for.
+
+This search (or autodetection) can be bypassed by defining the environment
+variables NPY_BLAS_LIBS and NPY_LAPACK_LIBS, which should then contain the
+exact linker flags to use (language will be set to F77). Building against
+Netlib BLAS/LAPACK or stub files, in order to be able to switch BLAS and LAPACK
+implementations at runtime. If using this to build NumPy itself, it is
+recommended to also define NPY_CBLAS_LIBS (assuming your BLAS library has a
+CBLAS interface) to enable CBLAS usage for matrix multiplication (unoptimized
+otherwise).
+
Example:
----------
[ALL]
@@ -1542,8 +1555,24 @@ class lapack_opt_info(system_info):
notfounderror = LapackNotFoundError
+ def _calc_info_from_envvar(self):
+ info = {}
+ info['language'] = 'f77'
+ info['libraries'] = []
+ info['include_dirs'] = []
+ info['define_macros'] = []
+ info['extra_link_args'] = os.environ['NPY_LAPACK_LIBS'].split()
+ self.set_info(**info)
+ return True
+
def calc_info(self):
+ if 'NPY_LAPACK_LIBS' in os.environ:
+ # Bypass autodetection, set language to F77 and use env var linker
+ # flags directly
+ self._calc_info_from_envvar()
+ return
+
lapack_mkl_info = get_info('lapack_mkl')
if lapack_mkl_info:
self.set_info(**lapack_mkl_info)
return
@@ -1621,8 +1650,28 @@ class blas_opt_info(system_info):
- openblas_info = get_info('openblas_lapack')
+ openblas_info = None
if openblas_info:
self.set_info(**openblas_info)
return
notfounderror = BlasNotFoundError
- openblas_info = get_info('openblas_clapack')
+ openblas_info = None
if openblas_info:
self.set_info(**openblas_info)
return
@@ -1642,7 +1642,7 @@ class blas_opt_info(system_info):
self.set_info(**blis_info)
return
+ def _calc_info_from_envvar(self):
+ info = {}
+ info['language'] = 'f77'
+ info['libraries'] = []
+ info['include_dirs'] = []
+ info['define_macros'] = []
+ info['extra_link_args'] = os.environ['NPY_BLAS_LIBS'].split()
+ if 'NPY_CBLAS_LIBS' in os.environ:
+ info['define_macros'].append(('HAVE_CBLAS', None))
+ info['extra_link_args'].extend(
+ os.environ['NPY_CBLAS_LIBS'].split())
+ self.set_info(**info)
+ return True
+
def calc_info(self):
- openblas_info = get_info('openblas')
+ openblas_info = None
if openblas_info:
self.set_info(**openblas_info)
return
+ if 'NPY_BLAS_LIBS' in os.environ:
+ # Bypass autodetection, set language to F77 and use env var linker
+ # flags directly
+ self._calc_info_from_envvar()
+ return
+
blas_mkl_info = get_info('blas_mkl')
if blas_mkl_info:
self.set_info(**blas_mkl_info)