1{ lib
2, stdenv
3, fetchPypi
4, fetchpatch
5, python
6, pythonOlder
7, buildPythonPackage
8, cython
9, gfortran
10, meson-python
11, pkg-config
12, pythran
13, wheel
14, nose
15, pytest
16, pytest-xdist
17, numpy
18, pybind11
19, libxcrypt
20}:
21
22buildPythonPackage rec {
23 pname = "scipy";
24 version = "1.9.1";
25 format = "pyproject";
26
27 src = fetchPypi {
28 inherit pname version;
29 sha256 = "sha256-JtKMRokA5tX9s30oEqtG2wzNIsY7qglQV4cfqjpJi8k=";
30 };
31
32 patches = [
33 (fetchpatch {
34 url = "https://github.com/scipy/scipy/commit/318d8c6d16fdf000be8637e9917989729f2c8ce7.diff";
35 sha256 = "sha256-Zfb9GYP0r9MDJ91hSzMN1r4eNilajPThNIvZmDzFEXo=";
36 })
37 ];
38
39 nativeBuildInputs = [ cython gfortran meson-python pythran pkg-config wheel ];
40
41 buildInputs = [
42 numpy.blas
43 pybind11
44 ] ++ lib.optionals (pythonOlder "3.9") [
45 libxcrypt
46 ];
47
48 propagatedBuildInputs = [ numpy ];
49
50 checkInputs = [ nose pytest pytest-xdist ];
51
52 doCheck = !(stdenv.isx86_64 && stdenv.isDarwin);
53
54 preConfigure = ''
55 sed -i '0,/from numpy.distutils.core/s//import setuptools;from numpy.distutils.core/' setup.py
56 export NPY_NUM_BUILD_JOBS=$NIX_BUILD_CORES
57 '';
58
59 # disable stackprotector on aarch64-darwin for now
60 #
61 # build error:
62 #
63 # /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].
64 #
65 # ldr x0, [x0, ___stack_chk_guard];momd
66 #
67 hardeningDisable = lib.optionals (stdenv.isAarch64 && stdenv.isDarwin) [ "stackprotector" ];
68
69 checkPhase = ''
70 runHook preCheck
71 pushd "$out"
72 export OMP_NUM_THREADS=$(( $NIX_BUILD_CORES / 4 ))
73 ${python.interpreter} -c "import scipy; scipy.test('fast', verbose=10, parallel=$NIX_BUILD_CORES)"
74 popd
75 runHook postCheck
76 '';
77
78 passthru = {
79 blas = numpy.blas;
80 };
81
82 setupPyBuildFlags = [ "--fcompiler='gnu95'" ];
83
84 SCIPY_USE_G77_ABI_WRAPPER = 1;
85
86 meta = with lib; {
87 description = "SciPy (pronounced 'Sigh Pie') is open-source software for mathematics, science, and engineering";
88 homepage = "https://www.scipy.org/";
89 license = licenses.bsd3;
90 maintainers = [ maintainers.fridh ];
91 };
92}