homebrew-core/Formula/libtensorflow.rb
2017-06-30 02:19:42 -07:00

53 lines
1.8 KiB
Ruby

class Libtensorflow < Formula
desc "C interface for Google's OS library for Machine Intelligence"
homepage "https://www.tensorflow.org/"
url "https://github.com/tensorflow/tensorflow/archive/v1.2.1.tar.gz"
sha256 "f2baf09b1a9a0500907b4d5cb5473070b3ecede06ed6e8d1096873c91922fb9e"
bottle do
cellar :any
sha256 "1fcf113066d12ec927fe18b8f8b58a9ee90c829ee0e8867de6475d1acb0fbe1b" => :sierra
sha256 "14c73d05efa47b32cdbab86b1854f2d6da3da1a58a4c893cc096f485103ca534" => :el_capitan
sha256 "391027909b9706d71c7ccdcc151896c8e15bdf3ab231775848c8ec566a5608ed" => :yosemite
end
depends_on "bazel" => :build
def install
ENV["PYTHON_BIN_PATH"] = which("python").to_s
ENV["CC_OPT_FLAGS"] = "-march=native"
ENV["TF_NEED_JEMALLOC"] = "1"
ENV["TF_NEED_GCP"] = "0"
ENV["TF_NEED_HDFS"] = "0"
ENV["TF_ENABLE_XLA"] = "0"
ENV["USE_DEFAULT_PYTHON_LIB_PATH"] = "1"
ENV["TF_NEED_OPENCL"] = "0"
ENV["TF_NEED_CUDA"] = "0"
ENV["TF_NEED_MKL"] = "0"
ENV["TF_NEED_VERBS"] = "0"
system "./configure"
system "bazel", "build", "--compilation_mode=opt", "--copt=-march=native", "tensorflow:libtensorflow.so"
lib.install "bazel-bin/tensorflow/libtensorflow.so"
(include/"tensorflow/c").install "tensorflow/c/c_api.h"
(lib/"pkgconfig/tensorflow.pc").write <<-EOS.undent
Name: tensorflow
Description: Tensorflow library
Version: #{version}
Libs: -L#{lib} -ltensorflow
Cflags: -I#{include}
EOS
end
test do
(testpath/"test.c").write <<-EOS.undent
#include <stdio.h>
#include <tensorflow/c/c_api.h>
int main() {
printf("%s", TF_Version());
}
EOS
system ENV.cc, "-L#{lib}", "-ltensorflow", "-o", "test_tf", "test.c"
assert_equal version, shell_output("./test_tf")
end
end