unofficial mirror of guix-patches@gnu.org 
 help / color / mirror / code / Atom feed
From: Vinicius Monego <monego@posteo.net>
To: 48785@debbugs.gnu.org
Cc: Vinicius Monego <monego@posteo.net>
Subject: [bug#48785] [PATCH v2 3/3] gnu: Add python-lightgbm.
Date: Wed, 30 Jun 2021 20:09:19 +0000	[thread overview]
Message-ID: <20210630200919.912223-3-monego@posteo.net> (raw)
In-Reply-To: <20210630200919.912223-1-monego@posteo.net>

* gnu/packages/machine-learning.scm (python-lightgbm): New variable.
---
Replace patch changes with code in 'preparations phase and added phase 'install-liblightgbm

 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 04d1fa0c4d..79bf0bbbfd 100644
--- a/gnu/packages/machine-learning.scm
+++ b/gnu/packages/machine-learning.scm
@@ -1109,6 +1109,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-scipy" ,python-scipy)
+       ("python-scikit-learn" ,python-scikit-learn)))
+    (synopsis "Python frontend for LightGBM")))
+
 (define-public vowpal-wabbit
   ;; Language bindings not included.
   (package
-- 
2.32.0





  parent reply	other threads:[~2021-06-30 20:11 UTC|newest]

Thread overview: 19+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-06-01 22:05 [bug#48785] [PATCH 0/3] Update LightGBM and split frontends Vinicius Monego
2021-06-01 22:06 ` [bug#48785] [PATCH 1/3] gnu: Add fast-double-parser Vinicius Monego
2021-06-01 22:06   ` [bug#48785] [PATCH 2/3] gnu: lightgbm: Update to 3.2.1 Vinicius Monego
2021-06-01 22:06   ` [bug#48785] [PATCH 3/3] gnu: Add python-lightgbm Vinicius Monego
2021-06-30 20:09 ` [bug#48785] [PATCH v2 1/3] gnu: Add fast-double-parser Vinicius Monego
2021-06-30 20:09   ` [bug#48785] [PATCH v2 2/3] gnu: lightgbm: Update to 3.2.1 Vinicius Monego
2021-06-30 20:09   ` Vinicius Monego [this message]
2021-10-08  2:54 ` [bug#48785] [PATCH v3 1/3] gnu: Add fast-double-parser Vinicius Monego
2021-10-08  2:54   ` [bug#48785] [PATCH v3 2/3] gnu: lightgbm: Update to 3.2.1 Vinicius Monego
2021-10-08  2:54   ` [bug#48785] [PATCH v3 3/3] gnu: Add python-lightgbm Vinicius Monego
2021-10-31  1:40 ` [bug#48785] [PATCH v4 1/3] gnu: Add fast-double-parser Vinicius Monego
2021-10-31  1:40   ` [bug#48785] [PATCH v4 2/3] gnu: lightgbm: Update to 3.3.1 Vinicius Monego
2021-10-31  1:40   ` [bug#48785] [PATCH v4 3/3] gnu: Add python-lightgbm Vinicius Monego
2023-04-07 15:17 ` [bug#48785] [PATCH v5 1/3] gnu: Add fast-double-parser Vinicius Monego
2023-04-07 15:17   ` [bug#48785] [PATCH v5 2/3] gnu: lightgbm: Update to 3.3.5 Vinicius Monego
2023-04-07 15:17   ` [bug#48785] [PATCH v5 3/3] gnu: Add python-lightgbm Vinicius Monego
2023-06-26  1:06 ` [bug#48785] [PATCH v6 1/3] gnu: Add fast-double-parser Vinicius Monego
2023-06-26  1:06   ` [bug#48785] [PATCH v6 2/3] gnu: lightgbm: Update to 3.3.5 Vinicius Monego
2023-06-26  1:06   ` [bug#48785] [PATCH v6 3/3] gnu: Add python-lightgbm Vinicius Monego

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://guix.gnu.org/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20210630200919.912223-3-monego@posteo.net \
    --to=monego@posteo.net \
    --cc=48785@debbugs.gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/guix.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).