Skip to content

Commit ac01c45

Browse files
committed
Refactor build and test scripts to use prepare_tf_dep.sh
PiperOrigin-RevId: 446639445
1 parent fb6c679 commit ac01c45

File tree

1 file changed

+7
-5
lines changed

1 file changed

+7
-5
lines changed

oss_scripts/prepare_tf_dep.sh

+7-5
Original file line numberDiff line numberDiff line change
@@ -10,16 +10,18 @@ fi
1010
# update setup.nightly.py with tf version
1111
tf_version=$($installed_python -c 'import tensorflow as tf; print(tf.__version__)')
1212
echo "$tf_version"
13-
sed -i "s/project_version = 'REPLACE_ME'/project_version = '${tf_version}'/" oss_scripts/pip_package/setup.nightly.py
13+
sed -E -i "s/project_version = 'REPLACE_ME'/project_version = '${tf_version}'/" oss_scripts/pip_package/setup.nightly.py
1414
# update __version__
15-
sed -i "s/__version__ = .*\$/__version__ = \"${tf_version}\"/" tensorflow_text/__init__.py
15+
sed -E -i "s/__version__ = .*\$/__version__ = \"${tf_version}\"/" tensorflow_text/__init__.py
1616

1717
# Get commit sha of installed tensorflow
18-
short_commit_sha=$($installed_python -c 'import tensorflow as tf; print(tf.__git_version__)' | tail -1 | grep -oP '(?<=-g)[0-9a-f]*$')
18+
# For some unknown reason this now needs to be split into two commands on Windows
19+
short_commit_sha=$($installed_python -c 'import tensorflow as tf; print(tf.__git_version__)' | tail -1)
20+
short_commit_sha=$(echo $short_commit_sha | grep -oP '(?<=-g)[0-9a-f]*$')
1921
commit_sha=$(curl -SsL https://github.com/tensorflow/tensorflow/commit/${short_commit_sha} | grep sha-block | grep commit | sed -e 's/.*\([a-f0-9]\{40\}\).*/\1/')
2022

2123
# Update TF dependency to installed tensorflow
22-
sed -i "s/strip_prefix = \"tensorflow-.\+\",/strip_prefix = \"tensorflow-${commit_sha}\",/" WORKSPACE
23-
sed -i "s|\"https://github.com/tensorflow/tensorflow/archive/.\+\.zip\"|\"https://github.com/tensorflow/tensorflow/archive/${commit_sha}.zip\"|" WORKSPACE
24+
sed -E -i "s/strip_prefix = \"tensorflow-2.\+\",/strip_prefix = \"tensorflow-${commit_sha}\",/" WORKSPACE
25+
sed -E -i "s|\"https://github.com/tensorflow/tensorflow/archive/.\+\.zip\"|\"https://github.com/tensorflow/tensorflow/archive/${commit_sha}.zip\"|" WORKSPACE
2426
prev_shasum=$(grep -A 1 -e "strip_prefix.*tensorflow-" WORKSPACE | tail -1 | awk -F '"' '{print $2}')
2527
sed -i "s/sha256 = \"${prev_shasum}\",//" WORKSPACE

0 commit comments

Comments
 (0)