Clone of https://github.com/NixOS/nixpkgs.git (to stress-test knotserver)
at 19.09 72 lines 2.0 kB view raw
1{ lib, fetchPypi, python, buildPythonPackage, gfortran, pytest, blas, writeTextFile, isPyPy }: 2 3let 4 blasImplementation = lib.nameFromURL blas.name "-"; 5 cfg = writeTextFile { 6 name = "site.cfg"; 7 text = (lib.generators.toINI {} { 8 ${blasImplementation} = { 9 include_dirs = "${blas}/include"; 10 library_dirs = "${blas}/lib"; 11 } // lib.optionalAttrs (blasImplementation == "mkl") { 12 mkl_libs = "mkl_rt"; 13 lapack_libs = ""; 14 }; 15 }); 16 }; 17in buildPythonPackage rec { 18 pname = "numpy"; 19 version = "1.17.2"; 20 21 src = fetchPypi { 22 inherit pname version; 23 extension = "zip"; 24 sha256 = "73615d3edc84dd7c4aeb212fa3748fb83217e00d201875a47327f55363cef2df"; 25 }; 26 27 nativeBuildInputs = [ gfortran pytest ]; 28 buildInputs = [ blas ]; 29 30 patches = lib.optionals python.hasDistutilsCxxPatch [ 31 # We patch cpython/distutils to fix https://bugs.python.org/issue1222585 32 # Patching of numpy.distutils is needed to prevent it from undoing the 33 # patch to distutils. 34 ./numpy-distutils-C++.patch 35 ]; 36 37 preConfigure = '' 38 sed -i 's/-faltivec//' numpy/distutils/system_info.py 39 export NPY_NUM_BUILD_JOBS=$NIX_BUILD_CORES 40 ''; 41 42 preBuild = '' 43 ln -s ${cfg} site.cfg 44 ''; 45 46 enableParallelBuilding = true; 47 48 doCheck = !isPyPy; # numpy 1.16+ hits a bug in pypy's ctypes, using either numpy or pypy HEAD fixes this (https://github.com/numpy/numpy/issues/13807) 49 50 checkPhase = '' 51 runHook preCheck 52 pushd dist 53 ${python.interpreter} -c 'import numpy; numpy.test("fast", verbose=10)' 54 popd 55 runHook postCheck 56 ''; 57 58 passthru = { 59 blas = blas; 60 inherit blasImplementation cfg; 61 }; 62 63 # Disable test 64 # - test_large_file_support: takes a long time and can cause the machine to run out of disk space 65 NOSE_EXCLUDE="test_large_file_support"; 66 67 meta = { 68 description = "Scientific tools for Python"; 69 homepage = http://numpy.scipy.org/; 70 maintainers = with lib.maintainers; [ fridh ]; 71 }; 72}