1{ stdenv
2, buildPythonPackage
3, fetchPypi
4, cmake
5, numpy
6, scipy
7, scikitlearn
8, llvmPackages ? null
9}:
10
11buildPythonPackage rec {
12 pname = "lightgbm";
13 version = "2.2.3";
14
15 src = fetchPypi {
16 inherit pname version;
17 sha256 = "40354d21da6bfa73c7ada4d01b2e0b22eaae00f93e90bdaf3fc423020c273890";
18 };
19
20 nativeBuildInputs = [
21 cmake
22 ];
23
24 dontUseCmakeConfigure = true;
25
26 # we never actually explicitly call the install command so this is the only way
27 # to inject these options to it - however, openmp-library doesn't appear to have
28 # any effect, so we have to inject it into NIX_LDFLAGS manually below
29 postPatch = stdenv.lib.optionalString stdenv.cc.isClang ''
30 cat >> setup.cfg <<EOF
31
32 [install]
33 openmp-include-dir=${llvmPackages.openmp}/include
34 openmp-library=${llvmPackages.openmp}/lib/libomp.dylib
35
36 EOF
37 '';
38
39 propagatedBuildInputs = [
40 numpy
41 scipy
42 scikitlearn
43 ];
44
45 postConfigure = ''
46 export HOME=$(mktemp -d)
47 '' + stdenv.lib.optionalString stdenv.cc.isClang ''
48 export NIX_LDFLAGS="$NIX_LDFLAGS -L${llvmPackages.openmp}/lib -lomp"
49 '';
50
51 # The pypi package doesn't distribute the tests from the GitHub
52 # repository. It contains c++ tests which don't seem to wired up to
53 # `make check`.
54 doCheck = false;
55
56 meta = with stdenv.lib; {
57 description = "A fast, distributed, high performance gradient boosting (GBDT, GBRT, GBM or MART) framework";
58 homepage = https://github.com/Microsoft/LightGBM;
59 license = licenses.mit;
60 maintainers = with maintainers; [ teh costrouc ];
61 };
62}