From patchwork Fri Apr 7 15:17:17 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vinicius Monego X-Patchwork-Id: 49016 Return-Path: X-Original-To: patchwork@mira.cbaines.net Delivered-To: patchwork@mira.cbaines.net Received: by mira.cbaines.net (Postfix, from userid 113) id 8D04617421; Fri, 7 Apr 2023 16:18:37 +0100 (BST) X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on mira.cbaines.net X-Spam-Level: X-Spam-Status: No, score=-1.8 required=5.0 tests=DKIM_INVALID,DKIM_SIGNED, MAILING_LIST_MULTI,RCVD_IN_MSPIKE_H2,SPF_HELO_PASS,URIBL_BLOCKED autolearn=unavailable autolearn_force=no version=3.4.6 Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mira.cbaines.net (Postfix) with ESMTPS id EB951173A7 for ; Fri, 7 Apr 2023 16:18:35 +0100 (BST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1pknqm-0002Vx-9f; Fri, 07 Apr 2023 11:18:04 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1pknql-0002VY-DN for guix-patches@gnu.org; Fri, 07 Apr 2023 11:18:03 -0400 Received: from debbugs.gnu.org ([209.51.188.43]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1pknql-0004UJ-59 for guix-patches@gnu.org; Fri, 07 Apr 2023 11:18:03 -0400 Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1pknql-0007zi-1k for guix-patches@gnu.org; Fri, 07 Apr 2023 11:18:03 -0400 X-Loop: help-debbugs@gnu.org Subject: [bug#48785] [PATCH v5 3/3] gnu: Add python-lightgbm. Resent-From: Vinicius Monego Original-Sender: "Debbugs-submit" Resent-CC: guix-patches@gnu.org Resent-Date: Fri, 07 Apr 2023 15:18:03 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 48785 X-GNU-PR-Package: guix-patches X-GNU-PR-Keywords: patch To: 48785@debbugs.gnu.org Cc: Vinicius Monego Received: via spool by 48785-submit@debbugs.gnu.org id=B48785.168088066330690 (code B ref 48785); Fri, 07 Apr 2023 15:18:03 +0000 Received: (at 48785) by debbugs.gnu.org; 7 Apr 2023 15:17:43 +0000 Received: from localhost ([127.0.0.1]:57055 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1pknqR-0007yv-FF for submit@debbugs.gnu.org; Fri, 07 Apr 2023 11:17:43 -0400 Received: from mout01.posteo.de ([185.67.36.65]:50835) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1pknqO-0007yP-QB for 48785@debbugs.gnu.org; Fri, 07 Apr 2023 11:17:42 -0400 Received: from submission (posteo.de [185.67.36.169]) by mout01.posteo.de (Postfix) with ESMTPS id 49E1B24027F for <48785@debbugs.gnu.org>; Fri, 7 Apr 2023 17:17:35 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=posteo.net; s=2017; t=1680880655; bh=G8dFfDtfqDiXDa5uP7HwtHSZfbDzYan/Bj8mDwcJVBc=; h=From:To:Cc:Subject:Date:From; b=lL7kCc+8eiUT7O6nzoiTqSzY+6LHNT5aAjK1adGl36yF+5l7U7mKDtoyx71VpBs1h /uFElNDA4hqPdaIz/IGtAACIvVDYNL9JJ/Kt7WhUsPIhQCaWHEM7HmBxgRNWGg7Nmm 9Z9VavtNZ5VUOcNS+hB/Y4wzKH9qq63FvWIWW1w0gjbr2MImrzROBUKZt7eZbNTuXL flNaZS7nnr7Rphtmmrq6onHJtE4w62v+Yh3nHOfLdYerlPxlngg/n3GdY555GGrcZg gOnvmYnQRjWyFVDaZiXGZ+ZGxUKbDQF6ZZysyz0Q4ptsWkIK7cKk7cXFiTwRu9IBl0 om5uPf5x9Qb9Q== Received: from customer (localhost [127.0.0.1]) by submission (posteo.de) with ESMTPSA id 4PtMRy1wB8z6trm; Fri, 7 Apr 2023 17:17:34 +0200 (CEST) From: Vinicius Monego Date: Fri, 7 Apr 2023 15:17:17 +0000 Message-Id: <20230407151717.1429006-3-monego@posteo.net> In-Reply-To: <20230407151717.1429006-1-monego@posteo.net> References: <20230407151717.1429006-1-monego@posteo.net> MIME-Version: 1.0 X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-BeenThere: guix-patches@gnu.org List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: guix-patches-bounces+patchwork=mira.cbaines.net@gnu.org Sender: guix-patches-bounces+patchwork=mira.cbaines.net@gnu.org X-getmail-retrieved-from-mailbox: Patches * 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