2021-08-22 07:53:02 +00:00
|
|
|
{ lib
|
|
|
|
, stdenv
|
2023-08-10 07:59:29 +00:00
|
|
|
, fetchFromGitHub
|
|
|
|
, fetchpatch
|
|
|
|
, fetchurl
|
|
|
|
, writeText
|
2021-08-22 07:53:02 +00:00
|
|
|
, python
|
2022-11-04 12:27:35 +00:00
|
|
|
, pythonOlder
|
2021-08-22 07:53:02 +00:00
|
|
|
, buildPythonPackage
|
2021-09-18 10:52:07 +00:00
|
|
|
, cython
|
2021-08-22 07:53:02 +00:00
|
|
|
, gfortran
|
2022-09-30 11:47:45 +00:00
|
|
|
, meson-python
|
2024-04-21 15:54:59 +00:00
|
|
|
, nukeReferences
|
2022-09-30 11:47:45 +00:00
|
|
|
, pkg-config
|
2021-09-18 10:52:07 +00:00
|
|
|
, pythran
|
2022-09-30 11:47:45 +00:00
|
|
|
, wheel
|
2024-01-25 14:12:00 +00:00
|
|
|
, setuptools
|
|
|
|
, hypothesis
|
2024-04-21 15:54:59 +00:00
|
|
|
, pytest7CheckHook
|
2021-08-22 07:53:02 +00:00
|
|
|
, pytest-xdist
|
|
|
|
, numpy
|
|
|
|
, pybind11
|
2023-03-15 16:39:30 +00:00
|
|
|
, pooch
|
2022-11-04 12:27:35 +00:00
|
|
|
, libxcrypt
|
2023-08-10 07:59:29 +00:00
|
|
|
, xsimd
|
|
|
|
, blas
|
|
|
|
, lapack
|
2021-08-22 07:53:02 +00:00
|
|
|
}:
|
2021-06-28 23:13:55 +00:00
|
|
|
|
2023-08-10 07:59:29 +00:00
|
|
|
let
|
2020-04-24 23:36:52 +00:00
|
|
|
pname = "scipy";
|
2023-08-10 07:59:29 +00:00
|
|
|
# DON'T UPDATE THESE ATTRIBUTES MANUALLY - USE:
|
|
|
|
#
|
|
|
|
# nix-shell maintainers/scripts/update.nix --argstr package python3.pkgs.scipy
|
|
|
|
#
|
2023-10-09 19:29:22 +00:00
|
|
|
# The update script uses sed regexes to replace them with the updated hashes.
|
2024-04-21 15:54:59 +00:00
|
|
|
version = "1.13.0";
|
|
|
|
srcHash = "sha256-HaYk92hOREHMOXppK+Bs9DrBu9KUVUsZ0KV+isTofUo=";
|
2023-08-10 07:59:29 +00:00
|
|
|
datasetsHashes = {
|
|
|
|
ascent = "1qjp35ncrniq9rhzb14icwwykqg2208hcssznn3hz27w39615kh3";
|
|
|
|
ecg = "1bwbjp43b7znnwha5hv6wiz3g0bhwrpqpi75s12zidxrbwvd62pj";
|
|
|
|
face = "11i8x29h80y7hhyqhil1fg8mxag5f827g33lhnsf44qk116hp2wx";
|
|
|
|
};
|
|
|
|
datasets = lib.mapAttrs (
|
|
|
|
d: hash: fetchurl {
|
|
|
|
url = "https://raw.githubusercontent.com/scipy/dataset-${d}/main/${d}.dat";
|
|
|
|
sha256 = hash;
|
|
|
|
}
|
|
|
|
) datasetsHashes;
|
|
|
|
# Additional cross compilation related properties that scipy reads in scipy/meson.build
|
|
|
|
crossFileScipy = writeText "cross-file-scipy.conf" ''
|
|
|
|
[properties]
|
|
|
|
numpy-include-dir = '${numpy}/${python.sitePackages}/numpy/core/include'
|
|
|
|
pythran-include-dir = '${pythran}/${python.sitePackages}/pythran'
|
|
|
|
host-python-path = '${python.interpreter}'
|
|
|
|
host-python-version = '${python.pythonVersion}'
|
|
|
|
'';
|
|
|
|
in buildPythonPackage {
|
|
|
|
inherit pname version;
|
2023-10-09 19:29:22 +00:00
|
|
|
format = "pyproject";
|
2023-08-10 07:59:29 +00:00
|
|
|
|
|
|
|
src = fetchFromGitHub {
|
|
|
|
owner = "scipy";
|
|
|
|
repo = pname;
|
|
|
|
rev = "v${version}";
|
|
|
|
hash = srcHash;
|
|
|
|
fetchSubmodules = true;
|
2020-04-24 23:36:52 +00:00
|
|
|
};
|
|
|
|
|
2023-03-15 16:39:30 +00:00
|
|
|
patches = [
|
2023-08-10 07:59:29 +00:00
|
|
|
# Helps with cross compilation, see https://github.com/scipy/scipy/pull/18167
|
|
|
|
(fetchpatch {
|
|
|
|
url = "https://github.com/scipy/scipy/commit/dd50ac9d98dbb70625333a23e3a90e493228e3be.patch";
|
|
|
|
hash = "sha256-Vf6/hhwu6X5s8KWhq8bUZKtSkdVu/GtEpGtj8Olxe7s=";
|
|
|
|
excludes = [
|
|
|
|
"doc/source/dev/contributor/meson_advanced.rst"
|
|
|
|
];
|
|
|
|
})
|
2024-04-21 15:54:59 +00:00
|
|
|
# Fix for https://github.com/scipy/scipy/issues/20300 until 1.13.1 is
|
|
|
|
# released. Patch is based upon:
|
|
|
|
# https://github.com/scipy/pocketfft/commit/9367142748fcc9696a1c9e5a99b76ed9897c9daa
|
|
|
|
# Couldn't use fetchpatch because it is a submodule of scipy, and
|
|
|
|
# extraPrefix doesn't fit this purpose.
|
|
|
|
./pocketfft-aligned_alloc.patch
|
2023-03-15 16:39:30 +00:00
|
|
|
];
|
|
|
|
|
2024-04-21 15:54:59 +00:00
|
|
|
# Upstream says in a comment in their pyproject.toml that building against
|
|
|
|
# both numpy 2 and numpy 1 should work, but they seem to worry about numpy
|
|
|
|
# incompatibilities that we here with Nixpkgs' Python ecosystem, shouldn't
|
|
|
|
# experience.
|
2023-08-10 07:59:29 +00:00
|
|
|
postPatch = ''
|
|
|
|
substituteInPlace pyproject.toml \
|
2024-04-21 15:54:59 +00:00
|
|
|
--replace-fail 'numpy>=2.0.0rc1,' 'numpy' \
|
2023-08-10 07:59:29 +00:00
|
|
|
'';
|
|
|
|
|
2023-10-09 19:29:22 +00:00
|
|
|
nativeBuildInputs = [
|
|
|
|
cython
|
|
|
|
gfortran
|
|
|
|
meson-python
|
2024-04-21 15:54:59 +00:00
|
|
|
nukeReferences
|
2023-10-09 19:29:22 +00:00
|
|
|
pythran
|
|
|
|
pkg-config
|
|
|
|
wheel
|
2024-01-25 14:12:00 +00:00
|
|
|
setuptools
|
2023-10-09 19:29:22 +00:00
|
|
|
];
|
2021-09-18 10:52:07 +00:00
|
|
|
|
2022-11-04 12:27:35 +00:00
|
|
|
buildInputs = [
|
2023-08-10 07:59:29 +00:00
|
|
|
blas
|
|
|
|
lapack
|
2022-11-04 12:27:35 +00:00
|
|
|
pybind11
|
2023-03-15 16:39:30 +00:00
|
|
|
pooch
|
2023-08-10 07:59:29 +00:00
|
|
|
xsimd
|
2022-11-04 12:27:35 +00:00
|
|
|
] ++ lib.optionals (pythonOlder "3.9") [
|
|
|
|
libxcrypt
|
|
|
|
];
|
2021-09-18 10:52:07 +00:00
|
|
|
|
2020-04-24 23:36:52 +00:00
|
|
|
propagatedBuildInputs = [ numpy ];
|
|
|
|
|
2023-10-09 19:29:22 +00:00
|
|
|
__darwinAllowLocalNetworking = true;
|
|
|
|
|
|
|
|
nativeCheckInputs = [
|
2024-01-25 14:12:00 +00:00
|
|
|
hypothesis
|
2024-04-21 15:54:59 +00:00
|
|
|
# Failed: DID NOT WARN. No warnings of type (<class 'DeprecationWarning'>, <class 'PendingDeprecationWarning'>, <class 'FutureWarning'>) were emitted.
|
|
|
|
pytest7CheckHook
|
2023-10-09 19:29:22 +00:00
|
|
|
pytest-xdist
|
|
|
|
];
|
|
|
|
|
|
|
|
# The following tests are broken on aarch64-darwin with newer compilers and library versions.
|
|
|
|
# See https://github.com/scipy/scipy/issues/18308
|
|
|
|
disabledTests = lib.optionals (stdenv.isDarwin && stdenv.isAarch64) [
|
|
|
|
"test_a_b_neg_int_after_euler_hypergeometric_transformation"
|
|
|
|
"test_dst4_definition_ortho"
|
|
|
|
"test_load_mat4_le"
|
|
|
|
"hyp2f1_test_case47"
|
|
|
|
"hyp2f1_test_case3"
|
|
|
|
"test_uint64_max"
|
|
|
|
];
|
2021-09-18 10:52:07 +00:00
|
|
|
|
2022-05-18 14:49:53 +00:00
|
|
|
doCheck = !(stdenv.isx86_64 && stdenv.isDarwin);
|
2020-04-24 23:36:52 +00:00
|
|
|
|
|
|
|
preConfigure = ''
|
2023-08-10 07:59:29 +00:00
|
|
|
# Helps parallelization a bit
|
2020-04-24 23:36:52 +00:00
|
|
|
export NPY_NUM_BUILD_JOBS=$NIX_BUILD_CORES
|
2023-08-10 07:59:29 +00:00
|
|
|
# We download manually the datasets and this variable tells the pooch
|
|
|
|
# library where these files are cached. See also:
|
|
|
|
# https://github.com/scipy/scipy/pull/18518#issuecomment-1562350648 And at:
|
|
|
|
# https://github.com/scipy/scipy/pull/17965#issuecomment-1560759962
|
|
|
|
export XDG_CACHE_HOME=$PWD; export HOME=$(mktemp -d); mkdir scipy-data
|
|
|
|
'' + (lib.concatStringsSep "\n" (lib.mapAttrsToList (d: dpath:
|
|
|
|
# Actually copy the datasets
|
|
|
|
"cp ${dpath} scipy-data/${d}.dat"
|
|
|
|
) datasets));
|
|
|
|
|
|
|
|
mesonFlags = [
|
|
|
|
"-Dblas=${blas.pname}"
|
|
|
|
"-Dlapack=${lapack.pname}"
|
|
|
|
# We always run what's necessary for cross compilation, which is passing to
|
|
|
|
# meson the proper cross compilation related arguments. See also:
|
|
|
|
# https://docs.scipy.org/doc/scipy/building/cross_compilation.html
|
|
|
|
"--cross-file=${crossFileScipy}"
|
|
|
|
];
|
2020-04-24 23:36:52 +00:00
|
|
|
|
2021-08-22 07:53:02 +00:00
|
|
|
# disable stackprotector on aarch64-darwin for now
|
|
|
|
#
|
|
|
|
# build error:
|
|
|
|
#
|
|
|
|
# /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].
|
|
|
|
#
|
|
|
|
# ldr x0, [x0, ___stack_chk_guard];momd
|
|
|
|
#
|
|
|
|
hardeningDisable = lib.optionals (stdenv.isAarch64 && stdenv.isDarwin) [ "stackprotector" ];
|
|
|
|
|
2024-04-21 15:54:59 +00:00
|
|
|
# remove references to dev dependencies
|
|
|
|
postInstall = ''
|
|
|
|
nuke-refs $out/${python.sitePackages}/scipy/__config__.py
|
|
|
|
rm $out/${python.sitePackages}/scipy/__pycache__/__config__.*.opt-1.pyc
|
|
|
|
'';
|
|
|
|
|
2024-01-25 14:12:00 +00:00
|
|
|
preCheck = ''
|
2022-10-30 15:09:59 +00:00
|
|
|
export OMP_NUM_THREADS=$(( $NIX_BUILD_CORES / 4 ))
|
2024-01-25 14:12:00 +00:00
|
|
|
cd $out
|
2020-04-24 23:36:52 +00:00
|
|
|
'';
|
|
|
|
|
2023-02-16 17:41:37 +00:00
|
|
|
requiredSystemFeatures = [ "big-parallel" ]; # the tests need lots of CPU time
|
|
|
|
|
2020-04-24 23:36:52 +00:00
|
|
|
passthru = {
|
2023-08-10 07:59:29 +00:00
|
|
|
inherit blas;
|
|
|
|
updateScript = [
|
|
|
|
./update.sh
|
|
|
|
# Pass it this file name as argument
|
|
|
|
(builtins.unsafeGetAttrPos "pname" python.pkgs.scipy).file
|
|
|
|
]
|
|
|
|
# Pass it the names of the datasets to update their hashes
|
|
|
|
++ (builtins.attrNames datasetsHashes)
|
|
|
|
;
|
2020-04-24 23:36:52 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
SCIPY_USE_G77_ABI_WRAPPER = 1;
|
|
|
|
|
2021-03-09 03:18:52 +00:00
|
|
|
meta = with lib; {
|
2024-01-13 08:15:51 +00:00
|
|
|
changelog = "https://github.com/scipy/scipy/releases/tag/v${version}";
|
2021-03-09 03:18:52 +00:00
|
|
|
description = "SciPy (pronounced 'Sigh Pie') is open-source software for mathematics, science, and engineering";
|
2023-11-16 04:20:00 +00:00
|
|
|
downloadPage = "https://github.com/scipy/scipy";
|
2020-04-24 23:36:52 +00:00
|
|
|
homepage = "https://www.scipy.org/";
|
2021-03-09 03:18:52 +00:00
|
|
|
license = licenses.bsd3;
|
2023-08-10 07:59:29 +00:00
|
|
|
maintainers = with maintainers; [ fridh doronbehar ];
|
2020-04-24 23:36:52 +00:00
|
|
|
};
|
|
|
|
}
|