1{ lib
2, buildPythonPackage
3, pytestCheckHook
4, cmake
5, scipy
6, scikit-learn
7, stdenv
8, xgboost
9, pandas
10, matplotlib
11, graphviz
12, datatable
13, hypothesis
14}:
15
16buildPythonPackage {
17 pname = "xgboost";
18 inherit (xgboost) version src meta;
19
20 nativeBuildInputs = [ cmake ];
21 buildInputs = [ xgboost ];
22 propagatedBuildInputs = [ scipy ];
23 checkInputs = [
24 pytestCheckHook
25 scikit-learn
26 pandas
27 matplotlib
28 graphviz
29 datatable
30 hypothesis
31 ];
32
33 # Override existing logic for locating libxgboost.so which is not appropriate for Nix
34 prePatch = let
35 libPath = "${xgboost}/lib/libxgboost${stdenv.hostPlatform.extensions.sharedLibrary}";
36 in ''
37 echo 'find_lib_path = lambda: ["${libPath}"]' > python-package/xgboost/libpath.py
38 '';
39
40 dontUseCmakeConfigure = true;
41
42 postPatch = ''
43 cd python-package
44 '';
45
46 preCheck = ''
47 ln -sf ../demo .
48 ln -s ${xgboost}/bin/xgboost ../xgboost
49 '';
50
51 # tests are extremely cpu intensive, only run basic tests to ensure package is working
52 pytestFlagsArray = ["../tests/python/test_basic.py"];
53 disabledTestPaths = [
54 # Requires internet access: https://github.com/dmlc/xgboost/blob/03cd087da180b7dff21bd8ef34997bf747016025/tests/python/test_ranking.py#L81
55 "../tests/python/test_ranking.py"
56 ];
57 disabledTests = [
58 "test_cli_binary_classification"
59 "test_model_compatibility"
60 ] ++ lib.optionals stdenv.isDarwin [
61 # fails to connect to the com.apple.fonts daemon in sandboxed mode
62 "test_plotting"
63 "test_sklearn_plotting"
64 ];
65
66 __darwinAllowLocalNetworking = true;
67}