1{ lib
2, buildPythonPackage
3, pythonOlder
4, cmake
5, numpy
6, scipy
7, hatchling
8, stdenv
9, xgboost
10}:
11
12buildPythonPackage {
13 pname = "xgboost";
14 format = "pyproject";
15 inherit (xgboost) version src meta;
16
17 disabled = pythonOlder "3.8";
18
19 nativeBuildInputs = [ cmake hatchling ];
20 buildInputs = [ xgboost ];
21 propagatedBuildInputs = [ numpy scipy ];
22
23 # Override existing logic for locating libxgboost.so which is not appropriate for Nix
24 prePatch = let
25 libPath = "${xgboost}/lib/libxgboost${stdenv.hostPlatform.extensions.sharedLibrary}";
26 in ''
27 echo 'find_lib_path = lambda: ["${libPath}"]' > python-package/xgboost/libpath.py
28 '';
29
30 dontUseCmakeConfigure = true;
31
32 postPatch = ''
33 cd python-package
34 '';
35
36 # test setup tries to download test data with no option to disable
37 # (removing sklearn from nativeCheckInputs causes all previously enabled tests to be skipped)
38 # and are extremely cpu intensive anyway
39 doCheck = false;
40
41 pythonImportsCheck = [
42 "xgboost"
43 ];
44
45 __darwinAllowLocalNetworking = true;
46}