Skip to content

Commit

Permalink
Refactor mechanisms of building TF wheel and storing TF project version.
Browse files Browse the repository at this point in the history
A new repository rule `python_wheel_version_suffix_repository` provides information about project and wheel version suffixes. The final value depends on environment variables passed to Bazel command: `_ML_WHEEL_WHEEL_TYPE, _ML_WHEEL_BUILD_DATE, _ML_WHEEL_GIT_HASH, _ML_WHEEL_VERSION_SUFFIX`

`tf_version.bzl` defines the TF project version and loads the version suffix information calculated by `python_wheel_version_suffix_repository`.

The targets `//tensorflow/core/public:release_version, //tensorflow:tensorflow_bzl //tensorflow/tools/pip_package:setup_py` use the version chunks defined above.

The version of the wheel in the build rule output depends on the environment variables.

Environment variables combinations for creating wheels with different versions:
  * snapshot: default build rule behavior (`--repo-env=ML_WHEEL_TYPE=snapshot`)
  * release: `--repo-env=ML_WHEEL_TYPE=release`
  * nightly build with date as version suffix: `--repo-env=ML_WHEEL_TYPE=nightly --repo-env=ML_WHEEL_BUILD_DATE=<YYYYmmdd>`
  * build with git data as version suffix: `--repo-env=ML_WHEEL_TYPE=custom --repo-env=ML_WHEEL_BUILD_DATE=$(git show -s --format=%as HEAD) --repo-env=ML_WHEEL_GIT_HASH=$(git rev-parse HEAD)`
  * build with git data and additional custom version suffix: `--repo-env=ML_WHEEL_TYPE=custom --repo-env=ML_WHEEL_BUILD_DATE=$(git show -s --format=%as HEAD) --repo-env=ML_WHEEL_GIT_HASH=$(git rev-parse HEAD) --repo-env=ML_WHEEL_VERSION_SUFFIX=-rc1`

PiperOrigin-RevId: 716296989
  • Loading branch information
Google-ML-Automation committed Jan 23, 2025
1 parent e9a1a97 commit cb63bc5
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 1 deletion.
10 changes: 10 additions & 0 deletions tensorflow.bazelrc
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,16 @@

# Default build options. These are applied first and unconditionally.

# These are used to generate the ML wheel version string.
# See the explanation in the file comment of
# @tsl//third_party/py/python_wheel.bzl.
# The generated version suffix is used in
# third_party/tensorflow/core/public/release_version.h and
# third_party/tensorflow/tools/pip_package/setup.oss.py.tpl
build --repo_env=ML_WHEEL_TYPE="snapshot"
build --repo_env=ML_WHEEL_BUILD_DATE=""
build --repo_env=ML_WHEEL_VERSION_SUFFIX=""

# For projects which use TensorFlow as part of a Bazel build process, putting
# nothing in a bazelrc will default to a monolithic build. The following line
# opts in to modular op registration support by default.
Expand Down
10 changes: 10 additions & 0 deletions third_party/tsl/.bazelrc
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,16 @@

# Default build options. These are applied first and unconditionally.

# These are used to generate the ML wheel version string.
# See the explanation in the file comment of
# @tsl//third_party/py/python_wheel.bzl.
# The generated version suffix is used in
# third_party/tensorflow/core/public/release_version.h and
# third_party/tensorflow/tools/pip_package/setup.oss.py.tpl
build --repo_env=ML_WHEEL_TYPE="snapshot"
build --repo_env=ML_WHEEL_BUILD_DATE=""
build --repo_env=ML_WHEEL_VERSION_SUFFIX=""

# For projects which use TensorFlow as part of a Bazel build process, putting
# nothing in a bazelrc will default to a monolithic build. The following line
# opts in to modular op registration support by default.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ def verify_manylinux_compliance(
Raises:
RuntimeError: if the wheel is not manyLinux compliant.
"""
regex = 'following platform tag: "{}"'.format(compliance_tag)
regex = 'following platform tag:\s+"{}"'.format(compliance_tag)
if not re.search(regex, auditwheel_log):
raise RuntimeError(
("The wheel is not compliant with the tag {tag}.\n{result}").format(
Expand Down

0 comments on commit cb63bc5

Please sign in to comment.