diff mbox series

[bug#48785,v2,2/3] gnu: lightgbm: Update to 3.2.1.

Message ID 20210630200919.912223-2-monego@posteo.net
State New
Headers show
Series [bug#48785,v2,1/3] gnu: Add fast-double-parser. | expand

Checks

Context Check Description
cbaines/comparison success View comparision
cbaines/git branch success View Git branch
cbaines/applying patch success View Laminar job
cbaines/issue success View issue

Commit Message

Vinicius Monego June 30, 2021, 8:09 p.m. UTC
* gnu/packages/machine-learning.scm (lightgbm): Update to 3.2.1.
[source]: Add patch. Make cosmetic changes.
[native-inputs]: Add googletest, opencl-headers.
[inputs]: Add boost, eigen, fast-double-parser, fmt, ocl-icd.
[propagated-inputs]: Remove.
[arguments]: Add #:tests?, #:test-target. Pass "-DBUILD_CPP_TEST=OFF" and
"-DUSE_GPU=ON" to #:configure-flags. Do not replace check phase.
* gnu/packages/patches/lightgbm-use-system-libraries.patch: New file.
* gnu/local.mk (dist_patch_DATA): Add it.
---
Removed the python patch.

 gnu/local.mk                                  |  1 +
 gnu/packages/machine-learning.scm             | 56 ++++++++++--------
 .../lightgbm-use-system-libraries.patch       | 58 +++++++++++++++++++
 3 files changed, 91 insertions(+), 24 deletions(-)
 create mode 100644 gnu/packages/patches/lightgbm-use-system-libraries.patch
diff mbox series

Patch

diff --git a/gnu/local.mk b/gnu/local.mk
index 19db9787dc..fa30cc7e9b 100644
--- a/gnu/local.mk
+++ b/gnu/local.mk
@@ -1386,6 +1386,7 @@  dist_patch_DATA =						\
   %D%/packages/patches/lierolibre-newer-libconfig.patch		\
   %D%/packages/patches/lierolibre-remove-arch-warning.patch	\
   %D%/packages/patches/lierolibre-try-building-other-arch.patch	\
+  %D%/packages/patches/lightgbm-use-system-libraries.patch	\
   %D%/packages/patches/linbox-fix-pkgconfig.patch		\
   %D%/packages/patches/linphone-desktop-without-sdk.patch           \
   %D%/packages/patches/linux-libre-support-for-Pinebook-Pro.patch \
diff --git a/gnu/packages/machine-learning.scm b/gnu/packages/machine-learning.scm
index b8d79821e0..04d1fa0c4d 100644
--- a/gnu/packages/machine-learning.scm
+++ b/gnu/packages/machine-learning.scm
@@ -56,6 +56,7 @@ 
   #:use-module (gnu packages check)
   #:use-module (gnu packages compression)
   #:use-module (gnu packages cmake)
+  #:use-module (gnu packages cpp)
   #:use-module (gnu packages cran)
   #:use-module (gnu packages databases)
   #:use-module (gnu packages dejagnu)
@@ -70,8 +71,10 @@ 
   #:use-module (gnu packages mpi)
   #:use-module (gnu packages ocaml)
   #:use-module (gnu packages onc-rpc)
+  #:use-module (gnu packages opencl)
   #:use-module (gnu packages perl)
   #:use-module (gnu packages pkg-config)
+  #:use-module (gnu packages pretty-print)
   #:use-module (gnu packages protobuf)
   #:use-module (gnu packages python)
   #:use-module (gnu packages python-build)
@@ -1058,33 +1061,38 @@  main intended application of Autograd is gradient-based optimization.")
 (define-public lightgbm
   (package
     (name "lightgbm")
-    (version "2.0.12")
-    (source (origin
-              (method git-fetch)
-              (uri (git-reference
-                     (url "https://github.com/Microsoft/LightGBM")
-                     (commit (string-append "v" version))))
-              (sha256
-               (base32
-                "0jlvyn7k81dzrh9ij3zw576wbgiwmmr26rzpdxjn1dbpc3njpvzi"))
-              (file-name (git-file-name name version))))
+    (version "3.2.1")
+    (source
+     (origin
+       (method git-fetch)
+       (uri (git-reference
+             (url "https://github.com/Microsoft/LightGBM")
+             (commit (string-append "v" version))))
+       (patches
+        (search-patches "lightgbm-use-system-libraries.patch"))
+       (sha256
+        (base32 "1fchiiwl3pz1kpi0kbfanif6c6b688wmmjjbqz4ff4djc6g2sg7z"))
+       (file-name (git-file-name name version))))
     (native-inputs
-     `(("python-pytest" ,python-pytest)
-       ("python-nose" ,python-nose)))
+     `(("googletest" ,googletest)
+       ("opencl-headers" ,opencl-headers)))
     (inputs
-     `(("openmpi" ,openmpi)))
-    (propagated-inputs
-     `(("python-numpy" ,python-numpy)
-       ("python-scipy" ,python-scipy)))
+     `(("boost" ,boost)
+       ("eigen" ,eigen)
+       ("fast-double-parser" ,fast-double-parser)
+       ("fmt" ,fmt)
+       ("ocl-icd" ,ocl-icd)
+       ("openmpi" ,openmpi)))
     (arguments
-     `(#:configure-flags
-       '("-DUSE_MPI=ON")
-       #:phases
-       (modify-phases %standard-phases
-         (replace 'check
-           (lambda _
-             (with-directory-excursion "../source"
-               (invoke "pytest" "tests/c_api_test/test_.py")))))))
+     `(;; FIXME: With 'find_package(GTest CONFIG)' (default), googletest
+       ;; is not found by CMake.  If we replace CONFIG with REQUIRED, the
+       ;; test files fail to link with googletest in the build phase.
+       #:tests? #f
+       #:test-target "testlightgbm"
+       #:configure-flags
+       (list "-DBUILD_CPP_TEST=OFF"
+             "-DUSE_GPU=ON" ;using OpenCL
+             "-DUSE_MPI=ON")))
     (build-system cmake-build-system)
     (home-page "https://github.com/Microsoft/LightGBM")
     (synopsis "Gradient boosting framework based on decision tree algorithms")
diff --git a/gnu/packages/patches/lightgbm-use-system-libraries.patch b/gnu/packages/patches/lightgbm-use-system-libraries.patch
new file mode 100644
index 0000000000..115ca02775
--- /dev/null
+++ b/gnu/packages/patches/lightgbm-use-system-libraries.patch
@@ -0,0 +1,58 @@ 
+From 894648291b9629d51785e4fd1cae820d2858e039 Mon Sep 17 00:00:00 2001
+From: Vinicius Monego <monego@posteo.net>
+Date: Mon, 31 May 2021 21:23:52 -0300
+Subject: [PATCH] Use system libraries.
+
+---
+ CMakeLists.txt                  | 11 ++++++++---
+ include/LightGBM/utils/common.h |  4 ++--
+ 2 files changed, 10 insertions(+), 5 deletions(-)
+
+diff --git a/CMakeLists.txt b/CMakeLists.txt
+index b845f36..560e477 100644
+--- a/CMakeLists.txt
++++ b/CMakeLists.txt
+@@ -93,9 +93,6 @@ if(USE_SWIG)
+   endif()
+ endif(USE_SWIG)
+ 
+-SET(EIGEN_DIR "${PROJECT_SOURCE_DIR}/external_libs/eigen")
+-include_directories(${EIGEN_DIR})
+-
+ # See https://gitlab.com/libeigen/eigen/-/blob/master/COPYING.README
+ ADD_DEFINITIONS(-DEIGEN_MPL2_ONLY)
+ 
+@@ -399,6 +396,14 @@ if(USE_SWIG)
+   endif()
+ endif(USE_SWIG)
+ 
++find_package (Eigen3 3.3 REQUIRED NO_MODULE)
++TARGET_LINK_LIBRARIES (lightgbm Eigen3::Eigen)
++TARGET_LINK_LIBRARIES (_lightgbm Eigen3::Eigen)
++
++find_package(fmt)
++TARGET_LINK_LIBRARIES(lightgbm fmt::fmt)
++TARGET_LINK_LIBRARIES(_lightgbm fmt::fmt)
++
+ if(USE_MPI)
+   TARGET_LINK_LIBRARIES(lightgbm ${MPI_CXX_LIBRARIES})
+   TARGET_LINK_LIBRARIES(_lightgbm ${MPI_CXX_LIBRARIES})
+diff --git a/include/LightGBM/utils/common.h b/include/LightGBM/utils/common.h
+index 4357357..00101a5 100644
+--- a/include/LightGBM/utils/common.h
++++ b/include/LightGBM/utils/common.h
+@@ -32,9 +32,9 @@
+ 
+ #if (!((defined(sun) || defined(__sun)) && (defined(__SVR4) || defined(__svr4__))))
+ #define FMT_HEADER_ONLY
+-#include "../../../external_libs/fmt/include/fmt/format.h"
++#include "fmt/format.h"
+ #endif
+-#include "../../../external_libs/fast_double_parser/include/fast_double_parser.h"
++#include "fast_double_parser.h"
+ 
+ #ifdef _MSC_VER
+ #include <intrin.h>
+-- 
+2.31.1
+