From 274e70aa392291e5ff4ddbe17f83890407341d38 Mon Sep 17 00:00:00 2001 From: Gaetan Lepage Date: Fri, 28 Feb 2025 23:21:52 +0100 Subject: [PATCH] [python312Packages.]lightgbm: 4.5.0 -> 4.6.0 Diff: https://github.com/microsoft/lightgbm/compare/v4.5.0...v4.6.0 Changelog: https://github.com/microsoft/LightGBM/releases/tag/v4.6.0 --- pkgs/by-name/li/lightgbm/package.nix | 129 +++++++++++------- .../python-modules/lightgbm/default.nix | 46 ++++--- 2 files changed, 105 insertions(+), 70 deletions(-) diff --git a/pkgs/by-name/li/lightgbm/package.nix b/pkgs/by-name/li/lightgbm/package.nix index c5d0238724d5..ee829c4e9cb8 100644 --- a/pkgs/by-name/li/lightgbm/package.nix +++ b/pkgs/by-name/li/lightgbm/package.nix @@ -1,8 +1,9 @@ { - config, - stdenv, lib, + stdenv, + config, fetchFromGitHub, + fetchpatch, cmake, gtest, doCheck ? true, @@ -25,14 +26,14 @@ R, rPackages, pandoc, + python3Packages, }: assert doCheck -> !mpiSupport; assert openclSupport -> !cudaSupport; assert cudaSupport -> !openclSupport; -stdenv.mkDerivation rec { - pnameBase = "lightgbm"; +stdenv.mkDerivation (finalAttrs: { # prefix with r when building the R library # The R package build results in a special binary file # that contains a subset of the .so file use for the CLI @@ -45,17 +46,52 @@ stdenv.mkDerivation rec { # lgbm = lightgbm.override{rLibrary = true; doCheck = false;}; \ # in \ # rWrapper.override{ packages = [ lgbm ]; }" - pname = lib.optionalString rLibrary "r-" + pnameBase; - version = "4.5.0"; + pname = lib.optionalString rLibrary "r-" + "lightgbm"; + version = "4.6.0"; src = fetchFromGitHub { owner = "microsoft"; - repo = pnameBase; - rev = "v${version}"; + repo = "lightgbm"; + tag = "v${finalAttrs.version}"; fetchSubmodules = true; - hash = "sha256-nST6+/c3Y4/hqwgEUhx03gWtjxhlmUu1XKDCy2pSsvU="; + hash = "sha256-vq/TlM87i1GNq0Rpy0OTulT9LF+uvi4PhOUz7ZNeceA="; }; + patches = [ + # Fix boost 1.83+ compatibility + # https://github.com/microsoft/LightGBM/issues/6786 + # Patch taken from https://github.com/conda-forge/lightgbm-feedstock/pull/69 + (fetchpatch { + name = "fix-boost-sha1"; + url = "https://raw.githubusercontent.com/conda-forge/lightgbm-feedstock/68ca96d25d8a6f7281310a4ad3b8d5cdd01f067b/recipe/patches/0003-boost-sha1.patch"; + hash = "sha256-Hw2YmoduOPri7O1XV2p/3Ny4hC8xq7Jq4zoSuKhVeVQ="; + }) + ]; + + # Skip APPLE in favor of linux build for .so files + postPatch = '' + export PROJECT_SOURCE_DIR=./ + substituteInPlace CMakeLists.txt \ + --replace-fail "find_package(GTest CONFIG)" "find_package(GTest REQUIRED)" \ + --replace-fail "OpenCL_INCLUDE_DIRS}" "OpenCL_INCLUDE_DIRS}" \ + --replace-fail "elseif(APPLE)" "elseif(APPLESKIP)" + substituteInPlace \ + external_libs/compute/include/boost/compute/cl.hpp \ + external_libs/compute/include/boost/compute/cl_ext.hpp \ + --replace-fail "include !cudaSupport; assert cudaSupport -> !gpuSupport; buildPythonPackage rec { - pname = "lightgbm"; - version = "4.5.0"; + inherit (pkgs.lightgbm) + pname + version + patches + ; pyproject = true; - disabled = pythonOlder "3.7"; - src = fetchPypi { inherit pname version; - hash = "sha256-4c17rwMY1OMIomV1pjpGNfCN+GatNiKp2OPXHZY3obo="; + hash = "sha256-yxxZcg61aTicC6dNFPUjUbVzr0ifIwAyocnzFPi6t/4="; }; + build-system = [ + scikit-build-core + ]; + nativeBuildInputs = [ cmake ninja pathspec pyproject-metadata - scikit-build-core + writableTmpDirAsHomeHook ] ++ lib.optionals cudaSupport [ cudaPackages.cuda_nvcc ]; dontUseCmakeConfigure = true; @@ -71,7 +81,7 @@ buildPythonPackage rec { cudaPackages.cuda_cudart ]; - propagatedBuildInputs = [ + dependencies = [ numpy scipy ]; @@ -80,10 +90,6 @@ buildPythonPackage rec { lib.optionals gpuSupport [ "--config-setting=cmake.define.USE_GPU=ON" ] ++ lib.optionals cudaSupport [ "--config-setting=cmake.define.USE_CUDA=ON" ]; - postConfigure = '' - export HOME=$(mktemp -d) - ''; - optional-dependencies = { arrow = [ cffi @@ -101,9 +107,7 @@ buildPythonPackage rec { scikit-learn = [ scikit-learn ]; }; - # The pypi package doesn't distribute the tests from the GitHub - # repository. It contains c++ tests which don't seem to wired up to - # `make check`. + # No python tests doCheck = false; pythonImportsCheck = [ "lightgbm" ];