mirror of
https://github.com/NixOS/nixpkgs.git
synced 2026-06-10 23:33:47 +00:00
From https://github.com/NixOS/nixpkgs/pull/507972#discussion_r3053161889:
> [This prevents] the other stdenv and its cc from leaking into the
> build. The latter is somewhat optional, but the leakage can result in,
> on one hand, in mixing object files from different cc releases ("works
> in practice but nobody offers guarantees"), and on the other in the
> hypothetical possibility that cuda tools use up wrong cc.
>
> If lightgbm builds cuda kernel, it "should" conditionally override
> stdenv, so far we don't have a better system to configure this
> transparently to individual packages...
137 lines
2.7 KiB
Nix
137 lines
2.7 KiB
Nix
{
|
|
lib,
|
|
config,
|
|
stdenv,
|
|
pkgs,
|
|
buildPythonPackage,
|
|
fetchPypi,
|
|
|
|
# build-system
|
|
scikit-build-core,
|
|
|
|
# nativeBuildInputs
|
|
cmake,
|
|
ninja,
|
|
pathspec,
|
|
pyproject-metadata,
|
|
writableTmpDirAsHomeHook,
|
|
|
|
# buildInputs
|
|
llvmPackages,
|
|
boost187,
|
|
ocl-icd,
|
|
opencl-headers,
|
|
|
|
# dependencies
|
|
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;
|
|
in
|
|
buildPythonPackage.override { stdenv = effectiveStdenv; } (finalAttrs: {
|
|
inherit (pkgs.lightgbm)
|
|
pname
|
|
version
|
|
patches
|
|
;
|
|
pyproject = true;
|
|
|
|
src = fetchPypi {
|
|
inherit (finalAttrs) pname version;
|
|
hash = "sha256-yxxZcg61aTicC6dNFPUjUbVzr0ifIwAyocnzFPi6t/4=";
|
|
};
|
|
|
|
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
|
|
];
|
|
|
|
dependencies = [
|
|
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")
|
|
];
|
|
|
|
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 ];
|
|
};
|
|
|
|
# No python tests
|
|
doCheck = false;
|
|
|
|
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
|
|
];
|
|
};
|
|
})
|