Skip to content

Commit

Permalink
libtensorflow 2.1.0
Browse files Browse the repository at this point in the history
Closes #48957.

Signed-off-by: Alexander Bayandin <[email protected]>
  • Loading branch information
bayandin committed Jan 14, 2020
1 parent 49b3e1d commit 3060bd1
Showing 1 changed file with 29 additions and 7 deletions.
36 changes: 29 additions & 7 deletions Formula/libtensorflow.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -15,16 +15,29 @@ class Libtensorflow < Formula

depends_on "bazel" => :build
depends_on :java => ["1.8", :build]
depends_on "python" => :build
depends_on "[email protected]" => :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"
Expand All @@ -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
Expand Down

0 comments on commit 3060bd1

Please sign in to comment.