Something went wrong. Try again.
Nix Packages collection & NixOS github.com/NixOS/nixpkgs
Something went wrong. Try again.
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142{ lib, config, stdenv, pkgs, buildPythonPackage,
# build-system scikit-build-core,
# nativeBuildInputs cmake, ninja, pathspec, pyproject-metadata, writableTmpDirAsHomeHook,
# buildInputs llvmPackages, boost187, ocl-icd, opencl-headers,
# dependencies narwhals, numpy, scipy,
# optional-dependencies cffi, dask, pandas, pyarrow, scikit-learn,
# optionals: gpu gpuSupport ? stdenv.hostPlatform.isLinux && !cudaSupport, cudaSupport ? config.cudaSupport, cudaPackages,}:
assert gpuSupport -> !cudaSupport;assert cudaSupport -> !gpuSupport;
let effectiveStdenv = if cudaSupport then cudaPackages.backendStdenv else stdenv;inbuildPythonPackage.override { stdenv = effectiveStdenv; } (finalAttrs: { inherit (pkgs.lightgbm) pname version patches src ; pyproject = true;
# These need to be in the root for the build to work. # The tarballs on PyPi are structured the same. postUnpack = '' mv source/python-package/{pyproject.toml,README.rst} source/ '';
build-system = [ scikit-build-core ];
nativeBuildInputs = [ cmake ninja pathspec pyproject-metadata writableTmpDirAsHomeHook ] ++ lib.optionals cudaSupport [ cudaPackages.cuda_nvcc ];
dontUseCmakeConfigure = true;
buildInputs = (lib.optionals stdenv.cc.isClang [ llvmPackages.openmp ]) ++ (lib.optionals gpuSupport [ boost187 ocl-icd opencl-headers ]) ++ lib.optionals cudaSupport [ cudaPackages.cuda_nvcc cudaPackages.cuda_cudart cudaPackages.nccl ];
dependencies = [ narwhals numpy scipy ];
cmakeFlags = [ (lib.cmakeBool "USE_GPU" gpuSupport) (lib.cmakeBool "USE_CUDA" cudaSupport) # Set in pyproject.toml for `cmake.args` in `[tool.scikit-build]`, # but not set by our hooks. (lib.cmakeBool "__BUILD_FOR_PYTHON" true) ] ++ lib.optionals cudaSupport [ # build fails otherwise (lib.cmakeFeature "CMAKE_CUDA_STANDARD" "14")
# needed to find nccl (lib.cmakeBool "BUILD_WITH_SHARED_NCCL" true) (lib.cmakeFeature "NCCL_ROOT" "${lib.getLib cudaPackages.nccl}") ];
optional-dependencies = { arrow = [ cffi pyarrow ]; dask = [ dask pandas ] ++ dask.optional-dependencies.array ++ dask.optional-dependencies.dataframe ++ dask.optional-dependencies.distributed; pandas = [ pandas ]; scikit-learn = [ scikit-learn ]; };
pythonImportsCheck = [ "lightgbm" ];
meta = { description = "Fast, distributed, high performance gradient boosting (GBDT, GBRT, GBM or MART) framework"; homepage = "https://github.com/lightgbm-org/LightGBM"; changelog = "https://github.com/lightgbm-org/LightGBM/releases/tag/v${finalAttrs.version}"; license = lib.licenses.mit; maintainers = with lib.maintainers; [ flokli teh ]; };})