nixpkgs mirror (for testing) github.com/NixOS/nixpkgs
nix
at python-updates 135 lines 2.9 kB view raw
1{ 2 lib, 3 config, 4 stdenv, 5 pkgs, 6 buildPythonPackage, 7 fetchPypi, 8 9 # build-system 10 scikit-build-core, 11 12 # nativeBuildInputs 13 cmake, 14 ninja, 15 pathspec, 16 pyproject-metadata, 17 writableTmpDirAsHomeHook, 18 19 # buildInputs 20 llvmPackages, 21 boost, 22 ocl-icd, 23 opencl-headers, 24 25 # dependencies 26 numpy, 27 scipy, 28 29 # optional-dependencies 30 cffi, 31 dask, 32 pandas, 33 pyarrow, 34 scikit-learn, 35 36 # optionals: gpu 37 gpuSupport ? stdenv.hostPlatform.isLinux && !cudaSupport, 38 cudaSupport ? config.cudaSupport, 39 cudaPackages, 40}: 41 42assert gpuSupport -> !cudaSupport; 43assert cudaSupport -> !gpuSupport; 44 45buildPythonPackage rec { 46 inherit (pkgs.lightgbm) 47 pname 48 version 49 patches 50 ; 51 pyproject = true; 52 53 src = fetchPypi { 54 inherit pname version; 55 hash = "sha256-yxxZcg61aTicC6dNFPUjUbVzr0ifIwAyocnzFPi6t/4="; 56 }; 57 58 # Patch dll search path to fix proper discovery of lib_lightgbm.so 59 # Exception: Cannot find lightgbm library file in following paths: 60 # /nix/store/...-python3.13-lightgbm-4.6.0/lib/python3.13/site-packages/lib_lightgbm.so 61 # /nix/store/...-python3.13-lightgbm-4.6.0/lib/python3.13/site-packages/lightgbm/bin/lib_lightgbm.so 62 # /nix/store/...-python3.13-lightgbm-4.6.0/lib/python3.13/site-packages/lightgbm/lib/lib_lightgbm.so 63 postPatch = '' 64 substituteInPlace lightgbm/libpath.py \ 65 --replace-fail \ 66 'curr_path.parents[0] / "lib",' \ 67 'curr_path.parents[1] / "lib",' 68 ''; 69 70 build-system = [ 71 scikit-build-core 72 ]; 73 74 nativeBuildInputs = [ 75 cmake 76 ninja 77 pathspec 78 pyproject-metadata 79 writableTmpDirAsHomeHook 80 ] 81 ++ lib.optionals cudaSupport [ cudaPackages.cuda_nvcc ]; 82 83 dontUseCmakeConfigure = true; 84 85 buildInputs = 86 (lib.optionals stdenv.cc.isClang [ llvmPackages.openmp ]) 87 ++ (lib.optionals gpuSupport [ 88 boost 89 ocl-icd 90 opencl-headers 91 ]) 92 ++ lib.optionals cudaSupport [ 93 cudaPackages.cuda_nvcc 94 cudaPackages.cuda_cudart 95 ]; 96 97 dependencies = [ 98 numpy 99 scipy 100 ]; 101 102 cmakeFlags = [ 103 (lib.cmakeBool "USE_GPU" gpuSupport) 104 (lib.cmakeBool "USE_CUDA" cudaSupport) 105 ]; 106 107 optional-dependencies = { 108 arrow = [ 109 cffi 110 pyarrow 111 ]; 112 dask = [ 113 dask 114 pandas 115 ] 116 ++ dask.optional-dependencies.array 117 ++ dask.optional-dependencies.dataframe 118 ++ dask.optional-dependencies.distributed; 119 pandas = [ pandas ]; 120 scikit-learn = [ scikit-learn ]; 121 }; 122 123 # No python tests 124 doCheck = false; 125 126 pythonImportsCheck = [ "lightgbm" ]; 127 128 meta = { 129 description = "Fast, distributed, high performance gradient boosting (GBDT, GBRT, GBM or MART) framework"; 130 homepage = "https://github.com/Microsoft/LightGBM"; 131 changelog = "https://github.com/microsoft/LightGBM/releases/tag/v${version}"; 132 license = lib.licenses.mit; 133 maintainers = with lib.maintainers; [ teh ]; 134 }; 135}