[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[bug#48785] [PATCH v3 3/3] gnu: Add python-lightgbm.
From: |
Vinicius Monego |
Subject: |
[bug#48785] [PATCH v3 3/3] gnu: Add python-lightgbm. |
Date: |
Fri, 8 Oct 2021 02:54:09 +0000 |
* gnu/packages/machine-learning.scm (python-lightgbm): New variable.
---
Rebase only.
gnu/packages/machine-learning.scm | 59 +++++++++++++++++++++++++++++++
1 file changed, 59 insertions(+)
diff --git a/gnu/packages/machine-learning.scm
b/gnu/packages/machine-learning.scm
index 99d864a25c..e7ce107637 100644
--- a/gnu/packages/machine-learning.scm
+++ b/gnu/packages/machine-learning.scm
@@ -1271,6 +1271,65 @@ the following advantages:
@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
+ `(#:configure-flags (list "--precompile")
+ #:phases
+ (modify-phases %standard-phases
+ (add-after 'unpack 'preparations
+ (lambda _
+ (setenv "HOME" "/tmp") ;to write a log file
+ ;; Move Python files to source root to silence some warnings.
+ (rename-file "python-package/setup.py" "setup.py")
+ (rename-file "python-package/README.rst" "README.rst")
+ (rename-file "python-package/lightgbm" "lightgbm")
+ ;; Install version file to read the library's version.
+ (with-output-to-file "lightgbm/VERSION.txt"
+ (lambda ()
+ (display ,(package-version lightgbm))))
+ ;; Skip building the shared library.
+ (substitute* "setup.py"
+ (("'install_lib': CustomInstallLib,") ""))))
+ (add-after 'install 'install-liblightgbm
+ (lambda* (#:key inputs outputs #:allow-other-keys)
+ (let* ((out (assoc-ref outputs "out"))
+ (pylib (string-append out "/lib/python"
+ ,(version-major+minor
+ (package-version python))
+ "/site-packages"))
+ (lgbdir (string-append pylib "/lightgbm"))
+ (lib-lightgbm (string-append (assoc-ref inputs "lightgbm")
+ "/lib/lib_lightgbm.so")))
+ ;; This symlink is necessary for tests.
+ (symlink lib-lightgbm "lightgbm/lib_lightgbm.so")
+ ;; And this one for runtime.
+ (mkdir-p (string-append lgbdir "/lib"))
+ (symlink lib-lightgbm (string-append lgbdir
+ "/lib_lightgbm.so")))))
+ (replace 'check
+ (lambda* (#:key inputs outputs tests? #:allow-other-keys)
+ (when tests?
+ (add-installed-pythonpath inputs outputs)
+ (invoke "python" "-m" "pytest"
+ "tests/python_package_test")))))))
+ (native-inputs
+ `(("python-psutil" ,python-psutil)
+ ("python-pytest" ,python-pytest)
+ ("python-wheel" ,python-wheel)))
+ (inputs
+ `(("lightgbm" ,lightgbm)))
+ (propagated-inputs
+ `(("python-numpy" ,python-numpy)
+ ("python-pandas" ,python-pandas)
+ ("python-scikit-learn" ,python-scikit-learn)
+ ("python-scipy" ,python-scipy)))
+ (synopsis "Python frontend for LightGBM")))
+
(define-public vowpal-wabbit
;; Language bindings not included.
(package
--
2.30.2