From 3060bd15938f290b72640dbdaa1c20fa1bf6548a Mon Sep 17 00:00:00 2001 From: Alexander Bayandin Date: Fri, 29 Nov 2019 16:26:06 +0000 Subject: [PATCH] libtensorflow 2.1.0 Closes #48957. Signed-off-by: Alexander Bayandin --- Formula/libtensorflow.rb | 36 +++++++++++++++++++++++++++++------- 1 file changed, 29 insertions(+), 7 deletions(-) diff --git a/Formula/libtensorflow.rb b/Formula/libtensorflow.rb index 47b2019089e89..cfc0785acb07f 100644 --- a/Formula/libtensorflow.rb +++ b/Formula/libtensorflow.rb @@ -3,8 +3,8 @@ 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/v2.0.0.tar.gz" - sha256 "49b5f0495cd681cbcb5296a4476853d4aea19a43bdd9f179c928a977308a0617" + url "https://github.com/tensorflow/tensorflow/archive/v2.1.0.tar.gz" + sha256 "638e541a4981f52c69da4a311815f1e7989bf1d67a41d204511966e1daed14f7" bottle do cellar :any @@ -15,16 +15,29 @@ class Libtensorflow < Formula depends_on "bazel" => :build depends_on :java => ["1.8", :build] - depends_on "python" => :build + depends_on "python@3.8" => :build + + resource "numpy" do + url "https://files.pythonhosted.org/packages/40/de/0ea5092b8bfd2e3aa6fdbb2e499a9f9adf810992884d414defc1573dca3f/numpy-1.18.1.zip" + sha256 "b6ff59cee96b454516e47e7721098e6ceebef435e3e21ac2d6c3b8b02628eb77" + end + + resource "six" do + url "https://files.pythonhosted.org/packages/94/3e/edcf6fef41d89187df7e38e868b2dd2182677922b600e880baad7749c865/six-1.13.0.tar.gz" + sha256 "30f610279e8b2578cab6db20741130331735c781b56053c59c4076da27f06b66" + end def install - venv_root = "#{buildpath}/venv" - virtualenv_create(venv_root, "python3") + # Bazel fails if version from .bazelversion doesn't match bazel version, so just to use the latest one + rm_f ".bazelversion" cmd = Language::Java.java_home_cmd("1.8") ENV["JAVA_HOME"] = Utils.popen_read(cmd).chomp - ENV["PYTHON_BIN_PATH"] = "#{venv_root}/bin/python" + venv = virtualenv_create("#{buildpath}/venv", "python3") + venv.pip_install resources + ENV["PYTHON_BIN_PATH"] = "#{buildpath}/venv/bin/python" + ENV["CC_OPT_FLAGS"] = "-march=native" ENV["TF_IGNORE_MAX_BAZEL_VERSION"] = "1" ENV["TF_NEED_JEMALLOC"] = "1" @@ -47,7 +60,16 @@ def install ENV["TF_CONFIGURE_IOS"] = "0" system "./configure" - system "bazel", "build", "--jobs", ENV.make_jobs, "--compilation_mode=opt", "--copt=-march=native", "tensorflow:libtensorflow.so" + bazel_args =%W[ + --jobs=#{ENV.make_jobs} + --compilation_mode=opt + --copt=-march=native + ] + targets = %w[ + tensorflow:libtensorflow.so + ] + system "bazel", "build", *bazel_args, *targets + lib.install Dir["bazel-bin/tensorflow/*.so*", "bazel-bin/tensorflow/*.dylib*"] (include/"tensorflow/c").install %w[ tensorflow/c/c_api.h