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
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
|
{
lib,
config,
fetchFromGitHub,
cmake,
cctools,
llvmPackages,
ninja,
openssl,
python3Packages,
ragel,
yasm,
zlib,
gitUpdater,
cudaSupport ? config.cudaSupport,
cudaPackages ? { },
pythonSupport ? false,
}:
let
stdenv = if cudaSupport then cudaPackages.backendStdenv else llvmPackages.stdenv;
buildPythonBindingsEnv = python3Packages.python.withPackages (
ps: with ps; [
cython
numpy
]
);
in
stdenv.mkDerivation (finalAttrs: {
pname = "catboost";
version = "1.2.10";
src = fetchFromGitHub {
owner = "catboost";
repo = "catboost";
tag = "v${finalAttrs.version}";
hash = "sha256-z68vflYgO3cWeOkb417Gyco1Fqb98ulyRgI+OS+B4is=";
};
postPatch = ''
substituteInPlace cmake/common.cmake \
--replace-fail "\''${RAGEL_BIN}" "${ragel}/bin/ragel" \
--replace-fail "\''${YASM_BIN}" "${yasm}/bin/yasm"
shopt -s globstar
for cmakelists in **/CMakeLists.*; do
sed -i "s/openssl::openssl/OpenSSL::SSL/g" $cmakelists
done
'';
outputs = [
"out"
"dev"
];
nativeBuildInputs = [
buildPythonBindingsEnv
cmake
llvmPackages.bintools
ninja
ragel
yasm
]
++ lib.optionals stdenv.hostPlatform.isDarwin [
cctools
]
++ lib.optionals cudaSupport [
cudaPackages.cuda_nvcc
];
buildInputs = [
openssl
zlib
]
++ lib.optionals cudaSupport [
cudaPackages.cuda_cudart
cudaPackages.cccl
cudaPackages.libcublas
];
env = {
PROGRAM_VERSION = finalAttrs.version;
# catboost requires clang 14+ for build, but does clang 12 for cuda build.
# after bumping the default version of llvm, check for compatibility with the cuda backend and pin it.
# see https://catboost.ai/en/docs/installation/build-environment-setup-for-cmake#compilers,-linkers-and-related-tools
CUDAHOSTCXX = lib.optionalString cudaSupport "${stdenv.cc}/bin/cc";
NIX_CFLAGS_LINK = lib.optionalString stdenv.hostPlatform.isLinux "-fuse-ld=lld";
NIX_LDFLAGS = "-lc -lm";
NIX_CFLAGS_COMPILE = toString (
lib.optionals stdenv.cc.isClang [
"-Wno-error=missing-template-arg-list-after-template-kw"
]
);
};
cmakeFlags = [
(lib.cmakeFeature "CMAKE_BINARY_DIR" "$out")
(lib.cmakeBool "CMAKE_POSITION_INDEPENDENT_CODE" true)
(lib.cmakeFeature "CATBOOST_COMPONENTS" "app;libs${lib.optionalString pythonSupport ";python-package"}")
(lib.cmakeBool "HAVE_CUDA" cudaSupport)
]
++ lib.optional pythonSupport (
lib.cmakeFeature "Python_EXECUTABLE" "${buildPythonBindingsEnv.interpreter}"
);
installPhase = ''
runHook preInstall
mkdir $dev
cp -r catboost $dev
install -Dm555 catboost/app/catboost -t $out/bin
install -Dm444 catboost/libs/model_interface/static/lib/libmodel_interface-static-lib.a -t $out/lib
install -Dm444 catboost/libs/model_interface/libcatboostmodel${stdenv.hostPlatform.extensions.sharedLibrary} -t $out/lib
install -Dm444 catboost/libs/train_interface/libcatboost${stdenv.hostPlatform.extensions.sharedLibrary} -t $out/lib
runHook postInstall
'';
passthru.updateScript = gitUpdater { rev-prefix = "v"; };
meta = {
description = "High-performance library for gradient boosting on decision trees";
longDescription = ''
A fast, scalable, high performance Gradient Boosting on Decision Trees
library, used for ranking, classification, regression and other machine
learning tasks for Python, R, Java, C++. Supports computation on CPU and GPU.
'';
changelog = "https://github.com/catboost/catboost/releases/tag/v${finalAttrs.version}";
license = lib.licenses.asl20;
platforms = lib.platforms.unix;
homepage = "https://catboost.ai";
maintainers = with lib.maintainers; [
PlushBeaver
natsukium
];
mainProgram = "catboost";
broken =
# See: <https://github.com/catboost/catboost/issues/2755>
cudaSupport
# /nix/store/hzxiynjmmj35fpy3jla7vcqwmzj9i449-Libsystem-1238.60.2/include/sys/_types/_mbstate_t.h:31:9: error: unknown type name '__darwin_mbstate_t'
|| (stdenv.hostPlatform.isDarwin && stdenv.hostPlatform.isx86_64);
};
})
|