pythonPackages.xgboost: fix build
The setup.py of `python-package` contains some path resolution magic to find `libxgboost.so` which is needed for the python API. Unfortunately the code is incompatible with Nix as it isn't compatible with the store-based structure for each package and tries to express the location of the shared object with relative paths. The detection in `setup.py` and `xgboost/libpath.py` has been either removed entirely or patched to link to the proper store path of the `libxgboost` build input. See https://hydra.nixos.org/build/77702715 for further reference.
This commit is contained in:
@@ -3,30 +3,28 @@
|
||||
, nose
|
||||
, scipy
|
||||
, xgboost
|
||||
, substituteAll
|
||||
}:
|
||||
|
||||
buildPythonPackage rec {
|
||||
pname = "xgboost";
|
||||
inherit (xgboost) version src meta;
|
||||
|
||||
patches = [
|
||||
(substituteAll {
|
||||
src = ./lib-path-for-python.patch;
|
||||
libpath = "${xgboost}/lib";
|
||||
})
|
||||
];
|
||||
|
||||
postPatch = "cd python-package";
|
||||
|
||||
propagatedBuildInputs = [ scipy ];
|
||||
buildInputs = [ xgboost ];
|
||||
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
|
||||
checkPhase = ''
|
||||
ln -sf ../demo .
|
||||
nosetests ../tests/python
|
||||
'';
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user