1{ stdenv, lib, fetchPypi, python, buildPythonPackage, isPyPy, gfortran, pytest, blas }:
2
3buildPythonPackage rec {
4 pname = "numpy";
5 version = "1.15.1";
6
7 src = fetchPypi {
8 inherit pname version;
9 extension = "zip";
10 sha256 = "7b9e37f194f8bcdca8e9e6af92e2cbad79e360542effc2dd6b98d63955d8d8a3";
11 };
12
13 disabled = isPyPy;
14 buildInputs = [ gfortran pytest blas ];
15
16 patches = lib.optionals (python.hasDistutilsCxxPatch or false) [
17 # We patch cpython/distutils to fix https://bugs.python.org/issue1222585
18 # Patching of numpy.distutils is needed to prevent it from undoing the
19 # patch to distutils.
20 ./numpy-distutils-C++.patch
21 ];
22
23 postPatch = lib.optionalString stdenv.hostPlatform.isMusl ''
24 # Use fenv.h
25 sed -i \
26 numpy/core/src/npymath/ieee754.c.src \
27 numpy/core/include/numpy/ufuncobject.h \
28 -e 's/__GLIBC__/__linux__/'
29 # Don't use various complex trig functions
30 substituteInPlace numpy/core/src/private/npy_config.h \
31 --replace '#if defined(__GLIBC__)' "#if 1" \
32 --replace '#if !__GLIBC_PREREQ(2, 18)' "#if 1"
33 '';
34
35 preConfigure = ''
36 sed -i 's/-faltivec//' numpy/distutils/system_info.py
37 export NPY_NUM_BUILD_JOBS=$NIX_BUILD_CORES
38 '';
39
40 preBuild = ''
41 echo "Creating site.cfg file..."
42 cat << EOF > site.cfg
43 [openblas]
44 include_dirs = ${blas}/include
45 library_dirs = ${blas}/lib
46 EOF
47 '';
48
49 enableParallelBuilding = true;
50
51 checkPhase = ''
52 runHook preCheck
53 pushd dist
54 ${python.interpreter} -c 'import numpy; numpy.test("fast", verbose=10)'
55 popd
56 runHook postCheck
57 '';
58
59 passthru = {
60 blas = blas;
61 };
62
63 # Disable two tests
64 # - test_f2py: f2py isn't yet on path.
65 # - test_large_file_support: takes a long time and can cause the machine to run out of disk space
66 NOSE_EXCLUDE="test_f2py,test_large_file_support";
67
68 meta = {
69 description = "Scientific tools for Python";
70 homepage = http://numpy.scipy.org/;
71 maintainers = with lib.maintainers; [ fridh ];
72 };
73}