about summary refs log tree commit diff
path: root/nixpkgs/pkgs/development/python-modules/xgboost/default.nix
blob: 1045b86a44410bf3e0634f79ada1e5baeb91871f (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
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
{ lib
, buildPythonPackage
, pytestCheckHook
, cmake
, scipy
, scikit-learn
, stdenv
, xgboost
, substituteAll
, pandas
, matplotlib
, graphviz
, datatable
, hypothesis
}:

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

  nativeBuildInputs = [ cmake ];
  buildInputs = [ xgboost ];
  propagatedBuildInputs = [ scipy ];
  checkInputs = [
    pytestCheckHook
    scikit-learn
    pandas
    matplotlib
    graphviz
    datatable
    hypothesis
  ];

  # 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
  '';

  preCheck = ''
    ln -sf ../demo .
    ln -s ${xgboost}/bin/xgboost ../xgboost
  '';

  pytestFlagsArray = ["../tests/python"];
  disabledTestPaths = [
    # Requires internet access: https://github.com/dmlc/xgboost/blob/03cd087da180b7dff21bd8ef34997bf747016025/tests/python/test_ranking.py#L81
    "../tests/python/test_ranking.py"
  ];
  disabledTests = [
    "test_cli_binary_classification"
    "test_model_compatibility"
  ] ++ lib.optionals stdenv.isDarwin [
    # fails to connect to the com.apple.fonts daemon in sandboxed mode
    "test_plotting"
    "test_sklearn_plotting"
  ];

  __darwinAllowLocalNetworking = true;
}