1{ buildPythonPackage, fetchFromGitHub, lib, pythonOlder
2, clang_12, python
3, graphviz, matplotlib, numpy, pandas, plotly, scipy, six
4, withCuda ? false, cudatoolkit }:
5
6buildPythonPackage rec {
7 pname = "catboost";
8 # nixpkgs-update: no auto update
9 version = "1.0.5";
10
11 disabled = pythonOlder "3.4";
12
13 src = fetchFromGitHub {
14 owner = "catboost";
15 repo = "catboost";
16 rev = "refs/tags/v${version}";
17 hash = "sha256-ILemeZUBI9jPb9G6F7QX/T1HaVhQ+g6y7YmsT6DFCJk";
18 };
19
20 nativeBuildInputs = [ clang_12 ];
21
22 propagatedBuildInputs = [ graphviz matplotlib numpy pandas scipy plotly six ]
23 ++ lib.optionals withCuda [ cudatoolkit ];
24
25 patches = [
26 ./nix-support.patch
27 ];
28
29 postPatch = ''
30 # substituteInPlace is too slow for these large files, and the target has lots of numbers in it that change often.
31 sed -e 's|\$(YMAKE_PYTHON3-.*)/python3|${python.interpreter}|' -i make/*.makefile
32 '';
33
34 preBuild = ''
35 cd catboost/python-package
36 '';
37 setupPyBuildFlags = [ "--with-ymake=no" ];
38 CUDA_ROOT = lib.optional withCuda cudatoolkit;
39 enableParallelBuilding = true;
40
41 # Tests use custom "ya" tool, not yet supported.
42 dontUseSetuptoolsCheck = true;
43 pythonImportsCheck = [ "catboost" ];
44
45 passthru = {
46 # Do not update to catboost 1.1.x because the patch doesn't apply cleanly
47 skipBulkUpdate = true;
48 };
49
50 meta = with lib; {
51 description = "High-performance library for gradient boosting on decision trees.";
52 longDescription = ''
53 A fast, scalable, high performance Gradient Boosting on Decision Trees
54 library, used for ranking, classification, regression and other machine
55 learning tasks for Python, R, Java, C++. Supports computation on CPU and GPU.
56 '';
57 license = licenses.asl20;
58 platforms = [ "x86_64-linux" ];
59 homepage = "https://catboost.ai";
60 maintainers = with maintainers; [ PlushBeaver ];
61 # _catboost.pyx.cpp:226822:19: error: use of undeclared identifier '_PyGen_Send'
62 broken = withCuda;
63 };
64}