Clone of https://github.com/NixOS/nixpkgs.git (to stress-test knotserver)
at 20.09 2.6 kB view raw
1{ lib 2, fetchPypi 3, python 4, buildPythonPackage 5, gfortran 6, hypothesis 7, pytest 8, blas 9, lapack 10, writeTextFile 11, isPyPy 12, cython 13, setuptoolsBuildHook 14 }: 15 16assert (!blas.isILP64) && (!lapack.isILP64); 17 18let 19 cfg = writeTextFile { 20 name = "site.cfg"; 21 text = (lib.generators.toINI {} { 22 ${blas.implementation} = { 23 include_dirs = "${lib.getDev blas}/include:${lib.getDev lapack}/include"; 24 library_dirs = "${blas}/lib:${lapack}/lib"; 25 runtime_library_dirs = "${blas}/lib:${lapack}/lib"; 26 libraries = "lapack,lapacke,blas,cblas"; 27 }; 28 lapack = { 29 include_dirs = "${lib.getDev lapack}/include"; 30 library_dirs = "${lapack}/lib"; 31 runtime_library_dirs = "${lapack}/lib"; 32 }; 33 blas = { 34 include_dirs = "${lib.getDev blas}/include"; 35 library_dirs = "${blas}/lib"; 36 runtime_library_dirs = "${blas}/lib"; 37 }; 38 }); 39 }; 40in buildPythonPackage rec { 41 pname = "numpy"; 42 version = "1.19.1"; 43 format = "pyproject.toml"; 44 45 src = fetchPypi { 46 inherit pname version; 47 extension = "zip"; 48 sha256 = "b8456987b637232602ceb4d663cb34106f7eb780e247d51a260b84760fd8f491"; 49 }; 50 51 nativeBuildInputs = [ gfortran pytest cython setuptoolsBuildHook ]; 52 buildInputs = [ blas lapack ]; 53 54 patches = lib.optionals python.hasDistutilsCxxPatch [ 55 # We patch cpython/distutils to fix https://bugs.python.org/issue1222585 56 # Patching of numpy.distutils is needed to prevent it from undoing the 57 # patch to distutils. 58 ./numpy-distutils-C++.patch 59 ]; 60 61 preConfigure = '' 62 sed -i 's/-faltivec//' numpy/distutils/system_info.py 63 export NPY_NUM_BUILD_JOBS=$NIX_BUILD_CORES 64 ''; 65 66 preBuild = '' 67 ln -s ${cfg} site.cfg 68 ''; 69 70 enableParallelBuilding = true; 71 72 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) 73 74 checkInputs = [ hypothesis ]; 75 76 checkPhase = '' 77 runHook preCheck 78 pushd dist 79 ${python.interpreter} -c 'import numpy; numpy.test("fast", verbose=10)' 80 popd 81 runHook postCheck 82 ''; 83 84 passthru = { 85 # just for backwards compatibility 86 blas = blas.provider; 87 blasImplementation = blas.implementation; 88 inherit cfg; 89 }; 90 91 # Disable test 92 # - test_large_file_support: takes a long time and can cause the machine to run out of disk space 93 NOSE_EXCLUDE="test_large_file_support"; 94 95 meta = { 96 description = "Scientific tools for Python"; 97 homepage = "https://numpy.org/"; 98 maintainers = with lib.maintainers; [ fridh ]; 99 }; 100}