summary refs log tree commit diff
path: root/pkgs/development/python-modules/xgboost/default.nix
blob: 2a65992e048d2e669732a05eba40196f9ae6c4e6 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
{ lib
, buildPythonPackage
, pythonOlder
, cmake
, numpy
, scipy
, hatchling
, stdenv
, xgboost
}:

buildPythonPackage {
  pname = "xgboost";
  format = "pyproject";
  inherit (xgboost) version src meta;

  disabled = pythonOlder "3.8";

  nativeBuildInputs = [ cmake hatchling ];
  buildInputs = [ xgboost ];
  propagatedBuildInputs = [ numpy scipy ];

  # Override existing logic for locating libxgboost.so which is not appropriate for Nix
  prePatch = let
    libPath = "${xgboost}/lib/libxgboost${stdenv.hostPlatform.extensions.sharedLibrary}";
  in ''
    echo 'find_lib_path = lambda: ["${libPath}"]' > python-package/xgboost/libpath.py
  '';

  dontUseCmakeConfigure = true;

  postPatch = ''
    cd python-package
  '';

  # test setup tries to download test data with no option to disable
  # (removing sklearn from nativeCheckInputs causes all previously enabled tests to be skipped)
  # and are extremely cpu intensive anyway
  doCheck = false;

  pythonImportsCheck = [
    "xgboost"
  ];

  __darwinAllowLocalNetworking = true;
}