about summary refs log tree commit diff
path: root/pkgs
diff options
context:
space:
mode:
authorAndrew Dunham <andrew@du.nham.ca>2018-03-14 18:17:55 -0700
committerNikolay Amiantov <ab@fmap.me>2018-03-15 04:17:55 +0300
commit92a77abd31e6c252390b1baa8a25553909e3f344 (patch)
tree04490a34ccf4525cebb7adc66aff8f196e6edb9f /pkgs
parent80582c600dadd6bd2a15f64a4e3e7da074adc71d (diff)
downloadnixlib-92a77abd31e6c252390b1baa8a25553909e3f344.tar
nixlib-92a77abd31e6c252390b1baa8a25553909e3f344.tar.gz
nixlib-92a77abd31e6c252390b1baa8a25553909e3f344.tar.bz2
nixlib-92a77abd31e6c252390b1baa8a25553909e3f344.tar.lz
nixlib-92a77abd31e6c252390b1baa8a25553909e3f344.tar.xz
nixlib-92a77abd31e6c252390b1baa8a25553909e3f344.tar.zst
nixlib-92a77abd31e6c252390b1baa8a25553909e3f344.zip
xgboost: Enable building on Darwin (#37046)
* xgboost: Enable building on Darwin

* Review feedback: pass `xgboost` to the python package
Diffstat (limited to 'pkgs')
-rw-r--r--pkgs/development/libraries/xgboost/default.nix11
-rw-r--r--pkgs/development/python-modules/xgboost/default.nix35
-rw-r--r--pkgs/top-level/python-packages.nix24
3 files changed, 44 insertions, 26 deletions
diff --git a/pkgs/development/libraries/xgboost/default.nix b/pkgs/development/libraries/xgboost/default.nix
index 0d86c8628913..7865724efa40 100644
--- a/pkgs/development/libraries/xgboost/default.nix
+++ b/pkgs/development/libraries/xgboost/default.nix
@@ -2,6 +2,7 @@
 , avxSupport ? false
 , cudaSupport ? false, cudatoolkit
 , ncclSupport ? false, nccl
+, llvmPackages
 }:
 
 assert ncclSupport -> cudaSupport;
@@ -19,7 +20,7 @@ stdenv.mkDerivation rec {
 
   enableParallelBuilding = true;
 
-  nativeBuildInputs = [ cmake ];
+  nativeBuildInputs = [ cmake ] ++ lib.optional stdenv.isDarwin llvmPackages.openmp;
 
   buildInputs = lib.optional cudaSupport cudatoolkit
                 ++ lib.optional ncclSupport nccl;
@@ -27,10 +28,12 @@ stdenv.mkDerivation rec {
   cmakeFlags = lib.optionals cudaSupport [ "-DUSE_CUDA=ON" "-DCUDA_HOST_COMPILER=${cudatoolkit.cc}/bin/cc" ]
                ++ lib.optional ncclSupport "-DUSE_NCCL=ON";
 
-  installPhase = ''
+  installPhase = let
+    libname = if stdenv.isDarwin then "libxgboost.dylib" else "libxgboost.so";
+  in ''
     mkdir -p $out
     cp -r ../include $out
-    install -Dm755 ../lib/libxgboost.so $out/lib/libxgboost.so
+    install -Dm755 ../lib/${libname} $out/lib/${libname}
     install -Dm755 ../xgboost $out/bin/xgboost
   '';
 
@@ -38,7 +41,7 @@ stdenv.mkDerivation rec {
     description = "Scalable, Portable and Distributed Gradient Boosting (GBDT, GBRT or GBM) Library";
     homepage = https://github.com/dmlc/xgboost;
     license = licenses.asl20;
-    platforms = [ "x86_64-linux" "i686-linux" ];
+    platforms = [ "x86_64-linux" "i686-linux" "x86_64-darwin" ];
     maintainers = with maintainers; [ abbradar ];
   };
 }
diff --git a/pkgs/development/python-modules/xgboost/default.nix b/pkgs/development/python-modules/xgboost/default.nix
new file mode 100644
index 000000000000..217c823afe57
--- /dev/null
+++ b/pkgs/development/python-modules/xgboost/default.nix
@@ -0,0 +1,35 @@
+{ stdenv
+, lib
+, pkgs
+, buildPythonPackage
+, nose
+, scipy
+, xgboost
+}:
+
+buildPythonPackage rec {
+  name = "xgboost-${version}";
+
+  inherit (xgboost) version src meta;
+
+  propagatedBuildInputs = [ scipy ];
+  checkInputs = [ nose ];
+
+  postPatch = let
+    libname = if stdenv.isDarwin then "libxgboost.dylib" else "libxgboost.so";
+
+  in ''
+    cd python-package
+
+    sed "s/CURRENT_DIR = os.path.dirname(__file__)/CURRENT_DIR = os.path.abspath(os.path.dirname(__file__))/g" -i setup.py
+    sed "/^LIB_PATH.*/a LIB_PATH = [os.path.relpath(LIB_PATH[0], CURRENT_DIR)]" -i setup.py
+    cat <<EOF >xgboost/libpath.py
+    def find_lib_path():
+      return ["${xgboost}/lib/${libname}"]
+    EOF
+  '';
+
+  postInstall = ''
+    rm -rf $out/xgboost
+  '';
+}
diff --git a/pkgs/top-level/python-packages.nix b/pkgs/top-level/python-packages.nix
index 253575fba0bb..9220b9e98ca6 100644
--- a/pkgs/top-level/python-packages.nix
+++ b/pkgs/top-level/python-packages.nix
@@ -20076,28 +20076,8 @@ EOF
     };
   };
 
-  xgboost = buildPythonPackage rec {
-    name = "xgboost-${version}";
-
-    inherit (pkgs.xgboost) version src meta;
-
-    propagatedBuildInputs = with self; [ scipy ];
-    checkInputs = with self; [ nose ];
-
-    postPatch = ''
-      cd python-package
-
-      sed "s/CURRENT_DIR = os.path.dirname(__file__)/CURRENT_DIR = os.path.abspath(os.path.dirname(__file__))/g" -i setup.py
-      sed "/^LIB_PATH.*/a LIB_PATH = [os.path.relpath(LIB_PATH[0], CURRENT_DIR)]" -i setup.py
-      cat <<EOF >xgboost/libpath.py
-      def find_lib_path():
-        return ["${pkgs.xgboost}/lib/libxgboost.so"]
-      EOF
-    '';
-
-    postInstall = ''
-      rm -rf $out/xgboost
-    '';
+  xgboost = callPackage ../development/python-modules/xgboost {
+    xgboost = pkgs.xgboost;
   };
 
   xkcdpass = buildPythonPackage rec {