From 0fe21efd8a5b52b70fd2e997f0d85b8d8f5b2074 Mon Sep 17 00:00:00 2001 From: Sean Morgan Date: Fri, 19 Apr 2019 14:39:43 -0400 Subject: [PATCH 1/6] Build using sysconfig for linux and macos --- README.md | 4 +++- configure.sh | 2 ++ tf_dependency/BUILD.tpl | 6 +----- tf_dependency/tf_configure.bzl | 11 +++++++---- 4 files changed, 13 insertions(+), 10 deletions(-) diff --git a/README.md b/README.md index e7da3374cb..05fd666f73 100644 --- a/README.md +++ b/README.md @@ -63,7 +63,7 @@ To install the latest version, run the following: pip install tensorflow-addons ``` -**Note:** You will also need [TensorFlow 2.0 or higher](https://www.tensorflow.org/alpha). +**Note:** You will need `tensorflow==2.0.0.a0` installed To use addons: @@ -76,6 +76,8 @@ import tensorflow_addons as tfa You can also install from source. This requires the [Bazel]( https://bazel.build/) build system. +**Note:** If building from master you must use `tf-nightly-2.0-preview` + ``` git clone https://github.com/tensorflow/addons.git cd addons diff --git a/configure.sh b/configure.sh index f8deeb6a00..6d89333f9e 100755 --- a/configure.sh +++ b/configure.sh @@ -44,6 +44,8 @@ pip install $QUIET_FLAG -r requirements.txt TF_CFLAGS=( $(python -c 'import tensorflow as tf; print(" ".join(tf.sysconfig.get_compile_flags()))') ) TF_LFLAGS=( $(python -c 'import tensorflow as tf; print(" ".join(tf.sysconfig.get_link_flags()))') ) +TF_SHAREDLIB=( $(python -c 'import tensorflow as tf; print(tf.sysconfig.get_link_flags()[-1])') ) write_action_env_to_bazelrc "TF_HEADER_DIR" ${TF_CFLAGS:2} write_action_env_to_bazelrc "TF_SHARED_LIBRARY_DIR" ${TF_LFLAGS:2} +write_action_env_to_bazelrc "TF_SHARED_LIBRARY" ${TF_SHAREDLIB:3} diff --git a/tf_dependency/BUILD.tpl b/tf_dependency/BUILD.tpl index a1a225ab3a..047baee46b 100644 --- a/tf_dependency/BUILD.tpl +++ b/tf_dependency/BUILD.tpl @@ -7,14 +7,10 @@ cc_library( visibility = ["//visibility:public"], ) -# FIXME: Read shared library name from the installed python package. -# See https://github.com/tensorflow/tensorflow/issues/27430 for why we're -# linking with hardcoded framework.so.2 cc_library( name = "libtensorflow_framework", - srcs = [":libtensorflow_framework.so.2"], - #data = ["lib/libtensorflow_framework.so.2"], + srcs = ["%{TF_SHARED_LIBRARY_NAME}"], visibility = ["//visibility:public"], ) diff --git a/tf_dependency/tf_configure.bzl b/tf_dependency/tf_configure.bzl index b1f188b56c..6a78bdf483 100644 --- a/tf_dependency/tf_configure.bzl +++ b/tf_dependency/tf_configure.bzl @@ -1,8 +1,8 @@ """Setup TensorFlow as external dependency""" _TF_HEADER_DIR = "TF_HEADER_DIR" - _TF_SHARED_LIBRARY_DIR = "TF_SHARED_LIBRARY_DIR" +_TF_SHARED_LIBRARY = "TF_SHARED_LIBRARY" def _tpl(repository_ctx, tpl, substitutions = {}, out = None): if not out: @@ -183,19 +183,22 @@ def _tf_pip_impl(repository_ctx): ) tf_shared_library_dir = repository_ctx.os.environ[_TF_SHARED_LIBRARY_DIR] - tf_shared_library_path = "%s/libtensorflow_framework.so.2" % tf_shared_library_dir + tf_shared_library_name = repository_ctx.os.environ[_TF_SHARED_LIBRARY] + tf_shared_library_path = "%s/%s" % (tf_shared_library_dir, tf_shared_library_name) + tf_shared_library_rule = _symlink_genrule_for_dir( repository_ctx, None, "", - "libtensorflow_framework.so.2", + tf_shared_library_name, [tf_shared_library_path], - ["libtensorflow_framework.so.2"], + [tf_shared_library_name], ) _tpl(repository_ctx, "BUILD", { "%{TF_HEADER_GENRULE}": tf_header_rule, "%{TF_SHARED_LIBRARY_GENRULE}": tf_shared_library_rule, + "%{TF_SHARED_LIBRARY_NAME}": tf_shared_library_name, }) tf_configure = repository_rule( From 0fbf4d6eee3a6de59f773501fe19f2a23b96e882 Mon Sep 17 00:00:00 2001 From: Sean Morgan Date: Fri, 19 Apr 2019 14:44:42 -0400 Subject: [PATCH 2/6] Reword README --- README.md | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index 05fd666f73..d79413a73a 100644 --- a/README.md +++ b/README.md @@ -62,8 +62,8 @@ To install the latest version, run the following: ``` pip install tensorflow-addons ``` - -**Note:** You will need `tensorflow==2.0.0.a0` installed + +**Note:** You will also need `tensorflow==2.0.0.a0` [installed](https://www.tensorflow.org/alpha) To use addons: @@ -76,7 +76,7 @@ import tensorflow_addons as tfa You can also install from source. This requires the [Bazel]( https://bazel.build/) build system. -**Note:** If building from master you must use `tf-nightly-2.0-preview` +**Note:** If building from master you must install `tf-nightly-2.0-preview` in the process ``` git clone https://github.com/tensorflow/addons.git From d4ed41303ccbbca7a848aa9f8ba88ba91195f2c6 Mon Sep 17 00:00:00 2001 From: Sean Morgan Date: Sun, 21 Apr 2019 19:59:44 -0400 Subject: [PATCH 3/6] FIx linting --- tf_dependency/tf_configure.bzl | 2 ++ 1 file changed, 2 insertions(+) diff --git a/tf_dependency/tf_configure.bzl b/tf_dependency/tf_configure.bzl index 6a78bdf483..27495f8e99 100644 --- a/tf_dependency/tf_configure.bzl +++ b/tf_dependency/tf_configure.bzl @@ -1,7 +1,9 @@ """Setup TensorFlow as external dependency""" _TF_HEADER_DIR = "TF_HEADER_DIR" + _TF_SHARED_LIBRARY_DIR = "TF_SHARED_LIBRARY_DIR" + _TF_SHARED_LIBRARY = "TF_SHARED_LIBRARY" def _tpl(repository_ctx, tpl, substitutions = {}, out = None): From f0b98c4f3d4ae8495a0bc6754053a411d5f5568f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Yan=20Facai=20=28=E9=A2=9C=E5=8F=91=E6=89=8D=29?= Date: Mon, 22 Apr 2019 05:15:05 -0700 Subject: [PATCH 4/6] Update README.md Co-Authored-By: seanpmorgan --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index d79413a73a..ad5c583496 100644 --- a/README.md +++ b/README.md @@ -76,7 +76,7 @@ import tensorflow_addons as tfa You can also install from source. This requires the [Bazel]( https://bazel.build/) build system. -**Note:** If building from master you must install `tf-nightly-2.0-preview` in the process +**Note:** If building from master you must install `tf-nightly-2.0-preview` in the process. ``` git clone https://github.com/tensorflow/addons.git From f2c7e791100278501b75bbb237d72127a35e7499 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Yan=20Facai=20=28=E9=A2=9C=E5=8F=91=E6=89=8D=29?= Date: Mon, 22 Apr 2019 05:15:11 -0700 Subject: [PATCH 5/6] Update README.md Co-Authored-By: seanpmorgan --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index ad5c583496..6e9ed562c2 100644 --- a/README.md +++ b/README.md @@ -63,7 +63,7 @@ To install the latest version, run the following: pip install tensorflow-addons ``` -**Note:** You will also need `tensorflow==2.0.0.a0` [installed](https://www.tensorflow.org/alpha) +**Note:** You will also need [`tensorflow==2.0.0.a0`](https://www.tensorflow.org/alpha) installed. To use addons: From dd5ef8e4b1a8c91216b26400d3beabe0dcc2ca0d Mon Sep 17 00:00:00 2001 From: Sean Morgan Date: Mon, 22 Apr 2019 08:18:02 -0400 Subject: [PATCH 6/6] Standardize naming --- configure.sh | 2 +- tf_dependency/tf_configure.bzl | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/configure.sh b/configure.sh index 6d89333f9e..cc0d9d0fee 100755 --- a/configure.sh +++ b/configure.sh @@ -48,4 +48,4 @@ TF_SHAREDLIB=( $(python -c 'import tensorflow as tf; print(tf.sysconfig.get_link write_action_env_to_bazelrc "TF_HEADER_DIR" ${TF_CFLAGS:2} write_action_env_to_bazelrc "TF_SHARED_LIBRARY_DIR" ${TF_LFLAGS:2} -write_action_env_to_bazelrc "TF_SHARED_LIBRARY" ${TF_SHAREDLIB:3} +write_action_env_to_bazelrc "TF_SHARED_LIBRARY_NAME" ${TF_SHAREDLIB:3} diff --git a/tf_dependency/tf_configure.bzl b/tf_dependency/tf_configure.bzl index 6a78bdf483..434dcdfadd 100644 --- a/tf_dependency/tf_configure.bzl +++ b/tf_dependency/tf_configure.bzl @@ -2,7 +2,7 @@ _TF_HEADER_DIR = "TF_HEADER_DIR" _TF_SHARED_LIBRARY_DIR = "TF_SHARED_LIBRARY_DIR" -_TF_SHARED_LIBRARY = "TF_SHARED_LIBRARY" +_TF_SHARED_LIBRARY_NAME = "TF_SHARED_LIBRARY_NAME" def _tpl(repository_ctx, tpl, substitutions = {}, out = None): if not out: @@ -183,7 +183,7 @@ def _tf_pip_impl(repository_ctx): ) tf_shared_library_dir = repository_ctx.os.environ[_TF_SHARED_LIBRARY_DIR] - tf_shared_library_name = repository_ctx.os.environ[_TF_SHARED_LIBRARY] + tf_shared_library_name = repository_ctx.os.environ[_TF_SHARED_LIBRARY_NAME] tf_shared_library_path = "%s/%s" % (tf_shared_library_dir, tf_shared_library_name) tf_shared_library_rule = _symlink_genrule_for_dir(