1{ lib
2, stdenv
3, buildPythonPackage
4, fetchPypi
5, cmake
6, numpy
7, scipy
8, scikit-learn
9, llvmPackages ? null
10, pythonOlder
11, python
12, ocl-icd
13, opencl-headers
14, boost
15, gpuSupport ? stdenv.isLinux
16}:
17
18buildPythonPackage rec {
19 pname = "lightgbm";
20 version = "3.3.5";
21 format = "setuptools";
22
23 disabled = pythonOlder "3.7";
24
25 src = fetchPypi {
26 inherit pname version;
27 hash = "sha256-ELj73PhR5PaKHwLzjZm9xEx8f7mxpi3PkkoNKf9zOVw=";
28 };
29
30 nativeBuildInputs = [
31 cmake
32 ];
33
34 dontUseCmakeConfigure = true;
35
36 buildInputs = (lib.optionals stdenv.cc.isClang [
37 llvmPackages.openmp
38 ]) ++ (lib.optionals gpuSupport [
39 boost
40 ocl-icd
41 opencl-headers
42 ]);
43
44 propagatedBuildInputs = [
45 numpy
46 scipy
47 scikit-learn
48 ];
49
50 buildPhase = ''
51 runHook preBuild
52
53 ${python.pythonForBuild.interpreter} setup.py bdist_wheel ${lib.optionalString gpuSupport "--gpu"}
54
55 runHook postBuild
56 '';
57
58 postConfigure = ''
59 export HOME=$(mktemp -d)
60 '';
61
62 # The pypi package doesn't distribute the tests from the GitHub
63 # repository. It contains c++ tests which don't seem to wired up to
64 # `make check`.
65 doCheck = false;
66
67 pythonImportsCheck = [
68 "lightgbm"
69 ];
70
71 meta = {
72 description = "A fast, distributed, high performance gradient boosting (GBDT, GBRT, GBM or MART) framework";
73 homepage = "https://github.com/Microsoft/LightGBM";
74 changelog = "https://github.com/microsoft/LightGBM/releases/tag/v${version}";
75 license = lib.licenses.mit;
76 maintainers = with lib.maintainers; [ teh costrouc ];
77 };
78}