Skip to content

Commit a46b7b1

Browse files
cantoniostf-text-github-robot
authored andcommitted
Update TF versions and scripts to allow consistently building against tf-nightly.
Currently the master branch contains a patch and other changes that is needed to build against a later version of TF than the 2.13 release (and even the 2.14 rc0). Bumped up the default commit in the WORKSPACE file to allow a build, and bumped up the release version to 2.13 for now (was previously 2.12). Sometimes the tf-nightly build reports a `tf.__git_version__` of "unknown" (occasionally on intel, frequently on ARM), causing the build scripts to fail and abort. Modified the `prepare_tf_dep.sh` to account for this, defaulting to the latest tf-nightly source in such a case. Fixes #1202, #1195. PiperOrigin-RevId: 559233072
1 parent 8f8b2a2 commit a46b7b1

File tree

6 files changed

+34
-24
lines changed

6 files changed

+34
-24
lines changed

.gitignore

+1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
# The .bazelrc file is autogenerated by oss_scripts/configure.sh.
22
.bazelrc
3+
.bazelversion
34

45
# Do not track bazels output directories.
56
bazel-*

WORKSPACE

+3-3
Original file line numberDiff line numberDiff line change
@@ -72,10 +72,10 @@ http_archive(
7272
name = "org_tensorflow",
7373
patch_args = ["-p1"],
7474
patches = ["//third_party/tensorflow:tf.patch"],
75-
strip_prefix = "tensorflow-2.12.0",
76-
sha256 = "af0584df1a4e28763c32c218b39f8c4f3784fabb6a8859b00c02d743864dc191",
75+
strip_prefix = "tensorflow-f21d60a1667c4a52399986809e8e9aedac0e24c2",
76+
sha256 = "35fd0d69969f482edcc1e46d2d07c43a16ee02cfef1396b11a71b719674a1c8a",
7777
urls = [
78-
"https://github.com/tensorflow/tensorflow/archive/v2.12.0.zip"
78+
"https://github.com/tensorflow/tensorflow/archive/f21d60a1667c4a52399986809e8e9aedac0e24c2.zip"
7979
],
8080
)
8181

oss_scripts/configure.sh

+3-3
Original file line numberDiff line numberDiff line change
@@ -46,12 +46,12 @@ else
4646
if is_macos; then
4747
# Only Apple Silicon will be installed with tensorflow-macos.
4848
if [[ x"$(arch)" == x"arm64" ]]; then
49-
pip install tensorflow-macos==2.9.0
49+
pip install tensorflow-macos==2.13.0
5050
else
51-
pip install tensorflow==2.12.0
51+
pip install tensorflow==2.13.0
5252
fi
5353
else
54-
pip install tensorflow==2.12.0
54+
pip install tensorflow==2.13.0
5555
fi
5656
fi
5757

oss_scripts/pip_package/setup.py

+4-4
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@
3232
from setuptools.dist import Distribution
3333

3434
project_name = 'tensorflow-text'
35-
project_version = '2.12.0'
35+
project_version = '2.13.0'
3636

3737

3838
class BinaryDistribution(Distribution):
@@ -74,18 +74,18 @@ def finalize_options(self):
7474
distclass=BinaryDistribution,
7575
install_requires=[
7676
(
77-
'tensorflow>=2.12.0, <2.13; platform_machine != "arm64" or'
77+
'tensorflow>=2.13.0, <2.14; platform_machine != "arm64" or'
7878
' platform_system != "Darwin"'
7979
),
8080
(
81-
'tensorflow-macos>=2.12.0, <2.13; platform_machine == "arm64" and'
81+
'tensorflow-macos>=2.13.0, <2.14; platform_machine == "arm64" and'
8282
' platform_system == "Darwin"'
8383
),
8484
'tensorflow_hub>=0.13.0',
8585
],
8686
extras_require={
8787
'tensorflow_cpu': [
88-
'tensorflow-cpu>=2.12.0, <2.13',
88+
'tensorflow-cpu>=2.13.0, <2.14',
8989
],
9090
'tests': [
9191
'absl-py',

oss_scripts/prepare_tf_dep.sh

+22-13
Original file line numberDiff line numberDiff line change
@@ -13,25 +13,34 @@ if [[ "${osname}" == "darwin" ]]; then
1313
ext='""'
1414
fi
1515

16-
# update setup.nightly.py with tf version
16+
# Update setup.nightly.py with current tf version.
1717
tf_version=$($installed_python -c 'import tensorflow as tf; print(tf.__version__)')
18-
echo "$tf_version"
19-
sed -i $ext "s/project_version = 'REPLACE_ME'/project_version = '${tf_version}'/" oss_scripts/pip_package/setup.nightly.py
20-
# update __version__
18+
echo "Updating setup.nightly.py to version $tf_version"
19+
sed -i $ext "s/project_version = '.*'/project_version = '${tf_version}'/" oss_scripts/pip_package/setup.nightly.py
20+
# Update __version__.
21+
echo "Updating __init__.py to version $tf_version"
2122
sed -i $ext "s/__version__ = .*\$/__version__ = \"${tf_version}\"/" tensorflow_text/__init__.py
2223

23-
# Get commit sha of installed tensorflow
24-
# For some unknown reason this now needs to be split into two commands on Windows
24+
# Get git commit sha of installed tensorflow.
25+
echo "Querying commit SHA"
2526
short_commit_sha=$($installed_python -c 'import tensorflow as tf; print(tf.__git_version__)' | tail -1)
26-
if [[ "${osname}" == "darwin" ]]; then
27-
short_commit_sha=$(echo $short_commit_sha | perl -nle 'print $& while m{(?<=-g)[0-9a-f]*$}g')
27+
if [[ "$short_commit_sha" == "unknown" ]]; then
28+
# Some nightly builds report "unknown" for tf.__git_version.
29+
echo 'TF git version "unknown", assuming nightly.'
30+
commit_slug='nightly'
2831
else
29-
short_commit_sha=$(echo $short_commit_sha | grep -oP '(?<=-g)[0-9a-f]*$')
32+
if [[ "${osname}" == "darwin" ]]; then
33+
short_commit_sha=$(echo $short_commit_sha | perl -nle 'print $& while m{(?<=-g)[0-9a-f]*$}g')
34+
else
35+
short_commit_sha=$(echo $short_commit_sha | grep -oP '(?<=-g)[0-9a-f]*$')
36+
fi
37+
echo "Found tensorflow commit sha: $short_commit_sha"
38+
commit_slug=$(curl -s "https://api.github.com/repos/tensorflow/tensorflow/commits/$short_commit_sha" | grep "sha" | head -n 1 | cut -d '"' -f 4)
3039
fi
31-
commit_sha=$(curl -s "https://api.github.com/repos/tensorflow/tensorflow/commits/$short_commit_sha" | grep "sha" | head -n 1 | cut -d '"' -f 4)
3240

33-
# Update TF dependency to installed tensorflow
34-
sed -E -i $ext "s/strip_prefix = \"tensorflow-2.+\",/strip_prefix = \"tensorflow-${commit_sha}\",/" WORKSPACE
35-
sed -E -i $ext "s|\"https://github.com/tensorflow/tensorflow/archive/v.+\.zip\"|\"https://github.com/tensorflow/tensorflow/archive/${commit_sha}.zip\"|" WORKSPACE
41+
# Update TF dependency to installed tensorflow.
42+
echo "Updating WORKSPACE file to use TensorFlow commit $commit_slug"
43+
sed -E -i $ext "s/strip_prefix = \"tensorflow-.+\",/strip_prefix = \"tensorflow-${commit_slug}\",/" WORKSPACE
44+
sed -E -i $ext "s|\"https://github.com/tensorflow/tensorflow/archive/.+\.zip\"|\"https://github.com/tensorflow/tensorflow/archive/${commit_slug}.zip\"|" WORKSPACE
3645
prev_shasum=$(grep -A 1 -e "strip_prefix.*tensorflow-" WORKSPACE | tail -1 | awk -F '"' '{print $2}')
3746
sed -i $ext "s/sha256 = \"${prev_shasum}\",//" WORKSPACE

tensorflow_text/__init__.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -110,4 +110,4 @@
110110
]
111111

112112
remove_undocumented(__name__, _allowed_symbols)
113-
__version__ = "2.12.0"
113+
__version__ = "2.13.0"

0 commit comments

Comments
 (0)