at master 1.5 kB view raw
1{ 2 buildPythonPackage, 3 pythonOlder, 4 cmake, 5 numpy, 6 scipy, 7 hatchling, 8 python, 9 stdenv, 10 xgboost, 11}: 12 13let 14 libExtension = stdenv.hostPlatform.extensions.sharedLibrary; 15 libName = "libxgboost${libExtension}"; 16 libPath = "${xgboost}/lib/${libName}"; 17in 18buildPythonPackage { 19 pname = "xgboost"; 20 format = "pyproject"; 21 inherit (xgboost) version src meta; 22 23 disabled = pythonOlder "3.8"; 24 25 nativeBuildInputs = [ 26 cmake 27 hatchling 28 ]; 29 buildInputs = [ xgboost ]; 30 propagatedBuildInputs = [ 31 numpy 32 scipy 33 ]; 34 35 pythonRemoveDeps = [ 36 "nvidia-nccl-cu12" 37 ]; 38 39 # Place libxgboost.so where the build will look for it 40 # to avoid triggering the compilation of the library 41 prePatch = '' 42 mkdir -p lib 43 ln -s ${libPath} lib/ 44 ''; 45 46 dontUseCmakeConfigure = true; 47 48 postPatch = '' 49 cd python-package 50 ''; 51 52 # test setup tries to download test data with no option to disable 53 # (removing sklearn from nativeCheckInputs causes all previously enabled tests to be skipped) 54 # and are extremely cpu intensive anyway 55 doCheck = false; 56 57 # During the build libxgboost.so is copied to its current location 58 # Replacing it with a symlink to the original 59 postInstall = 60 let 61 libOutPath = "$out/${python.sitePackages}/xgboost/lib/${libName}"; 62 in 63 '' 64 rm "${libOutPath}" 65 ln -s "${libPath}" "${libOutPath}" 66 ''; 67 68 pythonImportsCheck = [ "xgboost" ]; 69 70 __darwinAllowLocalNetworking = true; 71}