1{ lib
2, stdenv
3, fetchPypi
4, python
5, buildPythonPackage
6, cython
7, gfortran
8, pythran
9, nose
10, pytest
11, pytest-xdist
12, numpy
13, pybind11
14}:
15
16buildPythonPackage rec {
17 pname = "scipy";
18 version = "1.7.1";
19
20 src = fetchPypi {
21 inherit pname version;
22 sha256 = "6b47d5fa7ea651054362561a28b1ccc8da9368a39514c1bbf6c0977a1c376764";
23 };
24
25 nativeBuildInputs = [ cython gfortran pythran ];
26
27 buildInputs = [ numpy.blas pybind11 ];
28
29 propagatedBuildInputs = [ numpy ];
30
31 checkInputs = [ nose pytest pytest-xdist ];
32
33 # Remove tests because of broken wrapper
34 prePatch = ''
35 rm scipy/linalg/tests/test_lapack.py
36 '';
37
38 doCheck = true;
39
40 preConfigure = ''
41 sed -i '0,/from numpy.distutils.core/s//import setuptools;from numpy.distutils.core/' setup.py
42 export NPY_NUM_BUILD_JOBS=$NIX_BUILD_CORES
43 '';
44
45 preBuild = ''
46 ln -s ${numpy.cfg} site.cfg
47 '';
48
49 # disable stackprotector on aarch64-darwin for now
50 #
51 # build error:
52 #
53 # /private/tmp/nix-build-python3.9-scipy-1.6.3.drv-0/ccDEsw5U.s:109:15: error: index must be an integer in range [-256, 255].
54 #
55 # ldr x0, [x0, ___stack_chk_guard];momd
56 #
57 hardeningDisable = lib.optionals (stdenv.isAarch64 && stdenv.isDarwin) [ "stackprotector" ];
58
59 checkPhase = ''
60 runHook preCheck
61 pushd dist
62 ${python.interpreter} -c "import scipy; scipy.test('fast', verbose=10, parallel=$NIX_BUILD_CORES)"
63 popd
64 runHook postCheck
65 '';
66
67 passthru = {
68 blas = numpy.blas;
69 };
70
71 setupPyBuildFlags = [ "--fcompiler='gnu95'" ];
72
73 SCIPY_USE_G77_ABI_WRAPPER = 1;
74
75 meta = with lib; {
76 description = "SciPy (pronounced 'Sigh Pie') is open-source software for mathematics, science, and engineering";
77 homepage = "https://www.scipy.org/";
78 license = licenses.bsd3;
79 maintainers = [ maintainers.fridh ];
80 };
81}