git.iko.soy/typeable/nixpkgs
on master help sign in
Merge pull request #64711 from risicle/ris-lightgbm-darwin-fix

pythonPackages.lightgbm: fix build on darwin

commitfcc682382a933b5789280d66dd41c7f54ccfdf68 authorworldofpeace <worldofpeace@protonmail.ch> dateTue 23 Jul 2019, 02:47 (7 years ago) parentf41c696ed23412
1 file changed+19−3
pkgs/development/python-modules/lightgbm/default.nix+19−3
pkgs/development/python-modules/lightgbm/default.nix+19−3
@@ -1,10 +1,11 @@
1−{ lib
1+{ stdenv
22, buildPythonPackage
33, fetchPypi
44, cmake
55, numpy
66, scipy
77, scikitlearn
8+, llvmPackages ? null
89}:
910
1011buildPythonPackage rec {
@@ -20,6 +21,19 @@ buildPythonPackage rec {
2021 cmake
2122 ];
2223
24+ # we never actually explicitly call the install command so this is the only way
25+ # to inject these options to it - however, openmp-library doesn't appear to have
26+ # any effect, so we have to inject it into NIX_LDFLAGS manually below
27+ postPatch = stdenv.lib.optionalString stdenv.cc.isClang ''
28+ cat >> setup.cfg <<EOF
29+
30+ [install]
31+ openmp-include-dir=${llvmPackages.openmp}/include
32+ openmp-library=${llvmPackages.openmp}/lib/libomp.dylib
33+
34+ EOF
35+ '';
36+
2337 propagatedBuildInputs = [
2438 numpy
2539 scipy
@@ -28,6 +42,8 @@ buildPythonPackage rec {
2842
2943 postConfigure = ''
3044 export HOME=$(mktemp -d)
45+ '' + stdenv.lib.optionalString stdenv.cc.isClang ''
46+ export NIX_LDFLAGS="$NIX_LDFLAGS -L${llvmPackages.openmp}/lib -lomp"
3147 '';
3248
3349 # The pypi package doesn't distribute the tests from the GitHub
@@ -35,10 +51,10 @@ buildPythonPackage rec {
3551 # `make check`.
3652 doCheck = false;
3753
38− meta = with lib; {
54+ meta = with stdenv.lib; {
3955 description = "A fast, distributed, high performance gradient boosting (GBDT, GBRT, GBM or MART) framework";
4056 homepage = https://github.com/Microsoft/LightGBM;
4157 license = licenses.mit;
42− maintainers = with lib.maintainers; [ teh costrouc ];
58+ maintainers = with maintainers; [ teh costrouc ];
4359 };
4460}