From d38d2f40d3bbbc14f9ea96345e58ec63b83562b0 Mon Sep 17 00:00:00 2001 From: "TF.Text Team" Date: Fri, 23 Oct 2026 09:08:07 -0700 Subject: [PATCH] Transition OSS Python dependencies and CI builds to hermetic Python. Open-source builds and CI pipelines previously relied on legacy `@pypi_//:pkg` repository targets, `@release_or_nightly` workspace rules, and host-installed Python packages (`pip install`) before invoking Bazel. With the migration to `rules_python` hermetic Python toolchains, Bazel resolves Python interpreter versions and wheel dependencies directly via `requirements.txt` lockfiles and `@pypi//:pkg` targets, making host-level package installation and legacy workspace dependencies redundant and error-prone. Migrate OSS Python dependency rewrites and `oss_scripts/pip_package/BUILD` targets to `@pypi//:pkg`, remove the obsolete `extra_py_deps` helper and `@org_tensorflow_datasets` workspace archive, and declare explicit test dependencies in `BUILD` targets. Every `//third_party/py/absl...` dependency maps to the same `@pypi//absl_py:pkg`, so Copybara keeps the first one in each `deps` list and reversibly comments out the rest; `BUILD` files can list all the absl deps they use. Update `oss_scripts/configure.sh` and `py_deps_profile.bzl` to persist `HERMETIC_PYTHON_VERSION`, `IS_NIGHTLY`, and `TF_VERSION` into `.bazelrc`, re-evaluate the repository rule when environment variables change, and pin `tensorflow==` when re-locking requirements. `configure.sh` does not re-lock when the lock file already has the requested `TF_VERSION`, so the committed lock file is not replaced with stale `tf-keras` or pre-release versions. Presubmit, release, and Docker scripts pass `HERMETIC_PYTHON_VERSION` instead of managing host virtual environments. Presubmits use the release lock file by default. Nightly is used only when `IS_NIGHTLY=nightly` is set (the continuous integration configs set it) or `TF_VERSION` is a dev version. `prepare_tf_dep.sh` updates `setup.nightly.py` for nightly builds and `setup.py` otherwise, the same file `build_pip_package` uses. On macOS and Windows, Bazel is installed (`source oss_scripts/install_bazel.sh`) before `configure.sh` runs `bazel run`; `configure.sh --fetch_bazel_config_only` downloads `.bazelversion` first. Additionally, remove the `rules_ml_toolchain` override from `WORKSPACE` so the newer version from TF's `tf_workspace3()` is used, build new `deps` lists instead of using `deps +=` on default arguments in `tftext.bzl.oss`, and read only the first line of `.bazelversion` in `run_tests.sh`. PiperOrigin-RevId: 1005644968 --- WORKSPACE | 21 --- docs/tutorials/BUILD | 8 +- oss_scripts/build.Dockerfile.aarch64 | 8 +- oss_scripts/build.Dockerfile.x86_64 | 8 +- oss_scripts/configure.sh | 65 ++++--- oss_scripts/pip_package/BUILD | 4 +- oss_scripts/prepare_tf_dep.sh | 17 +- oss_scripts/run_build.sh | 9 +- oss_scripts/run_tests.sh | 6 +- tensorflow_text/BUILD | 191 ++++++++++++++------ tensorflow_text/core/pybinds/BUILD | 2 +- tensorflow_text/tftext.bzl | 21 +-- tensorflow_text/tools/wordpiece_vocab/BUILD | 4 +- third_party/bazel/py_deps_profile.bzl | 10 +- 14 files changed, 225 insertions(+), 149 deletions(-) diff --git a/WORKSPACE b/WORKSPACE index 08b0196bc..1fcb73502 100644 --- a/WORKSPACE +++ b/WORKSPACE @@ -81,15 +81,6 @@ http_archive( ], ) -http_archive( - name = "org_tensorflow_datasets", - sha256 = "c6ff4e2306387f0ca45d4f616d9a1c5e79e02ef16d0a8958230a8049ea07fc98", - strip_prefix = "datasets-3.2.0", - urls = [ - "https://github.com/tensorflow/datasets/archive/v3.2.0.zip", - ], -) - http_archive( name = "pybind11", build_file = "//third_party/pybind11:BUILD.bzl", @@ -140,7 +131,6 @@ py_deps_profile( deps_map = { "tensorflow": [ "tf-nightly", - "tf_headers", "tf_header_lib", "libtensorflow_framework", ], @@ -206,17 +196,6 @@ load( python_wheel_version_suffix_repository(name = "tf_wheel_version_suffix") -# Toolchains for ML projects hermetic builds. -# Details: https://github.com/google-ml-infra/rules_ml_toolchain -http_archive( - name = "rules_ml_toolchain", - sha256 = "54c1a357f71f611efdb4891ebd4bcbe4aeb6dfa7e473f14fd7ecad5062096616", - strip_prefix = "rules_ml_toolchain-d8cb9c2c168cd64000eaa6eda0781a9615a26ffe", - urls = [ - "https://github.com/google-ml-infra/rules_ml_toolchain/archive/d8cb9c2c168cd64000eaa6eda0781a9615a26ffe.tar.gz", - ], -) - load( "@rules_ml_toolchain//cc/deps:cc_toolchain_deps.bzl", "cc_toolchain_deps", diff --git a/docs/tutorials/BUILD b/docs/tutorials/BUILD index caf7e179f..100b1f35d 100644 --- a/docs/tutorials/BUILD +++ b/docs/tutorials/BUILD @@ -24,7 +24,7 @@ tf_org_notebook_test( deps = [ "//third_party/py/matplotlib", "@pypi//numpy:pkg", - # tensorflow datasets dep, + "@pypi//tensorflow_datasets:pkg", ], ) @@ -43,9 +43,9 @@ tf_org_notebook_test( tags = ["requires-net:external"], deps = [ "//third_party/py/matplotlib", - "@pypi//numpy:pkg", - # tensorflow datasets dep, "//third_party/py/tensorflow_text", + "@pypi//numpy:pkg", + "@pypi//tensorflow_datasets:pkg", ], ) @@ -57,6 +57,6 @@ tf_org_notebook_test( deps = [ "//third_party/py/matplotlib", "@pypi//numpy:pkg", - # tensorflow datasets dep, + "@pypi//tensorflow_datasets:pkg", ], ) diff --git a/oss_scripts/build.Dockerfile.aarch64 b/oss_scripts/build.Dockerfile.aarch64 index cf29aae7a..3b3af6d4b 100644 --- a/oss_scripts/build.Dockerfile.aarch64 +++ b/oss_scripts/build.Dockerfile.aarch64 @@ -22,16 +22,12 @@ RUN --mount=type=cache,target=/var/cache/apt \ checkinstall \ libffi-dev -# Install pip dependencies needed for tensorflow-text +# Install pip dependencies needed for packaging tensorflow-text wheels RUN --mount=type=cache,target=/root/.cache \ ${PYTHON_BIN_PATH} -m pip install -U pip && \ ${PYTHON_BIN_PATH} -m pip install -U \ - absl-py \ auditwheel \ - etils[epath] \ patchelf \ - setuptools \ - twine \ - wheel; + twine; WORKDIR "/tmp/tensorflow_text" diff --git a/oss_scripts/build.Dockerfile.x86_64 b/oss_scripts/build.Dockerfile.x86_64 index 51bf19713..849283af2 100644 --- a/oss_scripts/build.Dockerfile.x86_64 +++ b/oss_scripts/build.Dockerfile.x86_64 @@ -17,16 +17,12 @@ RUN --mount=type=cache,target=/var/cache/apt \ checkinstall \ libffi-dev -# Install pip dependencies needed for tensorflow text. +# Install pip dependencies needed for packaging tensorflow text wheels. RUN --mount=type=cache,target=/root/.cache \ python${PYTHON_VERSION} -m pip install -U pip && \ python${PYTHON_VERSION} -m pip install -U \ - absl-py \ auditwheel \ - etils[epath] \ patchelf \ - setuptools \ - twine \ - wheel; + twine; WORKDIR "/tmp/tensorflow_text" diff --git a/oss_scripts/configure.sh b/oss_scripts/configure.sh index 29b26dfa9..e03b08153 100755 --- a/oss_scripts/configure.sh +++ b/oss_scripts/configure.sh @@ -14,6 +14,8 @@ # limitations under the License. # ============================================================================== +set -e # fail and exit on any command erroring + function write_to_bazelrc() { echo "$1" >> .bazelrc } @@ -29,28 +31,8 @@ function is_macos() { [[ "${osname}" == "darwin" ]] } -# Remove .bazelrc if it already exist -[ -e .bazelrc ] && rm .bazelrc - -# Don't install tensorflow locally. -if (which python3) | grep -q "python3"; then - installed_python="python3" -elif (which python) | grep -q "python"; then - installed_python="python" -fi - -# if [[ $($installed_python -m pip show tensorflow) == *tensorflow* ]] || -# [[ $($installed_python -m pip show tensorflow-macos) == *tensorflow-macos* ]] || -# [[ $($installed_python -m pip show tf-nightly) == *tf-nightly* ]]; then -# echo 'Using installed tensorflow.' -# else -# echo 'Installing tensorflow.' -# if [[ "$IS_NIGHTLY" == "nightly" ]]; then -# $installed_python -m pip install --no-deps tf-nightly -# else -# $installed_python -m pip install --no-deps tensorflow==2.22.0rc0 -# fi -# fi +# Remove .bazelrc if it already exists +rm -f .bazelrc # Copy the current bazelversion of TF. curl https://raw.githubusercontent.com/tensorflow/tensorflow/v2.22.0-rc0/.bazelversion -o .bazelversion @@ -61,6 +43,14 @@ curl https://raw.githubusercontent.com/tensorflow/tensorflow/v2.22.0-rc0/bazel_d # This line breaks Windows builds, so we remove it. sed -i -e 's/build --noincompatible_remove_legacy_whole_archive//' .bazelrc +# With --fetch_bazel_config_only, stop after downloading the TF Bazel config. +# The rest of this script runs `bazel run`, so scripts that have to install +# Bazel first (oss_scripts/install_bazel.sh reads .bazelversion) call this +# script once with the flag, then install Bazel, then run it again. +if [[ "${1:-}" == "--fetch_bazel_config_only" ]]; then + exit 0 +fi + write_to_bazelrc "build:manylinux2014 --config=release_cpu_linux" write_to_bazelrc "test --test_env=TF_USE_LEGACY_KERAS=1" @@ -68,14 +58,41 @@ if [ -z "$HERMETIC_PYTHON_VERSION" ]; then if [ -n "$PY_VERSION" ]; then HERMETIC_PYTHON_VERSION=$PY_VERSION else - HERMETIC_PYTHON_VERSION=$($installed_python -c "import sys; print('.'.join(map(str, sys.version_info[:2])))") + if (which python3) | grep -q "python3"; then + installed_python="python3" + elif (which python) | grep -q "python"; then + installed_python="python" + fi + HERMETIC_PYTHON_VERSION=$($installed_python -c "import sys; print('.'.join(map(str, sys.version_info[:2])))") fi fi export HERMETIC_PYTHON_VERSION -# Only auto-upgrade requirements for nightly. +if [[ -n "$HERMETIC_PYTHON_VERSION" ]]; then + write_to_bazelrc "build --repo_env=HERMETIC_PYTHON_VERSION=${HERMETIC_PYTHON_VERSION}" +fi +if [[ -n "$IS_NIGHTLY" ]]; then + write_to_bazelrc "build --repo_env=IS_NIGHTLY=${IS_NIGHTLY}" +fi +if [[ -n "$TF_VERSION" ]]; then + write_to_bazelrc "build --repo_env=TF_VERSION=${TF_VERSION}" +fi + +# Re-lock the requirements for nightly builds, or when TF_VERSION is not in the +# lock file yet. Re-locking the current release would pick stale tf-keras and +# pre-release versions, so the committed lock file is used as is in that case. +# The tensorflow==${TF_VERSION} pin comes from @release_or_nightly's +# requirements.in, and pip allows pre-releases for such an explicit pin, so +# --pre is not needed. if [[ "$IS_NIGHTLY" == "nightly" ]]; then bazel run //oss_scripts/pip_package:requirements.update -- --upgrade +elif [[ -n "$TF_VERSION" ]]; then + requirements_lock="oss_scripts/pip_package/requirements_lock_${HERMETIC_PYTHON_VERSION//./_}.txt" + if awk -v dep="tensorflow==${TF_VERSION//-/}" '$1 == dep {found = 1} END {exit !found}' "$requirements_lock"; then + echo "tensorflow==${TF_VERSION} is already in ${requirements_lock}, using it as is." + else + bazel run //oss_scripts/pip_package:requirements.update -- --upgrade + fi fi TF_ABIFLAG=$(bazel run //oss_scripts/pip_package:tensorflow_build_info -- abi) diff --git a/oss_scripts/pip_package/BUILD b/oss_scripts/pip_package/BUILD index 208a9aa1d..fa1801af6 100644 --- a/oss_scripts/pip_package/BUILD +++ b/oss_scripts/pip_package/BUILD @@ -23,7 +23,7 @@ py_binary( name = "tensorflow_build_info", srcs = ["tensorflow_build_info.py"], deps = [ - "@absl_py//absl:app", + "@pypi//absl_py:pkg", "@release_or_nightly//:tensorflow_pkg", ], ) @@ -40,6 +40,6 @@ py_binary( "//tensorflow_text/core/pybinds:pybinds_binaries", ], deps = [ - "@pypi_setuptools//:pkg", + "@pypi//setuptools:pkg", ], ) diff --git a/oss_scripts/prepare_tf_dep.sh b/oss_scripts/prepare_tf_dep.sh index 731f352d8..3281b1e99 100755 --- a/oss_scripts/prepare_tf_dep.sh +++ b/oss_scripts/prepare_tf_dep.sh @@ -1,22 +1,21 @@ #!/bin/bash set -e # fail and exit on any command erroring -if (which python3) | grep -q "python3"; then - installed_python="python3" -elif (which python) | grep -q "python"; then - installed_python="python" -fi - ext="" osname="$(uname -s | tr 'A-Z' 'a-z')" if [[ "${osname}" == "darwin" ]]; then ext='""' fi -# Update setup.nightly.py with current tf version. +# Update the setup file with current tf version. build_pip_package uses +# setup.nightly.py for nightly builds and setup.py otherwise. +setup_file="oss_scripts/pip_package/setup.py" +if [[ "$IS_NIGHTLY" == "nightly" ]]; then + setup_file="oss_scripts/pip_package/setup.nightly.py" +fi tf_version=$(bazel run //oss_scripts/pip_package:tensorflow_build_info -- version) -echo "Updating setup.nightly.py to version $tf_version" -sed -i $ext "s/project_version = '.*'/project_version = '${tf_version}'/" oss_scripts/pip_package/setup.nightly.py +echo "Updating $setup_file to version $tf_version" +sed -i $ext "s/project_version = '.*'/project_version = '${tf_version}'/" "$setup_file" # Update __version__. echo "Updating __init__.py to version $tf_version" sed -i $ext "s/__version__ = .*\$/__version__ = \"${tf_version}\"/" tensorflow_text/__init__.py diff --git a/oss_scripts/run_build.sh b/oss_scripts/run_build.sh index 69a6ef9b0..350a44e88 100755 --- a/oss_scripts/run_build.sh +++ b/oss_scripts/run_build.sh @@ -13,11 +13,10 @@ fi # Run configure. source oss_scripts/configure.sh -# Don't overwrite tensorflow version. -# # Set tensorflow version -# if [[ $osname != "darwin" ]] || [[ ! $(sysctl -n machdep.cpu.brand_string) =~ "Apple" ]]; then -# source oss_scripts/prepare_tf_dep.sh -# fi +# Set tensorflow version if nightly or custom TF_VERSION is specified. +if [[ "$IS_NIGHTLY" == "nightly" ]] || [[ -n "$TF_VERSION" ]]; then + source oss_scripts/prepare_tf_dep.sh +fi # Build the pip package. bazel run ${BUILD_ARGS[@]} --enable_runfiles //oss_scripts/pip_package:build_pip_package -- "$(realpath .)" diff --git a/oss_scripts/run_tests.sh b/oss_scripts/run_tests.sh index c9046ae7d..c5722197e 100644 --- a/oss_scripts/run_tests.sh +++ b/oss_scripts/run_tests.sh @@ -7,7 +7,7 @@ set -e # fail and exit on any command erroring # Verify correct version of Bazel installed_bazel_version=$(bazel version | grep label | sed -e 's/.*: //') -tf_bazel_version=$(cat .bazelversion) +tf_bazel_version=$(head -n 1 .bazelversion) if [ "$installed_bazel_version" != "$tf_bazel_version" ]; then echo "Incorrect version of Bazel installed." echo "Version $tf_bazel_version should be installed, but found version ${installed_bazel_version}." @@ -15,8 +15,8 @@ if [ "$installed_bazel_version" != "$tf_bazel_version" ]; then exit 1 fi -# Set tensorflow version -if [[ $osname != "Darwin" ]] || [[ ! $(sysctl -n machdep.cpu.brand_string) =~ "Apple" ]]; then +# Set tensorflow version if nightly or custom TF_VERSION is specified. +if [[ "$IS_NIGHTLY" == "nightly" ]] || [[ -n "$TF_VERSION" ]]; then source oss_scripts/prepare_tf_dep.sh fi diff --git a/tensorflow_text/BUILD b/tensorflow_text/BUILD index b41b5fdba..c8d6d8370 100644 --- a/tensorflow_text/BUILD +++ b/tensorflow_text/BUILD @@ -4,7 +4,7 @@ load("@rules_cc//cc:cc_library.bzl", "cc_library") # [internal] load build_test.bzl load("@rules_license//rules:license.bzl", "license") load("@xla//third_party/rules_python/python:py_test.bzl", "py_test") -load("//tensorflow_text:tftext.bzl", "extra_py_deps", "if_pywrap", "py_library", "py_tf_text_library") +load("//tensorflow_text:tftext.bzl", "if_pywrap", "py_library", "py_tf_text_library") # Visibility rules package( @@ -131,10 +131,11 @@ py_library( ":whitespace_tokenizer_v2", ":wordpiece_tokenizer", ":wordshape_ops", + "@release_or_nightly//:tensorflow_pkg", # tensorflow package dep # python/util:all_util tensorflow dep, "//tensorflow_text/core/pybinds:tflite_registrar", "//tensorflow_text/tools/wordpiece_vocab", - ] + extra_py_deps() + if_pywrap([ + ] + if_pywrap([ "//tensorflow_text/core/pybinds:pybinds_library", ]), ) @@ -161,11 +162,12 @@ py_library( ":regex_split_ops", ":tokenization", ":wordpiece_tokenizer", + "@release_or_nightly//:tensorflow_pkg", # tensorflow package dep # python/eager:monitoring tensorflow dep, # python/framework:dtypes tensorflow dep, # python/ops:array_ops tensorflow dep, # python/ops:string_ops tensorflow dep, - ] + extra_py_deps(), + ], ) py_test( @@ -176,7 +178,8 @@ py_test( strict_deps = False, deps = [ ":bert_tokenizer", - "@absl_py//absl/testing:parameterized", + "@pypi//absl_py:pkg", # absl/testing:parameterized dep + "@release_or_nightly//:tensorflow_pkg", # tensorflow package dep # python/framework:constant_op tensorflow dep, # python/framework:dtypes tensorflow dep, # python/framework:test_lib tensorflow dep, @@ -201,6 +204,7 @@ py_tf_text_library( "//tensorflow_text/core/kernels:boise_offset_converter_kernel", ], deps = [ + "@release_or_nightly//:tensorflow_pkg", # tensorflow package dep # python/framework:ops tensorflow dep, # python/ops/ragged:ragged_conversion_ops tensorflow dep, # python/ops/ragged:ragged_tensor tensorflow dep, @@ -231,6 +235,7 @@ py_tf_text_library( "//tensorflow_text/core/kernels:byte_splitter_kernel", ], deps = [ + "@release_or_nightly//:tensorflow_pkg", # tensorflow package dep # python/framework:ops tensorflow dep, # python/ops/ragged tensorflow dep, ], @@ -243,6 +248,7 @@ py_test( strict_deps = False, deps = [ ":tensorflow_text", + "@pypi//numpy:pkg", "@release_or_nightly//:tensorflow_pkg", # tensorflow package dep "@release_or_nightly//:tf_keras_pkg", # python/platform:client_testlib tensorflow dep, @@ -259,6 +265,7 @@ py_tf_text_library( "//tensorflow_text/core/kernels:constrained_sequence_kernel", ], deps = [ + "@release_or_nightly//:tensorflow_pkg", # tensorflow package dep # python/framework:dtypes tensorflow dep, # python/framework:ops tensorflow dep, # python/ops/ragged tensorflow dep, @@ -270,6 +277,7 @@ py_library( srcs = ["python/ops/create_feature_bitmask_op.py"], strict_deps = False, deps = [ + "@release_or_nightly//:tensorflow_pkg", # tensorflow package dep # python/framework:constant_op tensorflow dep, # python/framework:dtypes tensorflow dep, # python/framework:errors tensorflow dep, @@ -277,7 +285,7 @@ py_library( # python/ops:array_ops tensorflow dep, # python/ops:check_ops tensorflow dep, # python/ops:math_ops tensorflow dep, - ] + extra_py_deps(), + ], ) py_test( @@ -287,6 +295,7 @@ py_test( strict_deps = False, deps = [ ":create_feature_bitmask_op", + "@release_or_nightly//:tensorflow_pkg", # tensorflow package dep # python/framework:constant_op tensorflow dep, # python/framework:dtypes tensorflow dep, # python/framework:errors tensorflow dep, @@ -304,6 +313,7 @@ py_tf_text_library( "//tensorflow_text/core/kernels:fast_bert_normalizer_tf_kernel", ], deps = [ + "@release_or_nightly//:tensorflow_pkg", # tensorflow package dep # python/eager:monitoring tensorflow dep, # python/framework:constant_op tensorflow dep, # python/framework:dtypes tensorflow dep, @@ -325,7 +335,8 @@ py_test( strict_deps = False, deps = [ ":tensorflow_text", - "@absl_py//absl/testing:parameterized", + "@pypi//absl_py:pkg", # absl/testing:parameterized dep + "@pypi//numpy:pkg", "@release_or_nightly//:tensorflow_pkg", # tensorflow package dep "@release_or_nightly//:tf_keras_pkg", # python/compat tensorflow dep, @@ -352,6 +363,7 @@ py_library( ":fast_bert_normalizer", ":fast_wordpiece_tokenizer", ":tokenization", + "@release_or_nightly//:tensorflow_pkg", # tensorflow package dep # python/eager:monitoring tensorflow dep, # python/framework:dtypes tensorflow dep, # python/ops:array_ops tensorflow dep, @@ -367,7 +379,8 @@ py_test( strict_deps = False, deps = [ ":tensorflow_text", - "@absl_py//absl/testing:parameterized", + "@pypi//absl_py:pkg", # absl/testing:parameterized dep + "@pypi//numpy:pkg", "@release_or_nightly//:tensorflow_pkg", # tensorflow package dep "@release_or_nightly//:tf_keras_pkg", # python/framework:constant_op tensorflow dep, @@ -414,10 +427,11 @@ py_test( deps = [ ":fast_sentencepiece_tokenizer", ":tensorflow_text", - "@absl_py//absl:app", - "@absl_py//absl/flags", - "@absl_py//absl/logging", - "@absl_py//absl/testing:parameterized", + "@pypi//absl_py:pkg", # absl:app dep + # copybara:dedup "@pypi//absl_py:pkg", # absl/flags dep + # copybara:dedup "@pypi//absl_py:pkg", # absl/logging dep + # copybara:dedup "@pypi//absl_py:pkg", # absl/testing:parameterized dep + "@pypi//numpy:pkg", "@release_or_nightly//:tensorflow_pkg", # tensorflow package dep "@release_or_nightly//:tf_keras_pkg", ] + if_pywrap([ @@ -434,6 +448,7 @@ py_tf_text_library( ], deps = [ ":tokenization", + "@release_or_nightly//:tensorflow_pkg", # tensorflow package dep # python/eager:monitoring tensorflow dep, # python/framework:constant_op tensorflow dep, # python/framework:dtypes tensorflow dep, @@ -459,7 +474,8 @@ py_test( strict_deps = False, deps = [ ":tensorflow_text", - "@absl_py//absl/testing:parameterized", + "@pypi//absl_py:pkg", # absl/testing:parameterized dep + "@pypi//numpy:pkg", "@release_or_nightly//:tensorflow_pkg", # tensorflow package dep "@release_or_nightly//:tf_keras_pkg", # python/compat tensorflow dep, @@ -483,6 +499,7 @@ py_tf_text_library( ], deps = [ ":tokenization", + "@release_or_nightly//:tensorflow_pkg", # tensorflow package dep # python/eager:monitoring tensorflow dep, # python/framework:constant_op tensorflow dep, # python/framework:dtypes tensorflow dep, @@ -508,7 +525,7 @@ py_test( strict_deps = False, deps = [ ":tensorflow_text", - "@absl_py//absl/testing:parameterized", + "@pypi//absl_py:pkg", # absl/testing:parameterized dep "@release_or_nightly//:tensorflow_pkg", # tensorflow package dep # python/compat tensorflow dep, # python/data/kernel_tests:test_base tensorflow dep, @@ -529,11 +546,12 @@ py_tf_text_library( ":constrained_sequence_op", ], deps = [ + "@release_or_nightly//:tensorflow_pkg", # tensorflow package dep # python/framework:dtypes tensorflow dep, # python/framework:ops tensorflow dep, # python/ops:array_ops tensorflow dep, # python/ops/ragged:ragged_tensor tensorflow dep, - ] + extra_py_deps(), + ], ) py_test( @@ -544,6 +562,7 @@ py_test( deps = [ ":greedy_constrained_sequence_op", "@pypi//numpy:pkg", + "@release_or_nightly//:tensorflow_pkg", # tensorflow package dep # python/framework:test_lib tensorflow dep, # python/ops/ragged:ragged_factory_ops tensorflow dep, # python/platform:client_testlib tensorflow dep, @@ -556,6 +575,7 @@ py_library( strict_deps = False, deps = [ ":splitter", + "@release_or_nightly//:tensorflow_pkg", # tensorflow package dep # python/eager:monitoring tensorflow dep, # python/ops:array_ops_stack tensorflow dep, # python/ops/ragged:ragged_tensor tensorflow dep, @@ -573,6 +593,8 @@ py_test( strict_deps = False, deps = [ ":ops", + "@pypi//absl_py:pkg", # absl/testing:parameterized dep + "@release_or_nightly//:tensorflow_pkg", # tensorflow package dep # python/framework:ops tensorflow dep, # python/framework:test_lib tensorflow dep, # python/ops:lookup_ops tensorflow dep, @@ -591,6 +613,7 @@ py_library( deps = [ ":hub_module_splitter", ":tokenization", + "@release_or_nightly//:tensorflow_pkg", # tensorflow package dep ], ) @@ -604,6 +627,8 @@ py_test( strict_deps = False, deps = [ ":ops", + "@pypi//absl_py:pkg", # absl/testing:parameterized dep + "@release_or_nightly//:tensorflow_pkg", # tensorflow package dep # python/framework:ops tensorflow dep, # python/framework:test_lib tensorflow dep, # python/ops:lookup_ops tensorflow dep, @@ -620,6 +645,7 @@ py_library( srcs = ["python/ops/item_selector_ops.py"], strict_deps = False, deps = [ + "@release_or_nightly//:tensorflow_pkg", # tensorflow package dep # python/framework:dtypes tensorflow dep, # python/framework:ops tensorflow dep, # python/framework:tensor tensorflow dep, @@ -640,7 +666,7 @@ py_library( # python/ops/ragged:ragged_tensor tensorflow dep, # python/ops/ragged:ragged_tensor_shape tensorflow dep, # python/ops/ragged:ragged_where_op tensorflow dep, - ] + extra_py_deps(), + ], ) py_test( @@ -650,6 +676,8 @@ py_test( strict_deps = False, deps = [ ":item_selector_ops", + "@pypi//absl_py:pkg", # absl/testing:parameterized dep + "@release_or_nightly//:tensorflow_pkg", # tensorflow package dep # python/framework:dtypes tensorflow dep, # python/framework:test_lib tensorflow dep, # python/ops:array_ops tensorflow dep, @@ -664,6 +692,7 @@ py_library( srcs = ["python/ops/masking_ops.py"], strict_deps = False, deps = [ + "@release_or_nightly//:tensorflow_pkg", # tensorflow package dep # python/framework:dtypes tensorflow dep, # python/ops:array_ops tensorflow dep, # python/ops:control_flow_assert tensorflow dep, @@ -688,7 +717,8 @@ py_test( deps = [ ":item_selector_ops", ":masking_ops", - "@absl_py//absl/testing:parameterized", + "@pypi//absl_py:pkg", # absl/testing:parameterized dep + "@release_or_nightly//:tensorflow_pkg", # tensorflow package dep # python/framework:constant_op tensorflow dep, # python/framework:test_lib tensorflow dep, # python/ops:array_ops tensorflow dep, @@ -705,13 +735,14 @@ py_tf_text_library( "//tensorflow_text/core/kernels:mst_op_kernels", ], deps = [ + "@release_or_nightly//:tensorflow_pkg", # tensorflow package dep # python/framework:dtypes tensorflow dep, # python/framework:errors tensorflow dep, # python/framework:ops tensorflow dep, # python/ops:array_ops tensorflow dep, # python/ops:math_ops tensorflow dep, # python/ops:standard_ops tensorflow dep, - ] + extra_py_deps(), + ], ) py_test( @@ -720,6 +751,8 @@ py_test( strict_deps = False, deps = [ ":mst_ops", + "@pypi//numpy:pkg", + "@release_or_nightly//:tensorflow_pkg", # tensorflow package dep # python/framework:constant_op tensorflow dep, # python/framework:dtypes tensorflow dep, # python/framework:test_lib tensorflow dep, @@ -738,6 +771,7 @@ py_tf_text_library( ], deps = [ ":sliding_window_op", + "@release_or_nightly//:tensorflow_pkg", # tensorflow package dep # python/framework:errors tensorflow dep, # python/framework:ops tensorflow dep, # python/ops:math_ops tensorflow dep, @@ -754,6 +788,7 @@ py_test( strict_deps = False, deps = [ ":tensorflow_text", + "@pypi//numpy:pkg", "@release_or_nightly//:tensorflow_pkg", # tensorflow package dep "@release_or_nightly//:tf_keras_pkg", # python/framework:constant_op tensorflow dep, @@ -774,10 +809,11 @@ py_tf_text_library( "//tensorflow_text/core/kernels:normalize_kernels", ], deps = [ + "@release_or_nightly//:tensorflow_pkg", # tensorflow package dep # python/framework:dtypes tensorflow dep, # python/ops/ragged:ragged_conversion_ops tensorflow dep, # python/ops/ragged:ragged_tensor tensorflow dep, - ] + extra_py_deps(), + ], ) py_test( @@ -787,6 +823,8 @@ py_test( strict_deps = False, deps = [ ":normalize_ops", + "@pypi//absl_py:pkg", # absl/testing:parameterized dep + "@release_or_nightly//:tensorflow_pkg", # tensorflow package dep # python/framework:errors tensorflow dep, # python/framework:test_lib tensorflow dep, # python/ops/ragged:ragged_factory_ops tensorflow dep, @@ -799,13 +837,14 @@ py_library( srcs = ["python/ops/pad_along_dimension_op.py"], strict_deps = False, deps = [ + "@release_or_nightly//:tensorflow_pkg", # tensorflow package dep # python/framework:dtypes tensorflow dep, # python/framework:errors tensorflow dep, # python/framework:ops tensorflow dep, # python/ops:array_ops tensorflow dep, # python/ops:math_ops tensorflow dep, # python/ops/ragged:ragged_tensor tensorflow dep, - ] + extra_py_deps(), + ], ) py_test( @@ -815,7 +854,8 @@ py_test( strict_deps = False, deps = [ ":pad_along_dimension_op", - "@absl_py//absl/testing:parameterized", + "@pypi//absl_py:pkg", # absl/testing:parameterized dep + "@release_or_nightly//:tensorflow_pkg", # tensorflow package dep # python/eager:context tensorflow dep, # python/framework:constant_op tensorflow dep, # python/framework:errors tensorflow dep, @@ -832,6 +872,7 @@ py_library( srcs = ["python/ops/pad_model_inputs_ops.py"], strict_deps = False, deps = [ + "@release_or_nightly//:tensorflow_pkg", # tensorflow package dep # python/framework:constant_op tensorflow dep, # python/framework:dtypes tensorflow dep, # python/framework:ops tensorflow dep, @@ -844,7 +885,7 @@ py_library( # python/ops/ragged:ragged_array_ops tensorflow dep, # python/ops/ragged:ragged_map_ops tensorflow dep, # python/ops/ragged:ragged_tensor tensorflow dep, - ] + extra_py_deps(), + ], ) py_test( @@ -853,7 +894,9 @@ py_test( strict_deps = False, deps = [ ":pad_model_inputs_ops", - "@absl_py//absl/testing:parameterized", + "@pypi//absl_py:pkg", # absl/testing:parameterized dep + "@pypi//numpy:pkg", + "@release_or_nightly//:tensorflow_pkg", # tensorflow package dep # python/framework:constant_op tensorflow dep, # python/framework:test_lib tensorflow dep, # python/ops/ragged:ragged_factory_ops tensorflow dep, @@ -866,6 +909,7 @@ py_library( srcs = ["python/ops/pointer_ops.py"], strict_deps = False, deps = [ + "@release_or_nightly//:tensorflow_pkg", # tensorflow package dep # python/framework:dtypes tensorflow dep, # python/framework:ops tensorflow dep, # python/framework:tensor tensorflow dep, @@ -879,7 +923,7 @@ py_library( # python/ops/ragged:ragged_tensor tensorflow dep, # python/ops/ragged:ragged_where_op tensorflow dep, # python/ops/ragged:segment_id_ops tensorflow dep, - ] + extra_py_deps(), + ], ) py_test( @@ -888,7 +932,8 @@ py_test( strict_deps = False, deps = [ ":pointer_ops", - "@absl_py//absl/testing:parameterized", + "@pypi//absl_py:pkg", # absl/testing:parameterized dep + "@release_or_nightly//:tensorflow_pkg", # tensorflow package dep # python/framework:constant_op tensorflow dep, # python/framework:dtypes tensorflow dep, # python/framework:errors tensorflow dep, @@ -904,7 +949,8 @@ py_test( strict_deps = False, deps = [ ":pointer_ops", - "@absl_py//absl/testing:parameterized", + "@pypi//absl_py:pkg", # absl/testing:parameterized dep + "@release_or_nightly//:tensorflow_pkg", # tensorflow package dep # python/framework:test_lib tensorflow dep, # python/ops/ragged:ragged_factory_ops tensorflow dep, # python/platform:client_testlib tensorflow dep, @@ -917,7 +963,8 @@ py_test( strict_deps = False, deps = [ ":pointer_ops", - "@absl_py//absl/testing:parameterized", + "@pypi//absl_py:pkg", # absl/testing:parameterized dep + "@release_or_nightly//:tensorflow_pkg", # tensorflow package dep # python/eager:context tensorflow dep, # python/framework:dtypes tensorflow dep, # python/framework:errors tensorflow dep, @@ -935,6 +982,7 @@ py_test( strict_deps = False, deps = [ ":tensorflow_text", + "@pypi//numpy:pkg", "@release_or_nightly//:tensorflow_pkg", # tensorflow package dep "@release_or_nightly//:tf_keras_pkg", # python/framework:constant_op tensorflow dep, @@ -953,8 +1001,9 @@ py_tf_text_library( cc_op_kernels = ["//tensorflow_text/core/kernels:regex_split_kernels"], deps = [ ":splitter", + "@release_or_nightly//:tensorflow_pkg", # tensorflow package dep # python/ops/ragged:ragged_tensor tensorflow dep, - ] + extra_py_deps(), + ], ) py_test( @@ -964,6 +1013,7 @@ py_test( strict_deps = False, deps = [ ":regex_split_ops", + "@pypi//absl_py:pkg", # absl/testing:parameterized dep "@release_or_nightly//:tensorflow_pkg", # tensorflow package dep # python/framework:test_lib tensorflow dep, ], @@ -974,11 +1024,12 @@ py_library( srcs = ["python/ops/segment_combiner_ops.py"], strict_deps = False, deps = [ + "@release_or_nightly//:tensorflow_pkg", # tensorflow package dep # python/framework:dtypes tensorflow dep, # python/framework:ops tensorflow dep, # python/ops:array_ops tensorflow dep, # python/ops:math_ops tensorflow dep, - ] + extra_py_deps(), + ], ) py_test( @@ -987,7 +1038,8 @@ py_test( strict_deps = False, deps = [ ":segment_combiner_ops", - "@absl_py//absl/testing:parameterized", + "@pypi//absl_py:pkg", # absl/testing:parameterized dep + "@release_or_nightly//:tensorflow_pkg", # tensorflow package dep # python/framework:constant_op tensorflow dep, # python/framework:dtypes tensorflow dep, # python/ops/ragged:ragged_factory_ops tensorflow dep, @@ -1006,6 +1058,7 @@ py_tf_text_library( ], deps = [ ":regex_split_ops", + "@release_or_nightly//:tensorflow_pkg", # tensorflow package dep # tf:lib tensorflow dep, # python/framework:dtypes tensorflow dep, # python/ops:math_ops tensorflow dep, @@ -1023,7 +1076,8 @@ py_test( strict_deps = False, deps = [ ":sentence_breaking_ops", - "@absl_py//absl/testing:parameterized", + "@pypi//absl_py:pkg", # absl/testing:parameterized dep + "@release_or_nightly//:tensorflow_pkg", # tensorflow package dep # python/framework:constant_op tensorflow dep, # python/framework:dtypes tensorflow dep, # python/framework:errors tensorflow dep, @@ -1045,6 +1099,7 @@ py_tf_text_library( ], deps = [ ":tokenization", + "@release_or_nightly//:tensorflow_pkg", # tensorflow package dep # python/framework:dtypes tensorflow dep, # python/framework:ops tensorflow dep, # python/ops:array_ops tensorflow dep, @@ -1066,7 +1121,8 @@ py_test( strict_deps = False, deps = [ ":sentencepiece_tokenizer", - "@absl_py//absl/testing:parameterized", + "@pypi//absl_py:pkg", # absl/testing:parameterized dep + "@release_or_nightly//:tensorflow_pkg", # tensorflow package dep # python/framework:constant_op tensorflow dep, # python/framework:test_lib tensorflow dep, # python/ops/ragged:ragged_factory_ops tensorflow dep, @@ -1081,11 +1137,12 @@ py_library( srcs = ["python/ops/sliding_window_op.py"], strict_deps = False, deps = [ + "@release_or_nightly//:tensorflow_pkg", # tensorflow package dep # python/framework:errors tensorflow dep, # python/framework:ops tensorflow dep, # python/ops:array_ops_stack tensorflow dep, # python/ops/ragged:ragged_tensor tensorflow dep, - ] + extra_py_deps(), + ], ) py_test( @@ -1095,7 +1152,8 @@ py_test( strict_deps = False, deps = [ ":sliding_window_op", - "@absl_py//absl/testing:parameterized", + "@pypi//absl_py:pkg", # absl/testing:parameterized dep + "@release_or_nightly//:tensorflow_pkg", # tensorflow package dep # python/framework:constant_op tensorflow dep, # python/framework:errors tensorflow dep, # python/framework:test_lib tensorflow dep, @@ -1114,6 +1172,7 @@ py_tf_text_library( ], deps = [ ":tokenization", + "@release_or_nightly//:tensorflow_pkg", # tensorflow package dep # python/framework:dtypes tensorflow dep, # python/framework:ops tensorflow dep, # python/ops/ragged tensorflow dep, @@ -1127,6 +1186,7 @@ py_test( strict_deps = False, deps = [ ":split_merge_from_logits_tokenizer", + "@release_or_nightly//:tensorflow_pkg", # tensorflow package dep # python/framework:errors tensorflow dep, # python/framework:test_lib tensorflow dep, # python/ops/ragged:ragged_factory_ops tensorflow dep, @@ -1143,6 +1203,7 @@ py_tf_text_library( ], deps = [ ":tokenization", + "@release_or_nightly//:tensorflow_pkg", # tensorflow package dep # python/framework:dtypes tensorflow dep, # python/framework:ops tensorflow dep, # python/ops/ragged tensorflow dep, @@ -1156,6 +1217,7 @@ py_test( strict_deps = False, deps = [ ":split_merge_tokenizer", + "@release_or_nightly//:tensorflow_pkg", # tensorflow package dep # python/framework:test_lib tensorflow dep, # python/ops/ragged:ragged_factory_ops tensorflow dep, # python/platform:client_testlib tensorflow dep, @@ -1167,6 +1229,7 @@ py_library( srcs = ["python/ops/splitter.py"], strict_deps = False, deps = [ + "@release_or_nightly//:tensorflow_pkg", # tensorflow package dep # python/module tensorflow dep, ], ) @@ -1183,6 +1246,7 @@ py_tf_text_library( deps = [ ":byte_splitter", ":sentence_breaking_ops", + "@release_or_nightly//:tensorflow_pkg", # tensorflow package dep # tf:lib tensorflow dep, # python/framework:dtypes tensorflow dep, # python/ops:math_ops tensorflow dep, @@ -1200,7 +1264,8 @@ py_test( deps = [ ":state_based_sentence_breaker_op", ":tensorflow_text", - "@absl_py//absl/testing:parameterized", + "@pypi//absl_py:pkg", # absl/testing:parameterized dep + "@pypi//numpy:pkg", "@release_or_nightly//:tensorflow_pkg", # tensorflow package dep "@release_or_nightly//:tf_keras_pkg", # python/framework:constant_op tensorflow dep, @@ -1223,8 +1288,9 @@ py_library( srcs = ["python/ops/string_ops.py"], strict_deps = False, deps = [ + "@release_or_nightly//:tensorflow_pkg", # tensorflow package dep # python/ops:string_ops tensorflow dep, - ] + extra_py_deps(), + ], ) py_test( @@ -1234,6 +1300,7 @@ py_test( strict_deps = False, deps = [ ":string_ops", + "@release_or_nightly//:tensorflow_pkg", # tensorflow package dep # python/framework:test_lib tensorflow dep, # python/platform:client_testlib tensorflow dep, ], @@ -1245,12 +1312,13 @@ py_tf_text_library( cc_op_defs = ["//tensorflow_text/core/ops:rouge_l_op.cc"], cc_op_kernels = ["//tensorflow_text/core/kernels:rouge_l_kernel"], deps = [ + "@release_or_nightly//:tensorflow_pkg", # tensorflow package dep # python/framework:dtypes tensorflow dep, # python/framework:ops tensorflow dep, # python/ops:array_ops tensorflow dep, # python/ops:lookup_ops tensorflow dep, # python/ops/ragged:ragged_tensor tensorflow dep, - ] + extra_py_deps(), + ], ) py_test( @@ -1260,7 +1328,8 @@ py_test( strict_deps = False, deps = [ ":text_similarity_metric_ops", - "@absl_py//absl/testing:parameterized", + "@pypi//absl_py:pkg", # absl/testing:parameterized dep + "@release_or_nightly//:tensorflow_pkg", # tensorflow package dep # python/framework:dtypes tensorflow dep, # python/framework:test_lib tensorflow dep, # python/ops:array_ops tensorflow dep, @@ -1289,7 +1358,7 @@ py_test( strict_deps = False, deps = [ ":todense_layer", - "@absl_py//absl/testing:parameterized", + "@pypi//absl_py:pkg", # absl/testing:parameterized dep "@pypi//numpy:pkg", "@release_or_nightly//:tensorflow_pkg", # tensorflow package dep "@release_or_nightly//:tf_keras_pkg", @@ -1303,8 +1372,9 @@ py_library( strict_deps = False, deps = [ ":splitter", + "@release_or_nightly//:tensorflow_pkg", # tensorflow package dep # python/module tensorflow dep, - ] + extra_py_deps(), + ], ) py_library( @@ -1330,7 +1400,7 @@ py_test( strict_deps = False, deps = [ ":tokenization_layers", - "@absl_py//absl/testing:parameterized", + "@pypi//absl_py:pkg", # absl/testing:parameterized dep "@pypi//numpy:pkg", "@release_or_nightly//:tensorflow_pkg", # tensorflow package dep "@release_or_nightly//:tf_keras_pkg", @@ -1346,6 +1416,7 @@ py_tf_text_library( cc_op_kernels = ["//tensorflow_text/core/kernels:round_robin_trimmer_kernel"], deps = [ ":item_selector_ops", + "@release_or_nightly//:tensorflow_pkg", # tensorflow package dep # python/framework:constant_op tensorflow dep, # python/framework:dtypes tensorflow dep, # python/framework:ops tensorflow dep, @@ -1368,7 +1439,7 @@ py_test( deps = [ ":tensorflow_text", ":trimmer_ops", - "@absl_py//absl/testing:parameterized", + "@pypi//absl_py:pkg", # absl/testing:parameterized dep "@release_or_nightly//:tensorflow_pkg", # tensorflow package dep "@release_or_nightly//:tf_keras_pkg", # python/framework:constant_op tensorflow dep, @@ -1393,6 +1464,7 @@ py_library( strict_deps = False, deps = [ ":tokenization", + "@release_or_nightly//:tensorflow_pkg", # tensorflow package dep # python/framework:dtypes tensorflow dep, # python/framework:ops tensorflow dep, # python/ops:array_ops tensorflow dep, @@ -1411,6 +1483,7 @@ py_test( strict_deps = False, deps = [ ":unicode_char_tokenizer", + "@release_or_nightly//:tensorflow_pkg", # tensorflow package dep # python/framework:constant_op tensorflow dep, # python/framework:test_lib tensorflow dep, # python/ops/ragged:ragged_factory_ops tensorflow dep, @@ -1427,6 +1500,7 @@ py_tf_text_library( ], deps = [ ":tokenization", + "@release_or_nightly//:tensorflow_pkg", # tensorflow package dep # python/framework:dtypes tensorflow dep, # python/framework:ops tensorflow dep, # python/ops:array_ops tensorflow dep, @@ -1446,6 +1520,7 @@ py_test( strict_deps = False, deps = [ ":unicode_script_tokenizer", + "@release_or_nightly//:tensorflow_pkg", # tensorflow package dep # python/framework:constant_op tensorflow dep, # python/framework:test_lib tensorflow dep, # python/ops/ragged:ragged_factory_ops tensorflow dep, @@ -1462,6 +1537,7 @@ py_tf_text_library( ], visibility = ["//visibility:private"], deps = [ + "@release_or_nightly//:tensorflow_pkg", # tensorflow package dep # python/framework:ops tensorflow dep, # python/ops:array_ops tensorflow dep, ], @@ -1475,6 +1551,7 @@ py_test( deps = [ ":tensorflow_text", ":utf8_binarize_op", + "@pypi//numpy:pkg", "@release_or_nightly//:tensorflow_pkg", # tensorflow package dep "@release_or_nightly//:tf_keras_pkg", # python/framework:test_lib tensorflow dep, @@ -1491,11 +1568,12 @@ py_tf_text_library( ":constrained_sequence_op", ], deps = [ + "@release_or_nightly//:tensorflow_pkg", # tensorflow package dep # python/framework:dtypes tensorflow dep, # python/framework:ops tensorflow dep, # python/ops:array_ops tensorflow dep, # python/ops/ragged:ragged_tensor tensorflow dep, - ] + extra_py_deps(), + ], ) py_test( @@ -1507,6 +1585,7 @@ py_test( ":viterbi_constrained_sequence_op", ":viterbi_decode", "@pypi//numpy:pkg", + "@release_or_nightly//:tensorflow_pkg", # tensorflow package dep # python/framework:test_lib tensorflow dep, # python/ops/ragged:ragged_factory_ops tensorflow dep, # python/platform:client_testlib tensorflow dep, @@ -1519,7 +1598,7 @@ py_library( strict_deps = False, deps = [ "@pypi//numpy:pkg", - ] + extra_py_deps(), + ], ) py_test( @@ -1529,7 +1608,7 @@ py_test( strict_deps = False, deps = [ ":viterbi_decode", - "@absl_py//absl/testing:absltest", + "@pypi//absl_py:pkg", # absl/testing:absltest dep "@pypi//numpy:pkg", ], ) @@ -1543,6 +1622,7 @@ py_tf_text_library( ], deps = [ ":tokenization", + "@release_or_nightly//:tensorflow_pkg", # tensorflow package dep # python/framework:dtypes tensorflow dep, # python/framework:ops tensorflow dep, # python/ops:array_ops tensorflow dep, @@ -1564,6 +1644,7 @@ py_tf_text_library( deps = [ ":tokenization", ":whitespace_tokenizer", + "@release_or_nightly//:tensorflow_pkg", # tensorflow package dep # python/framework:dtypes tensorflow dep, # python/framework:ops tensorflow dep, # python/ops:array_ops_stack tensorflow dep, @@ -1586,6 +1667,7 @@ py_test( strict_deps = False, deps = [ ":tensorflow_text", + "@pypi//numpy:pkg", "@release_or_nightly//:tensorflow_pkg", # tensorflow package dep "@release_or_nightly//:tf_keras_pkg", # python/framework:constant_op tensorflow dep, @@ -1606,6 +1688,7 @@ py_tf_text_library( ], deps = [ ":tokenization", + "@release_or_nightly//:tensorflow_pkg", # tensorflow package dep # python/compat tensorflow dep, # python/eager:monitoring tensorflow dep, # python/framework:dtypes tensorflow dep, @@ -1632,7 +1715,8 @@ py_test( strict_deps = False, deps = [ ":wordpiece_tokenizer", - "@absl_py//absl/testing:parameterized", + "@pypi//absl_py:pkg", # absl/testing:parameterized dep + "@release_or_nightly//:tensorflow_pkg", # tensorflow package dep # python/compat tensorflow dep, # python/framework:dtypes tensorflow dep, # python/framework:test_lib tensorflow dep, @@ -1649,10 +1733,11 @@ py_library( srcs = ["python/ops/wordshape_ops.py"], strict_deps = False, deps = [ + "@release_or_nightly//:tensorflow_pkg", # tensorflow package dep # python/framework:ops tensorflow dep, # python/ops:array_ops_stack tensorflow dep, # python/ops:string_ops tensorflow dep, - ] + extra_py_deps(), + ], ) py_test( @@ -1662,6 +1747,7 @@ py_test( strict_deps = False, deps = [ ":wordshape_ops", + "@release_or_nightly//:tensorflow_pkg", # tensorflow package dep # python/framework:test_lib tensorflow dep, # python/platform:client_testlib tensorflow dep, ], @@ -1690,7 +1776,7 @@ py_library( deps = [ "@pypi//numpy:pkg", "@release_or_nightly//:tensorflow_pkg", # tensorflow package dep - # tensorflow datasets dep, + "@pypi//tensorflow_datasets:pkg", # python/client:session tensorflow dep, # python/data/ops:dataset_ops tensorflow dep, # python/eager:context tensorflow dep, @@ -1715,8 +1801,9 @@ py_test( deps = [ ":benchmark_utils", ":ops", - "@absl_py//absl:app", - "@absl_py//absl/testing:parameterized", + "@pypi//absl_py:pkg", # absl:app dep + # copybara:dedup "@pypi//absl_py:pkg", # absl/flags dep + # copybara:dedup "@pypi//absl_py:pkg", # absl/testing:parameterized dep "@release_or_nightly//:tensorflow_pkg", # tensorflow package dep # python/framework:dtypes tensorflow dep, # python/user_ops:ops tensorflow dep, @@ -1734,8 +1821,10 @@ py_test( deps = [ ":benchmark_utils", ":ops", - "@absl_py//absl:app", - "@absl_py//absl/testing:parameterized", + "@pypi//absl_py:pkg", # absl:app dep + # copybara:dedup "@pypi//absl_py:pkg", # absl/flags dep + # copybara:dedup "@pypi//absl_py:pkg", # absl/testing:parameterized dep + "@pypi//numpy:pkg", "@release_or_nightly//:tensorflow_pkg", # tensorflow package dep # python/user_ops:ops tensorflow dep, ] + if_pywrap([ diff --git a/tensorflow_text/core/pybinds/BUILD b/tensorflow_text/core/pybinds/BUILD index cc08df086..99abd9939 100644 --- a/tensorflow_text/core/pybinds/BUILD +++ b/tensorflow_text/core/pybinds/BUILD @@ -50,7 +50,7 @@ py_test( ], deps = [ ":pywrap_fast_bert_normalizer_model_builder", - "@absl_py//absl/flags", + "@pypi//absl_py:pkg", # absl/flags dep "@release_or_nightly//:tensorflow_pkg", # tensorflow package dep ] + if_pywrap([":pybinds_library"]), ) diff --git a/tensorflow_text/tftext.bzl b/tensorflow_text/tftext.bzl index 44ab3df73..44ab80494 100644 --- a/tensorflow_text/tftext.bzl +++ b/tensorflow_text/tftext.bzl @@ -182,7 +182,7 @@ def tf_cc_library( oss_deps = oss_deps + _dedupe(deps, "@com_google_absl//absl/time") oss_deps = oss_deps + _dedupe(deps, "@com_google_absl//absl/types:variant") - deps += select({ + deps = list(deps or []) + select({ "@org_tensorflow//tensorflow:mobile": [ "@org_tensorflow//tensorflow/core:portable_tensorflow_lib_lite", ], @@ -241,7 +241,7 @@ def tflite_cc_library( "@com_google_absl//absl/time", "@com_google_absl//absl/types:variant", ] - deps += tflite_deps + select({ + deps = list(deps or []) + tflite_deps + select({ "@org_tensorflow//tensorflow:mobile": [ "@org_tensorflow//tensorflow/core:portable_tensorflow_lib_lite", ], @@ -261,14 +261,6 @@ def tflite_cc_library( alwayslink = alwayslink, ) -def extra_py_deps(): - return [ - "@release_or_nightly//:tensorflow_pkg", - "@release_or_nightly//:tf_keras_pkg", - "@pypi_tensorflow_datasets//:pkg", - "@pypi_tensorflow_metadata//:pkg", - ] - def py_library(name, lazy_imports = False, strict_deps = None, **kwargs): _ = (lazy_imports, strict_deps) # buildifier: disable=unused-variable _py_library( @@ -280,13 +272,14 @@ def pybind_extension(name, deps = None, **kwargs): deps = deps or [] deps = deps + ["@pybind11//:pybind11"] _pybind_extension( - name=name, - deps=deps, - **kwargs, + name = name, + deps = deps, + **kwargs ) - + def if_pywrap(if_true = None, if_false = None): _ = (if_false,) # buildifier: disable=unused-variable + # Always use pywrap. return if_true or [] diff --git a/tensorflow_text/tools/wordpiece_vocab/BUILD b/tensorflow_text/tools/wordpiece_vocab/BUILD index e356b8145..791b84989 100644 --- a/tensorflow_text/tools/wordpiece_vocab/BUILD +++ b/tensorflow_text/tools/wordpiece_vocab/BUILD @@ -36,7 +36,9 @@ py_test( strict_deps = False, deps = [ ":wordpiece_tokenizer_learner_lib", + "@pypi//absl_py:pkg", # absl/testing:parameterized dep "@pypi//numpy:pkg", + "@release_or_nightly//:tensorflow_pkg", # tensorflow package dep # python/data/ops:dataset_ops tensorflow dep, "//tensorflow_text:ops", ] + if_pywrap([ @@ -61,7 +63,7 @@ py_test( deps = [ ":bert_vocab_from_dataset", ":wordpiece_tokenizer_learner_lib", - "@absl_py//absl/testing:absltest", + "@pypi//absl_py:pkg", # absl/testing:absltest dep "@pypi//numpy:pkg", "@release_or_nightly//:tensorflow_pkg", # tensorflow package dep ], diff --git a/third_party/bazel/py_deps_profile.bzl b/third_party/bazel/py_deps_profile.bzl index 72d63240c..72020ec3e 100644 --- a/third_party/bazel/py_deps_profile.bzl +++ b/third_party/bazel/py_deps_profile.bzl @@ -7,14 +7,16 @@ def _py_deps_profile_impl(ctx): for var_name, var_val in ctx.attr.switch.items(): is_switch = is_switch or ctx.os.environ.get(var_name, "") == var_val + tf_version = ctx.os.environ.get("TF_VERSION", "") prefix = ctx.attr.pip_repo_name requirements_name = ctx.attr.requirements_in.name requirements_in_substitutions = {} build_content = ['exports_files(["{}"])'.format(requirements_name)] for k, v in ctx.attr.deps_map.items(): repo_name = v[0] if is_switch else k - requirements_in_substitutions[k + "\n"] = repo_name + "\n" - requirements_in_substitutions[k + "\r\n"] = repo_name + "\r\n" + req_entry = "{}=={}".format(repo_name, tf_version) if (k == "tensorflow" and tf_version) else repo_name + requirements_in_substitutions[k + "\n"] = req_entry + "\n" + requirements_in_substitutions[k + "\r\n"] = req_entry + "\r\n" aliased_targets = ["pkg"] + v[1:] norm_repo_name = repo_name.replace("-", "_") norm_alas_name = k.replace("-", "_") @@ -45,5 +47,9 @@ py_deps_profile = repository_rule( "pip_repo_name": attr.string(mandatory = True), "switch": attr.string_dict(mandatory = True), }, + environ = [ + "IS_NIGHTLY", + "TF_VERSION", + ], local = True, )