From e73227e28c4afbb7201ec13d5b0235af0d500cc8 Mon Sep 17 00:00:00 2001 From: Florian Klink Date: Wed, 8 Apr 2026 15:42:57 +0100 Subject: [PATCH] python3Packages.lightgbm: fix lib_lightgbm.so location cmake installs lib_lightgbm.so into the wrong place, `$out/lib/python3.13/site-packages/lib/lib_lightgbm.so`, which is not part of the locations `lightgbm/libpath.py` considers. Instead of patching that file, which seems to have regressed, set the `__BUILD_FOR_PYTHON` `cmakeBool` (as in `pyproject.toml`), which causes the .so file to be placed to a location that will be considered for dlopen()'ing later, removing the need for any patching alltogether. The new location of the .so file is also more aligned with how other python packages in nixpkgs do it, `$out/lib/python3.13/site-packages/lightgbm/lib/lib_lightgbm.so`. --- .../python-modules/lightgbm/default.nix | 15 +++------------ 1 file changed, 3 insertions(+), 12 deletions(-) diff --git a/pkgs/development/python-modules/lightgbm/default.nix b/pkgs/development/python-modules/lightgbm/default.nix index 6fbba4c436c6..46016b92469e 100644 --- a/pkgs/development/python-modules/lightgbm/default.nix +++ b/pkgs/development/python-modules/lightgbm/default.nix @@ -55,18 +55,6 @@ buildPythonPackage rec { hash = "sha256-yxxZcg61aTicC6dNFPUjUbVzr0ifIwAyocnzFPi6t/4="; }; - # Patch dll search path to fix proper discovery of lib_lightgbm.so - # Exception: Cannot find lightgbm library file in following paths: - # /nix/store/...-python3.13-lightgbm-4.6.0/lib/python3.13/site-packages/lib_lightgbm.so - # /nix/store/...-python3.13-lightgbm-4.6.0/lib/python3.13/site-packages/lightgbm/bin/lib_lightgbm.so - # /nix/store/...-python3.13-lightgbm-4.6.0/lib/python3.13/site-packages/lightgbm/lib/lib_lightgbm.so - postPatch = '' - substituteInPlace lightgbm/libpath.py \ - --replace-fail \ - 'curr_path.parents[0] / "lib",' \ - 'curr_path.parents[1] / "lib",' - ''; - build-system = [ scikit-build-core ]; @@ -102,6 +90,9 @@ buildPythonPackage rec { 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) ]; optional-dependencies = {