-
-
Notifications
You must be signed in to change notification settings - Fork 13.9k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #235226 from natsukium/catboost/update
python3Packages.catboost: 1.0.5 -> 1.2.2; build with cmake
- Loading branch information
Showing
6 changed files
with
200 additions
and
229 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,113 @@ | ||
{ lib | ||
, config | ||
, stdenv | ||
, fetchFromGitHub | ||
, cmake | ||
, libiconv | ||
, llvmPackages | ||
, ninja | ||
, openssl | ||
, python3Packages | ||
, ragel | ||
, yasm | ||
, zlib | ||
, cudaSupport ? config.cudaSupport | ||
, cudaPackages ? {} | ||
, pythonSupport ? false | ||
}: | ||
|
||
stdenv.mkDerivation (finalAttrs: { | ||
pname = "catboost"; | ||
version = "1.2.2"; | ||
|
||
src = fetchFromGitHub { | ||
owner = "catboost"; | ||
repo = "catboost"; | ||
rev = "refs/tags/v${finalAttrs.version}"; | ||
hash = "sha256-A1zCIqPOW21dHKBQHRtS+/sstZ2o6F8k71lmJFGn0+g="; | ||
}; | ||
|
||
patches = [ | ||
./remove-conan.patch | ||
]; | ||
|
||
postPatch = '' | ||
substituteInPlace cmake/common.cmake \ | ||
--replace "\''${RAGEL_BIN}" "${ragel}/bin/ragel" \ | ||
--replace "\''${YASM_BIN}" "${yasm}/bin/yasm" | ||
shopt -s globstar | ||
for cmakelists in **/CMakeLists.*; do | ||
sed -i "s/OpenSSL::OpenSSL/OpenSSL::SSL/g" $cmakelists | ||
${lib.optionalString (lib.versionOlder cudaPackages.cudaVersion "11.8") '' | ||
sed -i 's/-gencode=arch=compute_89,code=sm_89//g' $cmakelists | ||
sed -i 's/-gencode=arch=compute_90,code=sm_90//g' $cmakelists | ||
''} | ||
done | ||
''; | ||
|
||
outputs = [ "out" "dev" ]; | ||
|
||
nativeBuildInputs = [ | ||
cmake | ||
llvmPackages.bintools | ||
ninja | ||
(python3Packages.python.withPackages (ps: with ps; [ six ])) | ||
ragel | ||
yasm | ||
] ++ lib.optionals cudaSupport (with cudaPackages; [ | ||
cuda_nvcc | ||
]); | ||
|
||
buildInputs = [ | ||
openssl | ||
zlib | ||
] ++ lib.optionals stdenv.isDarwin [ | ||
libiconv | ||
] ++ lib.optionals cudaSupport (with cudaPackages; [ | ||
cuda_cudart | ||
cuda_cccl | ||
libcublas | ||
]); | ||
|
||
env = { | ||
CUDAHOSTCXX = lib.optionalString cudaSupport "${stdenv.cc}/bin/cc"; | ||
NIX_CFLAGS_LINK = lib.optionalString stdenv.isLinux "-fuse-ld=lld"; | ||
NIX_LDFLAGS = "-lc -lm"; | ||
}; | ||
|
||
cmakeFlags = [ | ||
"-DCMAKE_BINARY_DIR=$out" | ||
"-DCMAKE_POSITION_INDEPENDENT_CODE=on" | ||
"-DCATBOOST_COMPONENTS=app;libs${lib.optionalString pythonSupport ";python-package"}" | ||
] ++ lib.optionals cudaSupport [ | ||
"-DHAVE_CUDA=on" | ||
]; | ||
|
||
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 | ||
''; | ||
|
||
meta = with lib; { | ||
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. | ||
''; | ||
license = licenses.asl20; | ||
platforms = platforms.unix; | ||
homepage = "https://catboost.ai"; | ||
maintainers = with maintainers; [ PlushBeaver natsukium ]; | ||
mainProgram = "catboost"; | ||
}; | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
diff --git a/CMakeLists.txt b/CMakeLists.txt | ||
index becd2ad03c..7e3c8c99b1 100644 | ||
--- a/CMakeLists.txt | ||
+++ b/CMakeLists.txt | ||
@@ -27,7 +27,6 @@ cmake_policy(SET CMP0104 OLD) | ||
|
||
include(cmake/archive.cmake) | ||
include(cmake/common.cmake) | ||
-include(cmake/conan.cmake) | ||
include(cmake/cuda.cmake) | ||
include(cmake/cython.cmake) | ||
include(cmake/fbs.cmake) | ||
@@ -37,21 +36,6 @@ include(cmake/recursive_library.cmake) | ||
include(cmake/swig.cmake) | ||
include(cmake/global_vars.cmake) | ||
|
||
-if (CMAKE_CROSSCOMPILING) | ||
- include(${CMAKE_BINARY_DIR}/conan_paths.cmake) | ||
-else() | ||
- conan_cmake_autodetect(settings) | ||
- conan_cmake_install( | ||
- PATH_OR_REFERENCE ${CMAKE_SOURCE_DIR} | ||
- INSTALL_FOLDER ${CMAKE_BINARY_DIR} | ||
- BUILD missing | ||
- REMOTE conancenter | ||
- SETTINGS ${settings} | ||
- ENV "CONAN_CMAKE_GENERATOR=${CMAKE_GENERATOR}" | ||
- CONF "tools.cmake.cmaketoolchain:generator=${CMAKE_GENERATOR}" | ||
- ) | ||
-endif() | ||
- | ||
if (CMAKE_SYSTEM_NAME STREQUAL "Linux" AND CMAKE_SYSTEM_PROCESSOR STREQUAL "x86_64" AND NOT HAVE_CUDA) | ||
include(CMakeLists.linux-x86_64.txt) | ||
elseif (CMAKE_SYSTEM_NAME STREQUAL "Linux" AND CMAKE_SYSTEM_PROCESSOR STREQUAL "x86_64" AND HAVE_CUDA) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,64 +1,50 @@ | ||
{ buildPythonPackage, fetchFromGitHub, lib, pythonOlder | ||
, clang_12, python | ||
, graphviz, matplotlib, numpy, pandas, plotly, scipy, six | ||
, withCuda ? false, cudatoolkit }: | ||
|
||
buildPythonPackage rec { | ||
pname = "catboost"; | ||
# nixpkgs-update: no auto update | ||
version = "1.0.5"; | ||
|
||
disabled = pythonOlder "3.4"; | ||
{ lib | ||
, buildPythonPackage | ||
, catboost | ||
, python | ||
, graphviz | ||
, matplotlib | ||
, numpy | ||
, pandas | ||
, plotly | ||
, scipy | ||
, setuptools | ||
, six | ||
, wheel | ||
}: | ||
|
||
buildPythonPackage { | ||
inherit (catboost) pname version src meta; | ||
format = "pyproject"; | ||
|
||
sourceRoot = "source/catboost/python-package"; | ||
|
||
nativeBuildInputs = [ | ||
setuptools | ||
wheel | ||
]; | ||
|
||
src = fetchFromGitHub { | ||
owner = "catboost"; | ||
repo = "catboost"; | ||
rev = "refs/tags/v${version}"; | ||
hash = "sha256-ILemeZUBI9jPb9G6F7QX/T1HaVhQ+g6y7YmsT6DFCJk"; | ||
}; | ||
propagatedBuildInputs = [ | ||
graphviz | ||
matplotlib | ||
numpy | ||
pandas | ||
plotly | ||
scipy | ||
six | ||
]; | ||
|
||
nativeBuildInputs = [ clang_12 ]; | ||
buildPhase = '' | ||
runHook preBuild | ||
propagatedBuildInputs = [ graphviz matplotlib numpy pandas scipy plotly six ] | ||
++ lib.optionals withCuda [ cudatoolkit ]; | ||
# these arguments must set after bdist_wheel | ||
${python.pythonForBuild.interpreter} setup.py bdist_wheel --no-widget --prebuilt-extensions-build-root-dir=${lib.getDev catboost} | ||
patches = [ | ||
./nix-support.patch | ||
]; | ||
|
||
postPatch = '' | ||
# substituteInPlace is too slow for these large files, and the target has lots of numbers in it that change often. | ||
sed -e 's|\$(YMAKE_PYTHON3-.*)/python3|${python.interpreter}|' -i make/*.makefile | ||
runHook postBuild | ||
''; | ||
|
||
preBuild = '' | ||
cd catboost/python-package | ||
''; | ||
setupPyBuildFlags = [ "--with-ymake=no" ]; | ||
CUDA_ROOT = lib.optional withCuda cudatoolkit; | ||
enableParallelBuilding = true; | ||
# setup a test is difficult | ||
doCheck = false; | ||
|
||
# Tests use custom "ya" tool, not yet supported. | ||
dontUseSetuptoolsCheck = true; | ||
pythonImportsCheck = [ "catboost" ]; | ||
|
||
passthru = { | ||
# Do not update to catboost 1.1.x because the patch doesn't apply cleanly | ||
skipBulkUpdate = true; | ||
}; | ||
|
||
meta = with lib; { | ||
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. | ||
''; | ||
license = licenses.asl20; | ||
platforms = [ "x86_64-linux" ]; | ||
homepage = "https://catboost.ai"; | ||
maintainers = with maintainers; [ PlushBeaver ]; | ||
# _catboost.pyx.cpp:226822:19: error: use of undeclared identifier '_PyGen_Send' | ||
broken = withCuda; | ||
}; | ||
} |
Oops, something went wrong.