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