Skip to content

Commit

Permalink
catboost-model-cpp: 1.2.7
Browse files Browse the repository at this point in the history
  • Loading branch information
cdalvaro committed Dec 6, 2024
1 parent 7f86a76 commit 0046f41
Showing 1 changed file with 76 additions and 0 deletions.
76 changes: 76 additions & 0 deletions Formula/catboost-model-cpp.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,76 @@
require "yaml"

module ::Utils
def self.add_clang_version_to_conan_settings(version)
system "conan", "config", "init"
conan_home = safe_popen_read("conan", "config", "home").strip
settings_file = "#{conan_home}/settings.yml"
settings = YAML.load_file(settings_file, aliases: true)
clang_versions = settings["compiler"]["clang"]["version"]
unless clang_versions.include?(version)
clang_versions << version
File.write(settings_file, YAML.dump(settings))
end
end
end

class CatboostModelCpp < Formula
desc "Gradient Boosting on Decision Trees C++ Model Library"
homepage "https://catboost.ai"
url "https://github.com/catboost/catboost.git",
tag: "v1.2.7",
revision: "f903943a8cd903a117c3d3c8421cc72d3910562c"
license "Apache-2.0"
head "https://github.com/catboost/catboost.git", branch: "master"

depends_on "cmake" => :build
depends_on "conan@1" => :build
depends_on "ninja" => :build

uses_from_macos "llvm" => :build

def install

Check failure on line 32 in Formula/catboost-model-cpp.rb

View workflow job for this annotation

GitHub Actions / test-bot (ubuntu-latest)

`brew install --verbose --formula --build-bottle cdalvaro/tap/catboost-model-cpp` failed on Linux!

Run Build Command(s): /home/linuxbrew/.linuxbrew/bin/ninja -v cmTC_32deb [1/2] /home/linuxbrew/.linuxbrew/bin/clang -fPIE -MD -MT CMakeFiles/cmTC_32deb.dir/testCCompiler.c.o -MF CMakeFiles/cmTC_32deb.dir/testCCompiler.c.o.d -o CMakeFiles/cmTC_32deb.dir/testCCompiler.c.o -c /tmp/catboost-model-cpp-20241206-12110-4712ij/cmake-build/CMakeFiles/CMakeScratch/TryCompile-jMWsik/testCCompiler.c [2/2] : && /home/linuxbrew/.linuxbrew/bin/clang -fuse-ld=lld CMakeFiles/cmTC_32deb.dir/testCCompiler.c.o -o cmTC_32deb -lc -lm && : FAILED: cmTC_32deb : && /home/linuxbrew/.linuxbrew/bin/clang -fuse-ld=lld CMakeFiles/cmTC_32deb.dir/testCCompiler.c.o -o cmTC_32deb -lc -lm && : clang: error: invalid linker name in argument '-fuse-ld=lld' ninja: build stopped: subcommand failed. CMake will not be able to correctly generate this project. Call Stack (most recent call first): CMakeLists.txt:20 (project) -- Configuring incomplete, errors occurred! ==> Formula Tap: cdalvaro/tap Path: /home/linuxbrew/.linuxbrew/Homebrew/Library/Taps/cdalvaro/homebrew-tap/Formula/catboost-model-cpp.rb ==> Configuration HOMEBREW_VERSION: 4.4.10-4-g1065b55 ORIGIN: https://github.com/Homebrew/brew HEAD: 1065b55a2c648acd200dc974fdae24e156b2f040 Last commit: 4 hours ago Branch: master Core tap JSON: 06 Dec 13:00 UTC HOMEBREW_PREFIX: /home/linuxbrew/.linuxbrew HOMEBREW_BOOTSNAP: set HOMEBREW_CACHE: /home/runner/.cache/Homebrew HOMEBREW_CASK_OPTS: [] HOMEBREW_CLEANUP_PERIODIC_FULL_DAYS: 3650 HOMEBREW_COLOR: set HOMEBREW_CURL_PATH: /usr/bin/curl HOMEBREW_FAIL_LOG_LINES: 150 HOMEBREW_GITHUB_API_TOKEN: set HOMEBREW_GIT_EMAIL: [email protected] HOMEBREW_GIT_NAME: BrewTestBot HOMEBREW_GIT_PATH: /usr/bin/git HOMEBREW_LOGS: /home/runner/work/homebrew-tap/homebrew-tap/logs HOMEBREW_MAKE_JOBS: 4 HOMEBREW_NO_AUTO_UPDATE: set HOMEBREW_NO_EMOJI: set HOMEBREW_NO_ENV_HINTS: set HOMEBREW_NO_INSTALLED_DEPENDENTS_CHECK: set Homebrew Ruby: 3.3.6 => /home/linuxbrew/.linuxbrew/Homebrew/Library/Homebrew/vendor/portable-ruby/3.3.6/bin/ruby CPU: quad-core 64-bit zen3 Clang: 19.1.4 Git: 2.47.1 => /usr/bin/git Curl: 7.81.0 => /usr/bin/curl Kernel: Linux 6.5.0-1025-azure x86_64 GNU/Linux OS: Ubuntu 22.04.5 LTS (jammy) Host glibc: 2.35 /usr/bin/gcc: 11.4.0 /usr/bin/ruby: 3.0.2 glibc: N/A gcc@11: N/A gcc: N/A xorg: N/A ==> ENV HOMEBREW_CC: gcc-11 HOMEBREW_CXX: g++-11 MAKEFLAGS: -j4 CMAKE_PREFIX_PATH: /home/linuxbrew/.linuxbrew/opt/conan@1:/home/linuxbrew/.linuxbrew HOMEBREW_MAKE_JOBS: 4 HOMEBREW_GIT: /usr/bin/git ACLOCAL_PATH: /home/linuxbrew/.linuxbrew/share/aclocal PATH: /home/linuxbrew/.linuxbrew/Homebrew/Library/Homebrew/shims/linux/super:/home/linuxbrew/.linuxbrew/opt/cmake/bin:/home/linuxbrew/.linuxbrew/opt/conan@1/bin:/home/linuxbrew/.linuxbrew/opt/ninja/bin:/home/linuxbrew/.linuxbrew/opt/llvm/bin:/home/linuxbrew/.linuxbrew/opt/binutils/bin:/usr/bin:/bin:/usr/sbin:/sbin Logs: /home/runner/work/homebrew-tap/homebrew-tap/logs/catboost-model-cpp/00.options.out /home/runner/work/homebrew-tap/homebrew-tap/logs/catboost-model-cpp/01.cmake /home/runner/work/homebrew-tap/homebrew-tap/logs/catboost-model-cpp/01.cmake.cc /home/runner/work/homebrew-tap/homebrew-tap/logs/catboost-model-cpp/cmake-build If reporting this issue please do so at (not Homebrew/brew or Homebrew/homebrew-core): https://github.com/cdalvaro/homebrew-tap/issues ::error::cdalvaro/tap/catboost-model-cpp 1.2.7 did not build
Utils.add_clang_version_to_conan_settings(Formula["llvm"].version.major.to_s) if ENV.key?("GITHUB_ACTIONS")

args = [
"-DCATBOOST_COMPONENTS=libs",
"-DHAVE_CUDA=NO",
"-DCMAKE_POSITION_INDEPENDENT_CODE=On",
"-DCMAKE_TOOLCHAIN_FILE=#{buildpath}/build/toolchains/clang.toolchain",
]

cmakepath = buildpath/"cmake-build"
system "cmake", "-S", ".", "-B", cmakepath, "-G", "Ninja", *args, *std_cmake_args
system "ninja", "-C", cmakepath, "catboostmodel"

lib.install cmakepath/"catboost/libs/model_interface/libcatboostmodel.dylib"
%w[c_api.h wrapped_calcer.h].each do |header|
(include/"catboost/model_interface").install Dir[buildpath/"catboost/libs/model_interface/#{header}"]
end
end

test do
(testpath/"test.cpp").write <<~EOS
#include <catboost/model_interface/wrapped_calcer.h>
#include <iostream>
int main(int argc, char** argv) {
{
ModelCalcerWrapper calcer;
calcer.init_from_file("model.bin");
std::cout << calcer.CalcFlat(std::vector<float>(100)) << std::endl;
std::cout << calcer.CalcFlat(std::vector<float>(100, 1.0f)) << std::endl;
}
{
ModelCalcerWrapper calcer("model.bin");
std::vector<std::string> catFeatures = {"1", "2", "3"};
std::cout << calcer.Calc(std::vector<float>(100), catFeatures) << std::endl;
std::cout << calcer.Calc(std::vector<float>(100, 1.0f), std::vector<std::string>()) << std::endl;
}
return 0;
}
EOS
system ENV.cxx, "test.cpp", "-std=c++1y", "-L#{lib}", "-o", "test"
system "./test"
end
end

0 comments on commit 0046f41

Please sign in to comment.