Changes between Initial Version and Version 1 of Ticket #53946, comment 5


Ignore:
Timestamp:
Jun 24, 2017, 2:40:02 PM (7 years ago)
Author:
kencu (Ken)
Comment:

Legend:

Unmodified
Added
Removed
Modified
  • Ticket #53946, comment 5

    initial v1  
    22
    33<https://github.com/Homebrew/homebrew-core/blob/8e76efdb55e8431dff18c470cfd3694db6a9d208/Formula/libtensorflow.rb>
    4 {{{
    5 class Libtensorflow < Formula
    6   desc "C interface for Google's OS library for Machine Intelligence"
    7   homepage "https://www.tensorflow.org/"
    8   url "https://github.com/tensorflow/tensorflow/archive/v1.2.0.tar.gz"
    9   sha256 "03dbf7548d1fc1c11ed58da5fa68616f795c819f868f43478cbcaa26abed374f"
    10 
    11   bottle do
    12     cellar :any
    13     sha256 "09c17052b8500ca29b16e0b0cf897ff2f1fa1ac58dbb1f8379620f74727cbe75" => :sierra
    14     sha256 "5253b9433228b62e9db77e03ad76f2d03960c9e8e5d7c3888c44c9f090b38c4b" => :el_capitan
    15     sha256 "148f9ee2c1a09e20dbbe126212494e76aa8a699801cd8a1f5838d8d4534f0d4d" => :yosemite
    16   end
    17 
    18   depends_on "bazel" => :build
    19 
    20   def install
    21     ENV["PYTHON_BIN_PATH"] = which("python").to_s
    22     ENV["CC_OPT_FLAGS"] = "-march=native"
    23     ENV["TF_NEED_JEMALLOC"] = "1"
    24     ENV["TF_NEED_GCP"] = "0"
    25     ENV["TF_NEED_HDFS"] = "0"
    26     ENV["TF_ENABLE_XLA"] = "0"
    27     ENV["USE_DEFAULT_PYTHON_LIB_PATH"] = "1"
    28     ENV["TF_NEED_OPENCL"] = "0"
    29     ENV["TF_NEED_CUDA"] = "0"
    30     ENV["TF_NEED_MKL"] = "0"
    31     ENV["TF_NEED_VERBS"] = "0"
    32     system "./configure"
    33 
    34     system "bazel", "build", "--compilation_mode=opt", "--copt=-march=native", "tensorflow:libtensorflow.so"
    35     lib.install "bazel-bin/tensorflow/libtensorflow.so"
    36     (include/"tensorflow/c").install "tensorflow/c/c_api.h"
    37     (lib/"pkgconfig/tensorflow.pc").write <<-EOS.undent
    38       Name: tensorflow
    39       Description: Tensorflow library
    40       Version: #{version}
    41       Libs: -L#{lib} -ltensorflow
    42       Cflags: -I#{include}
    43     EOS
    44   end
    45 
    46   test do
    47     (testpath/"test.c").write <<-EOS.undent
    48       #include <stdio.h>
    49       #include <tensorflow/c/c_api.h>
    50       int main() {
    51         printf("%s", TF_Version());
    52       }
    53     EOS
    54     system ENV.cc, "-L#{lib}", "-ltensorflow", "-o", "test_tf", "test.c"
    55     assert_equal version, shell_output("./test_tf")
    56   end
    57 end
    58 }}}