51 lines
1.7 KiB
Ruby
51 lines
1.7 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.1.0.tar.gz"
|
|
sha256 "aad4470f52fa59f54de7b9a2da727429e6755d91d756f245f952698c42a60027"
|
|
|
|
bottle do
|
|
cellar :any
|
|
sha256 "a5acbff2b7eb24d98bbf4c189d6c88851032dcc5171bd938b6f165079aee7c4d" => :sierra
|
|
sha256 "5be9de1f5af8f24a2804b1f04b5078e0adc49df714658458337b369f6a2f08a7" => :el_capitan
|
|
sha256 "3042303160e55e4260606be386d5a76c76a25f27df00b6970ff1569166a97ab4" => :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"
|
|
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
|