32 # DON'T UPDATE THESE ATTRIBUTES MANUALLY - USE:
34 # nix-shell maintainers/scripts/update.nix --argstr package python3.pkgs.scipy
36 # The update script uses sed regexes to replace them with the updated hashes.
38 srcHash = "sha256-HaYk92hOREHMOXppK+Bs9DrBu9KUVUsZ0KV+isTofUo=";
40 ascent = "1qjp35ncrniq9rhzb14icwwykqg2208hcssznn3hz27w39615kh3";
41 ecg = "1bwbjp43b7znnwha5hv6wiz3g0bhwrpqpi75s12zidxrbwvd62pj";
42 face = "11i8x29h80y7hhyqhil1fg8mxag5f827g33lhnsf44qk116hp2wx";
44 datasets = lib.mapAttrs (
46 url = "https://raw.githubusercontent.com/scipy/dataset-${d}/main/${d}.dat";
50 # Additional cross compilation related properties that scipy reads in scipy/meson.build
51 crossFileScipy = writeText "cross-file-scipy.conf" ''
53 numpy-include-dir = '${numpy}/${python.sitePackages}/numpy/core/include'
54 pythran-include-dir = '${pythran}/${python.sitePackages}/pythran'
55 host-python-path = '${python.interpreter}'
56 host-python-version = '${python.pythonVersion}'
58 in buildPythonPackage {
59 inherit pname version;
62 src = fetchFromGitHub {
67 fetchSubmodules = true;
71 # Helps with cross compilation, see https://github.com/scipy/scipy/pull/18167
73 url = "https://github.com/scipy/scipy/commit/dd50ac9d98dbb70625333a23e3a90e493228e3be.patch";
74 hash = "sha256-Vf6/hhwu6X5s8KWhq8bUZKtSkdVu/GtEpGtj8Olxe7s=";
76 "doc/source/dev/contributor/meson_advanced.rst"
79 # Fix for https://github.com/scipy/scipy/issues/20300 until 1.13.1 is
80 # released. Patch is based upon:
81 # https://github.com/scipy/pocketfft/commit/9367142748fcc9696a1c9e5a99b76ed9897c9daa
82 # Couldn't use fetchpatch because it is a submodule of scipy, and
83 # extraPrefix doesn't fit this purpose.
84 ./pocketfft-aligned_alloc.patch
87 # Upstream says in a comment in their pyproject.toml that building against
88 # both numpy 2 and numpy 1 should work, but they seem to worry about numpy
89 # incompatibilities that we here with Nixpkgs' Python ecosystem, shouldn't
92 substituteInPlace pyproject.toml \
93 --replace-fail 'numpy>=2.0.0rc1,' 'numpy' \
113 ] ++ lib.optionals (pythonOlder "3.9") [
117 propagatedBuildInputs = [ numpy ];
119 __darwinAllowLocalNetworking = true;
121 nativeCheckInputs = [
123 # Failed: DID NOT WARN. No warnings of type (<class 'DeprecationWarning'>, <class 'PendingDeprecationWarning'>, <class 'FutureWarning'>) were emitted.
128 # The following tests are broken on aarch64-darwin with newer compilers and library versions.
129 # See https://github.com/scipy/scipy/issues/18308
130 disabledTests = lib.optionals (stdenv.isDarwin && stdenv.isAarch64) [
131 "test_a_b_neg_int_after_euler_hypergeometric_transformation"
132 "test_dst4_definition_ortho"
139 doCheck = !(stdenv.isx86_64 && stdenv.isDarwin);
142 # Helps parallelization a bit
143 export NPY_NUM_BUILD_JOBS=$NIX_BUILD_CORES
144 # We download manually the datasets and this variable tells the pooch
145 # library where these files are cached. See also:
146 # https://github.com/scipy/scipy/pull/18518#issuecomment-1562350648 And at:
147 # https://github.com/scipy/scipy/pull/17965#issuecomment-1560759962
148 export XDG_CACHE_HOME=$PWD; export HOME=$(mktemp -d); mkdir scipy-data
149 '' + (lib.concatStringsSep "\n" (lib.mapAttrsToList (d: dpath:
150 # Actually copy the datasets
151 "cp ${dpath} scipy-data/${d}.dat"
155 "-Dblas=${blas.pname}"
156 "-Dlapack=${lapack.pname}"
157 # We always run what's necessary for cross compilation, which is passing to
158 # meson the proper cross compilation related arguments. See also:
159 # https://docs.scipy.org/doc/scipy/building/cross_compilation.html
160 "--cross-file=${crossFileScipy}"
163 # disable stackprotector on aarch64-darwin for now
167 # /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].
169 # ldr x0, [x0, ___stack_chk_guard];momd
171 hardeningDisable = lib.optionals (stdenv.isAarch64 && stdenv.isDarwin) [ "stackprotector" ];
173 # remove references to dev dependencies
175 nuke-refs $out/${python.sitePackages}/scipy/__config__.py
176 rm $out/${python.sitePackages}/scipy/__pycache__/__config__.*.opt-1.pyc
180 export OMP_NUM_THREADS=$(( $NIX_BUILD_CORES / 4 ))
184 requiredSystemFeatures = [ "big-parallel" ]; # the tests need lots of CPU time
190 # Pass it this file name as argument
191 (builtins.unsafeGetAttrPos "pname" python.pkgs.scipy).file
193 # Pass it the names of the datasets to update their hashes
194 ++ (builtins.attrNames datasetsHashes)
198 SCIPY_USE_G77_ABI_WRAPPER = 1;
201 changelog = "https://github.com/scipy/scipy/releases/tag/v${version}";
202 description = "SciPy (pronounced 'Sigh Pie') is open-source software for mathematics, science, and engineering";
203 downloadPage = "https://github.com/scipy/scipy";
204 homepage = "https://www.scipy.org/";
205 license = licenses.bsd3;
206 maintainers = with maintainers; [ fridh doronbehar ];