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