about summary refs log tree commit diff
path: root/pkgs/development/python-modules/xgboost/default.nix
blob: 9b53c180397dfb79cafc0e1688bc4dcc7e6f9265 (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
{ stdenv
, buildPythonPackage
, nose
, scipy
, xgboost
}:

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

  propagatedBuildInputs = [ scipy ];
  checkInputs = [ nose ];

  postPatch = let
    libname = "libxgboost.${stdenv.hostPlatform.extensions.sharedLibrary}";

  in ''
    cd python-package

    sed "s/CURRENT_DIR = os.path.dirname(__file__)/CURRENT_DIR = os.path.abspath(os.path.dirname(__file__))/g" -i setup.py
    sed "/^LIB_PATH.*/a LIB_PATH = [os.path.relpath(LIB_PATH[0], CURRENT_DIR)]" -i setup.py
    cat <<EOF >xgboost/libpath.py
    def find_lib_path():
      return ["${xgboost}/lib/${libname}"]
    EOF
  '';

  postInstall = ''
    rm -rf $out/xgboost
  '';
}