1{ stdenv
2, lib
3, buildPythonPackage
4, fetchPypi
5, fetchpatch
6, gfortran, glibcLocales
7, numpy, scipy, pytest, pillow
8, cython
9, joblib
10, llvmPackages
11, threadpoolctl
12}:
13
14buildPythonPackage rec {
15 pname = "scikit-learn";
16 version = "0.23.2";
17 # UnboundLocalError: local variable 'message' referenced before assignment
18 disabled = stdenv.isi686; # https://github.com/scikit-learn/scikit-learn/issues/5534
19
20 src = fetchPypi {
21 inherit pname version;
22 sha256 = "20766f515e6cd6f954554387dfae705d93c7b544ec0e6c6a5d8e006f6f7ef480";
23 };
24
25 buildInputs = [
26 pillow
27 gfortran
28 glibcLocales
29 ] ++ lib.optionals stdenv.cc.isClang [
30 llvmPackages.openmp
31 ];
32
33 nativeBuildInputs = [
34 cython
35 ];
36
37 propagatedBuildInputs = [
38 numpy
39 scipy
40 numpy.blas
41 joblib
42 threadpoolctl
43 ];
44 checkInputs = [ pytest ];
45
46 LC_ALL="en_US.UTF-8";
47
48 doCheck = !stdenv.isAarch64;
49 # Skip test_feature_importance_regression - does web fetch
50 checkPhase = ''
51 cd $TMPDIR
52 HOME=$TMPDIR OMP_NUM_THREADS=1 pytest -k "not test_feature_importance_regression" --pyargs sklearn
53 '';
54
55 meta = with stdenv.lib; {
56 description = "A set of python modules for machine learning and data mining";
57 changelog = let
58 major = versions.major version;
59 minor = versions.minor version;
60 dashVer = replaceChars ["."] ["-"] version;
61 in
62 "https://scikit-learn.org/stable/whats_new/v${major}.${minor}.html#version-${dashVer}";
63 homepage = "https://scikit-learn.org";
64 license = licenses.bsd3;
65 maintainers = with maintainers; [ ];
66 };
67}