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.9.0.tar.gz" sha256 "ffc3151b06823d57b4a408261ba8efe53601563dfe93af0866751d4f6ca5068c" bottle do cellar :any sha256 "39ab6ff642ec4fc7c9b33e8825b829b28114739d7a0dc2fced1bbbae5837a17a" => :high_sierra sha256 "d0831926ac2441a126e741ef307e35e075070882486575d6389c7b562a82d161" => :sierra sha256 "5d33085552c8b487b39629be7b7868d8f2db89305e2b824f7c2c7acd9cd9ec1b" => :el_capitan end depends_on "bazel" => :build depends_on :java => ["1.8", :build] def install cmd = Language::Java.java_home_cmd("1.8") ENV["JAVA_HOME"] = Utils.popen_read(cmd).chomp 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" ENV["TF_NEED_MPI"] = "0" ENV["TF_NEED_S3"] = "1" ENV["TF_NEED_GDR"] = "0" ENV["TF_NEED_KAFKA"] = "0" ENV["TF_NEED_OPENCL_SYCL"] = "0" ENV["TF_DOWNLOAD_CLANG"] = "0" ENV["TF_SET_ANDROID_WORKSPACE"] = "0" system "./configure" system "bazel", "build", "--compilation_mode=opt", "--copt=-march=native", "tensorflow:libtensorflow.so" lib.install Dir["bazel-bin/tensorflow/*.so"] (include/"tensorflow/c").install "tensorflow/c/c_api.h" (lib/"pkgconfig/tensorflow.pc").write <<~EOS Name: tensorflow Description: Tensorflow library Version: #{version} Libs: -L#{lib} -ltensorflow Cflags: -I#{include} EOS end test do (testpath/"test.c").write <<~EOS #include #include 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