GNU bug report logs - #48785
[PATCH 0/3] Update LightGBM and split frontends.

Previous Next

Package: guix-patches;

Reported by: Vinicius Monego <monego <at> posteo.net>

Date: Tue, 1 Jun 2021 22:06:01 UTC

Severity: normal

Tags: patch

Full log


View this message in rfc822 format

From: Vinicius Monego <monego <at> posteo.net>
To: 48785 <at> debbugs.gnu.org
Cc: Vinicius Monego <monego <at> posteo.net>
Subject: [bug#48785] [PATCH v5 3/3] gnu: Add python-lightgbm.
Date: Fri,  7 Apr 2023 15:17:17 +0000
* gnu/packages/machine-learning.scm (python-lightgbm): New variable.
---
 gnu/packages/machine-learning.scm | 55 +++++++++++++++++++++++++++++++
 1 file changed, 55 insertions(+)

diff --git a/gnu/packages/machine-learning.scm b/gnu/packages/machine-learning.scm
index 248e318eea..1585f09992 100644
--- a/gnu/packages/machine-learning.scm
+++ b/gnu/packages/machine-learning.scm
@@ -1511,6 +1511,61 @@ (define-public lightgbm
 @end itemize\n")
     (license license:expat)))
 
+(define-public python-lightgbm
+  (package
+    (inherit lightgbm)
+    (name "python-lightgbm")
+    (source (package-source lightgbm))
+    (build-system python-build-system)
+    (arguments
+     (list #:configure-flags #~(list "--precompile") ; use our library
+           #:phases
+           #~(modify-phases %standard-phases
+               (add-after 'unpack 'preparations
+                 (lambda _
+                   (setenv "HOME" "/tmp") ; to write a log file
+                   (rename-file "python-package/setup.py" "setup.py")
+                   (rename-file "python-package/README.rst" "README.rst")
+                   (rename-file "python-package/lightgbm" "lightgbm")
+                   ;; Write the version so the module identifies it.
+                   (with-output-to-file "lightgbm/VERSION.txt"
+                     (lambda () (display #$(package-version lightgbm))))
+                   ;; Manually install the lib.
+                   (substitute* "setup.py"
+                     (("'install_lib': CustomInstallLib,") ""))))
+               (add-after 'install 'install-liblightgbm
+                 ;; LightGBM's setup.py hardcodes LIB_PATH to look for
+                 ;; lib_lightgbm.so in this source, which we can't modify.
+                 ;; So, we symlink it in the install phase.
+                 (lambda _
+                   (let* ((pylib (string-append #$output
+                                                "/lib/python"
+                                                #$(version-major+minor
+                                                   (package-version
+                                                    python))
+                                                "/site-packages"))
+                          (lgbdir (string-append pylib "/lightgbm"))
+                          (lib-lightgbm (string-append
+                                         #$(this-package-input "lightgbm")
+                                         "/lib/lib_lightgbm.so")))
+                     ;; For whatever reason, the first symlink is required for
+                     ;; the check phase and the second for sanity-check.
+                     (symlink lib-lightgbm "lightgbm/lib_lightgbm.so")
+                     (mkdir-p (string-append lgbdir "/lib"))
+                     (symlink lib-lightgbm
+                              (string-append lgbdir
+                                             "/lib_lightgbm.so")))))
+               (replace 'check
+                 (lambda* (#:key tests? #:allow-other-keys)
+                   (when tests?
+                     (invoke "python" "-m" "pytest"
+                             "tests/python_package_test")))))))
+    (native-inputs (list python-psutil python-pytest python-wheel))
+    (inputs (list lightgbm))
+    (propagated-inputs (list python-numpy python-pandas python-scikit-learn
+                             python-scipy))
+    (synopsis "Python interface for LightGBM")))
+
 (define-public vowpal-wabbit
   ;; Language bindings not included.
   (package
-- 
2.34.1





This bug report was last modified 1 year and 353 days ago.

Previous Next


GNU bug tracking system
Copyright (C) 1999 Darren O. Benham, 1997,2003 nCipher Corporation Ltd, 1994-97 Ian Jackson.