Skip to content

Commit

Permalink
Merge pull request #241 from google/sr
Browse files Browse the repository at this point in the history
load tf versioned so file to avoid abi incompatibility for mac
  • Loading branch information
taku910 authored Nov 11, 2018
2 parents 49b54ed + 8850737 commit d35413c
Showing 1 changed file with 33 additions and 17 deletions.
50 changes: 33 additions & 17 deletions tensorflow/make_py_wheel_mac.sh
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,33 @@ set -x # display all commands

PROTOBUF_VERSION=3.6.1

build_tf_wrapper() {
if [ "$1" != "" ]; then
pkg_name="==$1"
fi

# Builds _sentencepiece_processor_ops.so
pip install tensorflow${pkg_name} --upgrade

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_VERSION=( $(python -c 'import tensorflow as tf; print(tf.__version__)') )

g++ -std=c++11 -shared \
-I../../src \
-fPIC ${TF_CFLAGS[@]} -O2 \
-D_GLIBCXX_USE_CXX11_ABI=0 \
-Wl,-all_load \
/usr/local/lib/libprotobuf.a \
/usr/local/lib/libsentencepiece.a \
-Wl,-noall_load \
sentencepiece_processor_ops.cc \
-o tf_sentencepiece/_sentencepiece_processor_ops.so.${TF_VERSION} \
${TF_LFLAGS[@]}

strip -x tf_sentencepiece/_sentencepiece_processor_ops.so.${TF_VERSION}
}

build() {
cd tensorflow
rm -fr build
Expand Down Expand Up @@ -49,24 +76,13 @@ build() {
sudo python get-pip.py --no-setuptools --no-wheel --ignore-installed
pip install --upgrade setuptools
pip install wheel
pip install tensorflow

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()))') )

g++ -std=c++11 -shared \
-I../../src \
-fPIC ${TF_CFLAGS[@]} -O2 \
-D_GLIBCXX_USE_CXX11_ABI=0 \
-Wl,-all_load \
/usr/local/lib/libprotobuf.a \
/usr/local/lib/libsentencepiece.a \
-Wl,-noall_load \
sentencepiece_processor_ops.cc \
-o tf_sentencepiece/_sentencepiece_processor_ops.so \
${TF_LFLAGS[@]}

strip -x tf_sentencepiece/_sentencepiece_processor_ops.so
build_tf_wrapper ""
build_tf_wrapper "1.11.0"
build_tf_wrapper "1.10.0"
build_tf_wrapper "1.9.0"
build_tf_wrapper "1.8.0"
build_tf_wrapper "1.7.0"

# Builds Python manylinux wheel package.
# Platform name is determined by the tensorflow pip package.
Expand Down

0 comments on commit d35413c

Please sign in to comment.