-
-
Notifications
You must be signed in to change notification settings - Fork 12.7k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Closes #48957. Signed-off-by: Alexander Bayandin <[email protected]>
- Loading branch information
Showing
1 changed file
with
29 additions
and
7 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -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 "[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" | ||
|
@@ -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 | ||
|