nixpkgs mirror (for testing)
github.com/NixOS/nixpkgs
nix
1{ stdenv
2, lib
3, buildPythonPackage
4, fetchPypi
5, fetchpatch
6, gfortran
7, glibcLocales
8, numpy
9, scipy
10, pytestCheckHook
11, pytest-xdist
12, pillow
13, cython
14, joblib
15, llvmPackages
16, threadpoolctl
17, pythonOlder
18}:
19
20buildPythonPackage rec {
21 pname = "scikit-learn";
22 version = "1.0.2";
23 disabled = pythonOlder "3.6";
24
25 src = fetchPypi {
26 inherit pname version;
27 sha256 = "sha256-tYcJWaVIS2FPJtMcpMF1JLGwMXUiGZ3JhcO0JW4DB2c=";
28 };
29
30 buildInputs = [
31 pillow
32 glibcLocales
33 ] ++ lib.optionals stdenv.cc.isClang [
34 llvmPackages.openmp
35 ];
36
37 nativeBuildInputs = [
38 cython
39 gfortran
40 ];
41
42 propagatedBuildInputs = [
43 numpy
44 scipy
45 numpy.blas
46 joblib
47 threadpoolctl
48 ];
49
50 checkInputs = [ pytestCheckHook pytest-xdist ];
51
52 LC_ALL="en_US.UTF-8";
53
54 preBuild = ''
55 export SKLEARN_BUILD_PARALLEL=$NIX_BUILD_CORES
56 '';
57
58 doCheck = !stdenv.isAarch64;
59
60 disabledTests = [
61 # Skip test_feature_importance_regression - does web fetch
62 "test_feature_importance_regression"
63
64 # failing on macos
65 "check_regressors_train"
66 "check_classifiers_train"
67 "xfail_ignored_in_check_estimator"
68 ];
69
70 pytestFlagsArray = [
71 # verbose build outputs needed to debug hard-to-reproduce hydra failures
72 "-v"
73 "--pyargs" "sklearn"
74
75 # NuSVC memmap tests causes segmentation faults in certain environments
76 # (e.g. Hydra Darwin machines) related to a long-standing joblib issue
77 # (https://github.com/joblib/joblib/issues/563). See also:
78 # https://github.com/scikit-learn/scikit-learn/issues/17582
79 # Since we are overriding '-k' we need to include the 'disabledTests' from above manually.
80 "-k" "'not (NuSVC and memmap) ${toString (lib.forEach disabledTests (t: "and not ${t}"))}'"
81 ];
82
83 preCheck = ''
84 cd $TMPDIR
85 export HOME=$TMPDIR
86 export OMP_NUM_THREADS=1
87 '';
88
89 pythonImportsCheck = [ "sklearn" ];
90
91 meta = with lib; {
92 description = "A set of python modules for machine learning and data mining";
93 changelog = let
94 major = versions.major version;
95 minor = versions.minor version;
96 dashVer = replaceChars ["."] ["-"] version;
97 in
98 "https://scikit-learn.org/stable/whats_new/v${major}.${minor}.html#version-${dashVer}";
99 homepage = "https://scikit-learn.org";
100 license = licenses.bsd3;
101 maintainers = with maintainers; [ davhau ];
102 };
103}