@@ -1839,6 +1839,45 @@ (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,") ""))
+ ;; Change lib_path to look for our package's lib.
+ (substitute* "lightgbm/libpath.py"
+ (("lib_path = \\[str\\(p\\) for p in dll_path if p\\.is_file\\(\\)]")
+ ;; lib_path is a list of paths.
+ (format #f "lib_path = ['~a/lib/lib_lightgbm.so']"
+ #$(this-package-input "lightgbm"))))))
+ (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