Skip to content

Commit a9ee66a

Browse files
authored
FIX: build using tf sysconfig (#197)
* Build using sysconfig for linux and macos
1 parent c5c7dae commit a9ee66a

File tree

4 files changed

+15
-10
lines changed

4 files changed

+15
-10
lines changed

README.md

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -62,8 +62,8 @@ To install the latest version, run the following:
6262
```
6363
pip install tensorflow-addons
6464
```
65-
66-
**Note:** You will also need [TensorFlow 2.0 or higher](https://www.tensorflow.org/alpha).
65+
66+
**Note:** You will also need [`tensorflow==2.0.0.a0`](https://www.tensorflow.org/alpha) installed.
6767

6868
To use addons:
6969

@@ -76,6 +76,8 @@ import tensorflow_addons as tfa
7676
You can also install from source. This requires the [Bazel](
7777
https://bazel.build/) build system.
7878

79+
**Note:** If building from master you must install `tf-nightly-2.0-preview` in the process.
80+
7981
```
8082
git clone https://github.com/tensorflow/addons.git
8183
cd addons

configure.sh

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,8 @@ pip install $QUIET_FLAG -r requirements.txt
4444

4545
TF_CFLAGS=( $(python -c 'import tensorflow as tf; print(" ".join(tf.sysconfig.get_compile_flags()))') )
4646
TF_LFLAGS=( $(python -c 'import tensorflow as tf; print(" ".join(tf.sysconfig.get_link_flags()))') )
47+
TF_SHAREDLIB=( $(python -c 'import tensorflow as tf; print(tf.sysconfig.get_link_flags()[-1])') )
4748

4849
write_action_env_to_bazelrc "TF_HEADER_DIR" ${TF_CFLAGS:2}
4950
write_action_env_to_bazelrc "TF_SHARED_LIBRARY_DIR" ${TF_LFLAGS:2}
51+
write_action_env_to_bazelrc "TF_SHARED_LIBRARY_NAME" ${TF_SHAREDLIB:3}

tf_dependency/BUILD.tpl

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -7,14 +7,10 @@ cc_library(
77
visibility = ["//visibility:public"],
88
)
99

10-
# FIXME: Read shared library name from the installed python package.
11-
# See https://github.com/tensorflow/tensorflow/issues/27430 for why we're
12-
# linking with hardcoded framework.so.2
1310

1411
cc_library(
1512
name = "libtensorflow_framework",
16-
srcs = [":libtensorflow_framework.so.2"],
17-
#data = ["lib/libtensorflow_framework.so.2"],
13+
srcs = ["%{TF_SHARED_LIBRARY_NAME}"],
1814
visibility = ["//visibility:public"],
1915
)
2016

tf_dependency/tf_configure.bzl

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@ _TF_HEADER_DIR = "TF_HEADER_DIR"
44

55
_TF_SHARED_LIBRARY_DIR = "TF_SHARED_LIBRARY_DIR"
66

7+
_TF_SHARED_LIBRARY_NAME = "TF_SHARED_LIBRARY_NAME"
8+
79
def _tpl(repository_ctx, tpl, substitutions = {}, out = None):
810
if not out:
911
out = tpl
@@ -183,19 +185,22 @@ def _tf_pip_impl(repository_ctx):
183185
)
184186

185187
tf_shared_library_dir = repository_ctx.os.environ[_TF_SHARED_LIBRARY_DIR]
186-
tf_shared_library_path = "%s/libtensorflow_framework.so.2" % tf_shared_library_dir
188+
tf_shared_library_name = repository_ctx.os.environ[_TF_SHARED_LIBRARY_NAME]
189+
tf_shared_library_path = "%s/%s" % (tf_shared_library_dir, tf_shared_library_name)
190+
187191
tf_shared_library_rule = _symlink_genrule_for_dir(
188192
repository_ctx,
189193
None,
190194
"",
191-
"libtensorflow_framework.so.2",
195+
tf_shared_library_name,
192196
[tf_shared_library_path],
193-
["libtensorflow_framework.so.2"],
197+
[tf_shared_library_name],
194198
)
195199

196200
_tpl(repository_ctx, "BUILD", {
197201
"%{TF_HEADER_GENRULE}": tf_header_rule,
198202
"%{TF_SHARED_LIBRARY_GENRULE}": tf_shared_library_rule,
203+
"%{TF_SHARED_LIBRARY_NAME}": tf_shared_library_name,
199204
})
200205

201206
tf_configure = repository_rule(

0 commit comments

Comments
 (0)