about summary refs log tree commit diff
path: root/pkgs/development/python-modules/numpy
diff options
context:
space:
mode:
authorChris Ostrouchov <chris.ostrouchov@gmail.com>2018-10-18 15:00:48 -0400
committerFrederik Rietdijk <fridh@fridh.nl>2018-10-20 11:50:37 +0200
commit277b73ab6fecd5c8f76b8eb9cc2fc1e036aee0db (patch)
treeb9962f497ce1689bbd6c7fac739d3eadb21d52af /pkgs/development/python-modules/numpy
parenteee82aee375bf964e41dc7b66e35977a85e287a7 (diff)
downloadnixlib-277b73ab6fecd5c8f76b8eb9cc2fc1e036aee0db.tar
nixlib-277b73ab6fecd5c8f76b8eb9cc2fc1e036aee0db.tar.gz
nixlib-277b73ab6fecd5c8f76b8eb9cc2fc1e036aee0db.tar.bz2
nixlib-277b73ab6fecd5c8f76b8eb9cc2fc1e036aee0db.tar.lz
nixlib-277b73ab6fecd5c8f76b8eb9cc2fc1e036aee0db.tar.xz
nixlib-277b73ab6fecd5c8f76b8eb9cc2fc1e036aee0db.tar.zst
nixlib-277b73ab6fecd5c8f76b8eb9cc2fc1e036aee0db.zip
pythonPackages.{numpy,scipy,numexpr}: support MKL as BLAS
This adds support building with MKL.
Diffstat (limited to 'pkgs/development/python-modules/numpy')
-rw-r--r--pkgs/development/python-modules/numpy/default.nix28
1 files changed, 20 insertions, 8 deletions
diff --git a/pkgs/development/python-modules/numpy/default.nix b/pkgs/development/python-modules/numpy/default.nix
index 87428f4563d9..8b6b8d46b83c 100644
--- a/pkgs/development/python-modules/numpy/default.nix
+++ b/pkgs/development/python-modules/numpy/default.nix
@@ -1,6 +1,20 @@
-{ stdenv, lib, fetchPypi, python, buildPythonPackage, isPyPy, gfortran, pytest, blas }:
+{ stdenv, lib, fetchPypi, python, buildPythonPackage, isPyPy, gfortran, pytest, blas, writeTextFile }:
 
-buildPythonPackage rec {
+let
+  blasImplementation = lib.nameFromURL blas.name "-";
+  cfg = writeTextFile {
+    name = "site.cfg";
+    text = (lib.generators.toINI {} {
+      "${blasImplementation}" = {
+        include_dirs = "${blas}/include";
+        library_dirs = "${blas}/lib";
+      } // lib.optionalAttrs (blasImplementation == "mkl") {
+        mkl_libs = "mkl_rt";
+        lapack_libs = "";
+      };
+    });
+  };
+in buildPythonPackage rec {
   pname = "numpy";
   version = "1.15.2";
 
@@ -39,12 +53,7 @@ buildPythonPackage rec {
   '';
 
   preBuild = ''
-    echo "Creating site.cfg file..."
-    cat << EOF > site.cfg
-    [openblas]
-    include_dirs = ${blas}/include
-    library_dirs = ${blas}/lib
-    EOF
+    ln -s ${cfg} site.cfg
   '';
 
   enableParallelBuilding = true;
@@ -59,8 +68,11 @@ buildPythonPackage rec {
 
   passthru = {
     blas = blas;
+    inherit blasImplementation cfg;
   };
 
+  doCheck = blasImplementation != "mkl";
+
   # Disable two tests
   # - test_f2py: f2py isn't yet on path.
   # - test_large_file_support: takes a long time and can cause the machine to run out of disk space