python312Packages.yoda: 2.0.1 -> 2.0.2
[NixPkgs.git] / pkgs / development / python-modules / scikit-learn / default.nix
blob2502006fbae4427bb82c7a6c3327bca7bba40787
2   stdenv,
3   lib,
4   buildPythonPackage,
5   fetchPypi,
7   # build-system
8   cython,
9   gfortran,
10   meson-python,
11   numpy,
12   scipy,
14   # native dependencies
15   glibcLocales,
16   llvmPackages,
17   pytestCheckHook,
18   pytest-xdist,
19   pillow,
20   joblib,
21   threadpoolctl,
22   pythonOlder,
25 buildPythonPackage rec {
26   pname = "scikit-learn";
27   version = "1.5.2";
28   pyproject = true;
30   disabled = pythonOlder "3.9";
32   src = fetchPypi {
33     pname = "scikit_learn";
34     inherit version;
35     hash = "sha256-tCN+17P90KSIJ5LmjvJUXVuqUKyju0WqffRoE4rY+U0=";
36   };
38   postPatch = ''
39     substituteInPlace pyproject.toml \
40       --replace-fail "numpy>=2" "numpy"
42     substituteInPlace meson.build --replace-fail \
43       "run_command('sklearn/_build_utils/version.py', check: true).stdout().strip()," \
44       "'${version}',"
45   '';
47   buildInputs = [
48     numpy.blas
49     pillow
50     glibcLocales
51   ] ++ lib.optionals stdenv.cc.isClang [ llvmPackages.openmp ];
53   nativeBuildInputs = [
54     gfortran
55   ];
57   build-system = [
58     cython
59     meson-python
60     numpy
61     scipy
62   ];
64   dependencies = [
65     joblib
66     numpy
67     scipy
68     threadpoolctl
69   ];
71   nativeCheckInputs = [
72     pytestCheckHook
73     pytest-xdist
74   ];
76   env.LC_ALL = "en_US.UTF-8";
78   # PermissionError: [Errno 1] Operation not permitted: '/nix/nix-installer'
79   doCheck = !stdenv.hostPlatform.isDarwin;
81   disabledTests = [
82     # Skip test_feature_importance_regression - does web fetch
83     "test_feature_importance_regression"
84   ] ++ lib.optionals stdenv.hostPlatform.isAarch64 [
85     # doesn't seem to produce correct results?
86     # possibly relevant: https://github.com/scikit-learn/scikit-learn/issues/25838#issuecomment-2308650816
87     "test_sparse_input"
88   ];
90   pytestFlagsArray = [
91     # verbose build outputs needed to debug hard-to-reproduce hydra failures
92     "-v"
93     "--pyargs"
94     "sklearn"
96     # NuSVC memmap tests causes segmentation faults in certain environments
97     # (e.g. Hydra Darwin machines) related to a long-standing joblib issue
98     # (https://github.com/joblib/joblib/issues/563). See also:
99     # https://github.com/scikit-learn/scikit-learn/issues/17582
100     # Since we are overriding '-k' we need to include the 'disabledTests' from above manually.
101     "-k"
102     "'not (NuSVC and memmap) ${toString (lib.forEach disabledTests (t: "and not ${t}"))}'"
103   ];
105   preCheck = ''
106     cd $TMPDIR
107     export HOME=$TMPDIR
108     export OMP_NUM_THREADS=1
109   '';
111   pythonImportsCheck = [ "sklearn" ];
113   meta = with lib; {
114     description = "Set of python modules for machine learning and data mining";
115     changelog =
116       let
117         major = versions.major version;
118         minor = versions.minor version;
119         dashVer = replaceStrings [ "." ] [ "-" ] version;
120       in
121       "https://scikit-learn.org/stable/whats_new/v${major}.${minor}.html#version-${dashVer}";
122     homepage = "https://scikit-learn.org";
123     license = licenses.bsd3;
124     maintainers = with maintainers; [ davhau ];
125   };