Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

New package: {sci-libs,dev-python}/lightgbm #1308

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions dev-python/lightgbm/Manifest
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
DIST lightgbm-4.5.0.tar.gz 1701072 BLAKE2B 1323d27ad7f34b43699c7d6605d34a6cbca4c85ace1ffdecfd3d169132c6bf97ae23b48634957af093d235f37c85d7ad157a16d93b15eab4ad5bae38ac938aff SHA512 66cf32bd9dc9cd74629052e59b6fe8e404c264a9ef529d40b073685c5ded9a1deb028e78b7ccff48cfe78f29fcc9746ec957a38b14d86c7fa89fd3ed88fbf6ac
14 changes: 14 additions & 0 deletions dev-python/lightgbm/files/lightgbm-4.5.0-loadlib.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
Index: lightgbm-4.5.0/lightgbm/basic.py
===================================================================
--- lightgbm-4.5.0.orig/lightgbm/basic.py
+++ lightgbm-4.5.0/lightgbm/basic.py
@@ -261,8 +261,7 @@ def _log_callback(msg: bytes) -> None:

def _load_lib() -> ctypes.CDLL:
"""Load LightGBM library."""
- lib_path = find_lib_path()
- lib = ctypes.cdll.LoadLibrary(lib_path[0])
+ lib = ctypes.cdll.LoadLibrary("lib_lightgbm.so")
lib.LGBM_GetLastError.restype = ctypes.c_char_p
callback = ctypes.CFUNCTYPE(None, ctypes.c_char_p)
lib.callback = callback(_log_callback) # type: ignore[attr-defined]
30 changes: 30 additions & 0 deletions dev-python/lightgbm/lightgbm-4.5.0.ebuild
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
# Copyright 1999-2022 Gentoo Authors
# Distributed under the terms of the GNU General Public License v2

EAPI=8

PYTHON_COMPAT=( python3_{10..12} )
DISTUTILS_USE_PEP517=scikit-build-core

inherit distutils-r1 pypi

DESCRIPTION="LightGBM Python Package"
HOMEPAGE="https://github.com/microsoft/LightGBM"
SRC_URI="$(pypi_sdist_url "${PN^}" "${PV}")"

LICENSE="MIT"
SLOT="0"
KEYWORDS="~amd64"

RDEPEND="dev-python/wheel[${PYTHON_USEDEP}]
dev-python/numpy[${PYTHON_USEDEP}]
dev-python/scipy[${PYTHON_USEDEP}]
dev-python/scikit-learn[${PYTHON_USEDEP}]
sci-libs/lightgbm"
distutils_enable_tests pytest

PATCHES=( "${FILESDIR}/${PN}-4.5.0-loadlib.patch" )

python_compile() {
SKBUILD_WHEEL_CMAKE=false distutils-r1_python_compile
}
14 changes: 14 additions & 0 deletions dev-python/lightgbm/metadata.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE pkgmetadata SYSTEM 'http://www.gentoo.org/dtd/metadata.dtd'>
<pkgmetadata>
<maintainer type="person">
<email>[email protected]</email>
</maintainer>
<maintainer type="person">
<email>[email protected]</email>
</maintainer>
<upstream>
<remote-id type="github">microsoft/LightGBM</remote-id>
<remote-id type="pypi">Lightgbm</remote-id>
</upstream>
</pkgmetadata>
5 changes: 5 additions & 0 deletions sci-libs/lightgbm/Manifest
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
DIST LightGBM-4.5.0.tar.gz 6163768 BLAKE2B ad5c737bd18b60617e5b7a8f95845b4e0f5ff522a0a16d995b12109e73aa3dc224dd32f621500196b465842aeeb3bd62c483d0f8646ec53cc43bf90788da8b95 SHA512 f968f984a0881a5eadd898dded367b799b619e3cc80415dec8b623897e84d7e1e1034f20179125354b93759ea1b8a3e334cfa506427442810ef098bc93fd4634
DIST compute-36350b7d.tar.gz 377161 BLAKE2B cf9ed88b147fc07d7d0c562f699d5ea660c085860c6a44de2fb8585cd2574141a48aa939024fbbbbe9a0ded38de955f3f3be31b7b8481edfaf22ff14ce842956 SHA512 66ab1b8182e0a06f8a1fb3e59b2fb94bae89e7b72f8ec8d14d40811751768721d399c00cbacb74c6d55c11d91cc8b827409be07d8411a0f4c9daf3be57238bee
DIST double-conversion-f4cb2384.tar.gz 7027061 BLAKE2B d08b61b51728ff3ee01a1bd6c4aaed70c1afca6e8202920f4b01f79f6500a1ab230e4daf73fe0fd24f79e2135853051c8600ea89e8e331f36bd70875871af57d SHA512 8a0dfabe25b40d13a00417df0779a86477ce994e98ce7dfc7196464bf83fd8f29fbb8153a1419be9354b2afbb04645b41a0d103bfe847468de0cc9800644b7ba
DIST fast_double_parser-efec0353.tar.gz 636133 BLAKE2B 5a0244b4ddf1a0eae52cc26ae0749c2ca34f76f665160635eea94da4db0915b4d848cf2ba09c7173c058e2da305a89f6e90517d703e36a2ed565eabc264811de SHA512 2917167f05a270253b4c6360b598a69df43e8305601abb59d12c4085dd5db0b93b0e8725f61595a0424f0a26b59ec1a97d58df1ab33674ce36f0da9bd818c485
DIST fmt-f5e54359.tar.gz 851890 BLAKE2B 025d29873ea8c65580c4681410d03d3dfaddde6daf18c436bf4a3f97be53d73439cf41e32e051095cb5b838560ddcd22f986c66300753155fd3e10dff16034d3 SHA512 0810d7d96d96aea0d02648eb5d201f8bed22d0b0ddc0ed22e7d4f4dd11ea05bf90fc23e067c274f16e1ff566d0326942ccd55696cdab1a4a9ba01e6553280999
13 changes: 13 additions & 0 deletions sci-libs/lightgbm/files/lightgbm-4.5.0-eigen3.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
Index: LightGBM/src/treelearner/linear_tree_learner.cpp
===================================================================
--- LightGBM.orig/src/treelearner/linear_tree_learner.cpp
+++ LightGBM/src/treelearner/linear_tree_learner.cpp
@@ -4,7 +4,7 @@
*/
#include "linear_tree_learner.h"

-#include <Eigen/Dense>
+#include "eigen3/Eigen/Dense"

#include <algorithm>

36 changes: 36 additions & 0 deletions sci-libs/lightgbm/files/lightgbm-4.5.0-libdir.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
From 9512c085f7a453a40ce85ce86233c5c6d32c7aaf Mon Sep 17 00:00:00 2001
From: Yiyang Wu <[email protected]>
Date: Fri, 8 Nov 2024 20:23:00 +0800
Subject: [PATCH] Use cmake default install location

Install 64bit dynamic and static libs to lib is not allowed in some
distributions

Reference: https://cmake.org/cmake/help/latest/command/install.html#signatures
Signed-off-by: Yiyang Wu <[email protected]>
---
CMakeLists.txt | 8 +-------
1 file changed, 1 insertion(+), 7 deletions(-)

diff --git a/CMakeLists.txt b/CMakeLists.txt
index 183ef62b..b558b67b 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -829,13 +829,7 @@ if(APPLE AND USE_OPENMP AND NOT BUILD_STATIC_LIB)
)
endif()

-install(
- TARGETS _lightgbm
- RUNTIME DESTINATION ${CMAKE_INSTALL_PREFIX}/bin
- LIBRARY DESTINATION ${CMAKE_INSTALL_PREFIX}/lib
- ARCHIVE DESTINATION ${CMAKE_INSTALL_PREFIX}/lib
-)
-
+install( TARGETS _lightgbm )
if(INSTALL_HEADERS)
install(
DIRECTORY ${LightGBM_HEADER_DIR}/LightGBM
--
2.47.0

49 changes: 49 additions & 0 deletions sci-libs/lightgbm/lightgbm-4.5.0.ebuild
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
# Copyright 1999-2022 Gentoo Authors
# Distributed under the terms of the GNU General Public License v2

EAPI=8

inherit cmake cuda

DESCRIPTION="Gradient boosting framework (GBM) based on decision tree algorithms"
HOMEPAGE="https://github.com/microsoft/LightGBM"
SRC_URI="https://github.com/microsoft/LightGBM/archive/refs/tags/v${PV}.tar.gz -> LightGBM-${PV}.tar.gz
https://github.com/boostorg/compute/archive/36350b7d.tar.gz -> compute-36350b7d.tar.gz
https://github.com/google/double-conversion/archive/f4cb2384.tar.gz -> double-conversion-f4cb2384.tar.gz
https://github.com/lemire/fast_double_parser/archive/efec0353.tar.gz -> fast_double_parser-efec0353.tar.gz
https://github.com/fmtlib/fmt/archive/f5e54359.tar.gz -> fmt-f5e54359.tar.gz"
S="${WORKDIR}/LightGBM-${PV}"

LICENSE="MIT"
SLOT="0"
KEYWORDS="~amd64"
IUSE="cuda"

RDEPEND="cuda? ( >=dev-util/nvidia-cuda-toolkit-11 )"
DEPEND=">=dev-cpp/eigen-3.4"

PATCHES=( "${FILESDIR}"/${PN}-4.5.0-eigen3.patch
"${FILESDIR}"/${PN}-4.5.0-libdir.patch )

src_prepare() {
rmdir external_libs/compute && ln -sv "${WORKDIR}"/compute-36350b7de849300bd3d72a05d8bf890ca405a014 external_libs/compute || die
rmdir external_libs/fast_double_parser/benchmarks/dependencies/double-conversion && ln -sv "${WORKDIR}"/double-conversion-f4cb2384efa55dee0e6652f8674b05763441ab09 external_libs/fast_double_parser/benchmarks/dependencies/double-conversion || die
rmdir external_libs/fast_double_parser && ln -sv "${WORKDIR}"/fast_double_parser-efec03532ef65984786e5e32dbc81f6e6a55a115 external_libs/fast_double_parser || die
rmdir external_libs/fmt && ln -sv "${WORKDIR}"/fmt-f5e54359df4c26b6230fc61d38aa294581393084 external_libs/fmt || die
cmake_src_prepare
use cuda && cuda_src_prepare
}

src_configure() {
local mycmakeargs=()
if use cuda; then
# Host compiler should also be nvcc compatible,
# or error occur in the final linking
# CMakeLists also ensures that, so configure fails if we just set CMAKE_CUDA_FLAGS
PATH="$(cuda_gccdir):${PATH}"
mycmakeargs+=(
-DUSE_CUDA=ON
)
fi
cmake_src_configure
}
13 changes: 13 additions & 0 deletions sci-libs/lightgbm/metadata.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE pkgmetadata SYSTEM 'http://www.gentoo.org/dtd/metadata.dtd'>
<pkgmetadata>
<maintainer type="person">
<email>[email protected]</email>
</maintainer>
<maintainer type="person">
<email>[email protected]</email>
</maintainer>
<upstream>
<remote-id type="github">microsoft/LightGBM</remote-id>
</upstream>
</pkgmetadata>
Loading