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}:
12
13buildPythonPackage rec {
14 pname = "scikit-learn";
15 version = "0.21.3";
16 # UnboundLocalError: local variable 'message' referenced before assignment
17 disabled = stdenv.isi686; # https://github.com/scikit-learn/scikit-learn/issues/5534
18
19 src = fetchPypi {
20 inherit pname version;
21 sha256 = "eb9b8ebf59eddd8b96366428238ab27d05a19e89c5516ce294abc35cea75d003";
22 };
23
24 buildInputs = [
25 pillow
26 gfortran
27 glibcLocales
28 ] ++ lib.optionals stdenv.cc.isClang [
29 llvmPackages.openmp
30 ];
31
32 nativeBuildInputs = [
33 cython
34 ];
35
36 propagatedBuildInputs = [
37 numpy
38 scipy
39 numpy.blas
40 joblib
41 ];
42 checkInputs = [ pytest ];
43
44 patches = [
45 # Fixes tests by changing threshold of a test-case that broke
46 # with numpy versions >= 1.17. This should be removed for versions > 0.21.2.
47 ( fetchpatch {
48 url = "https://github.com/scikit-learn/scikit-learn/commit/b730befc821caec5b984d9ff3aa7bc4bd7f4d9bb.patch";
49 sha256 = "0z36m05mv6d494qwq0688rgwa7c4bbnm5s2rcjlrp29fwn3fy1bv";
50 })
51 ];
52
53 LC_ALL="en_US.UTF-8";
54
55 doCheck = !stdenv.isAarch64;
56 # Skip test_feature_importance_regression - does web fetch
57 checkPhase = ''
58 cd $TMPDIR
59 HOME=$TMPDIR OMP_NUM_THREADS=1 pytest -k "not test_feature_importance_regression" --pyargs sklearn
60 '';
61
62 meta = with stdenv.lib; {
63 description = "A set of python modules for machine learning and data mining";
64 homepage = http://scikit-learn.org;
65 license = licenses.bsd3;
66 maintainers = with maintainers; [ ];
67 };
68}