From 4d4ebae8265e94e9a6f96f1e68588e705497366c Mon Sep 17 00:00:00 2001 From: Yulia Baturina Date: Thu, 11 Dec 2025 18:35:29 -0800 Subject: [PATCH] Replace `http_archive` with `tf_http_archive` for Github links to avoid timeout issues. PiperOrigin-RevId: 843458022 --- WORKSPACE | 14 ++++++----- tensorflow/workspace0.bzl | 14 +++++------ tensorflow/workspace1.bzl | 9 ++++--- tensorflow/workspace3.bzl | 49 +++++++++++++++++---------------------- 4 files changed, 40 insertions(+), 46 deletions(-) diff --git a/WORKSPACE b/WORKSPACE index 0fc24cb3edd..97d26fb10fd 100644 --- a/WORKSPACE +++ b/WORKSPACE @@ -4,26 +4,28 @@ workspace(name = "org_tensorflow") # buildifier: disable=load-on-top -load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive") +load("//third_party:repo.bzl", "tf_http_archive", "tf_mirror_urls") -http_archive( +tf_http_archive( name = "rules_shell", sha256 = "bc61ef94facc78e20a645726f64756e5e285a045037c7a61f65af2941f4c25e1", strip_prefix = "rules_shell-0.4.1", - url = "https://github.com/bazelbuild/rules_shell/releases/download/v0.4.1/rules_shell-v0.4.1.tar.gz", + urls = tf_mirror_urls( + "https://github.com/bazelbuild/rules_shell/releases/download/v0.4.1/rules_shell-v0.4.1.tar.gz", + ), ) # Initialize toolchains for ML projects. # # A hermetic build system is designed to produce completely reproducible builds for C++. # Details: https://github.com/google-ml-infra/rules_ml_toolchain -http_archive( +tf_http_archive( name = "rules_ml_toolchain", sha256 = "7f00b3e94bbca1a4737ded6b9ed5358f6d1c86430c2ec97c90081343c0482f18", strip_prefix = "rules_ml_toolchain-29d54c875da37e74b8548924ed30e78cb28126b9", - urls = [ + urls = tf_mirror_urls( "https://github.com/yuriivcs/rules_ml_toolchain/archive/29d54c875da37e74b8548924ed30e78cb28126b9.tar.gz", - ], + ), ) load( diff --git a/tensorflow/workspace0.bzl b/tensorflow/workspace0.bzl index 144e34d7460..e6507c60a40 100644 --- a/tensorflow/workspace0.bzl +++ b/tensorflow/workspace0.bzl @@ -8,6 +8,7 @@ load("@build_bazel_rules_swift//swift:repositories.bzl", "swift_rules_dependenci load("@com_github_grpc_grpc//bazel:grpc_extra_deps.bzl", "grpc_extra_deps") load("@local_config_android//:android.bzl", "android_workspace") load("@rules_foreign_cc//foreign_cc:repositories.bzl", "rules_foreign_cc_dependencies") +load("//third_party:repo.bzl", "tf_http_archive", "tf_mirror_urls") load("//third_party/googleapis:repository_rules.bzl", "config_googleapis") def _tf_bind(): @@ -79,14 +80,13 @@ def workspace(): # Note: We add this to fix Kokoro builds. # The rules below call into `rules_proto` but the hash has changed and # Bazel refuses to continue. So, we add our own mirror. - http_archive( + tf_http_archive( name = "rules_proto", sha256 = "20b240eba17a36be4b0b22635aca63053913d5c1ee36e16be36499d167a2f533", strip_prefix = "rules_proto-11bf7c25e666dd7ddacbcd4d4c4a9de7a25175f8", - urls = [ - "https://storage.googleapis.com/mirror.tensorflow.org/github.com/bazelbuild/rules_proto/archive/11bf7c25e666dd7ddacbcd4d4c4a9de7a25175f8.tar.gz", + urls = tf_mirror_urls( "https://github.com/bazelbuild/rules_proto/archive/11bf7c25e666dd7ddacbcd4d4c4a9de7a25175f8.tar.gz", - ], + ), ) # Now, finally use the rules @@ -106,13 +106,13 @@ def workspace(): # Toolchains for ML projects hermetic builds. # Details: https://github.com/google-ml-infra/rules_ml_toolchain - http_archive( + tf_http_archive( name = "rules_ml_toolchain", sha256 = "b1e5e306d8b1103e73b9b778dfc3a9e069d20664437a03246a235724962b5c94", strip_prefix = "rules_ml_toolchain-484235be45e6843db962c45d08fe4b2b65a6a24c", - urls = [ + urls = tf_mirror_urls( "https://github.com/google-ml-infra/rules_ml_toolchain/archive/484235be45e6843db962c45d08fe4b2b65a6a24c.tar.gz", - ], + ), ) # Alias so it can be loaded without assigning to a different symbol to prevent diff --git a/tensorflow/workspace1.bzl b/tensorflow/workspace1.bzl index 399ff8f7579..408e9a89183 100644 --- a/tensorflow/workspace1.bzl +++ b/tensorflow/workspace1.bzl @@ -1,11 +1,11 @@ """TensorFlow workspace initialization. Consult the WORKSPACE on how to use it.""" -load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive") load("@com_github_grpc_grpc//bazel:grpc_deps.bzl", "grpc_deps") load("@com_google_benchmark//:bazel/benchmark_deps.bzl", "benchmark_deps") load("@io_bazel_rules_closure//closure:defs.bzl", "closure_repositories") load("@local_xla//third_party/llvm:setup.bzl", "llvm_setup") load("@rules_pkg//:deps.bzl", "rules_pkg_dependencies") +load("//third_party:repo.bzl", "tf_http_archive", "tf_mirror_urls") load("//third_party/android:android_configure.bzl", "android_configure") # buildifier: disable=unnamed-macro @@ -21,14 +21,13 @@ def workspace(with_rules_cc = True): closure_repositories() - http_archive( + tf_http_archive( name = "bazel_toolchains", sha256 = "294cdd859e57fcaf101d4301978c408c88683fbc46fbc1a3829da92afbea55fb", strip_prefix = "bazel-toolchains-8c717f8258cd5f6c7a45b97d974292755852b658", - urls = [ - "http://mirror.tensorflow.org/github.com/bazelbuild/bazel-toolchains/archive/8c717f8258cd5f6c7a45b97d974292755852b658.tar.gz", + urls = tf_mirror_urls( "https://github.com/bazelbuild/bazel-toolchains/archive/8c717f8258cd5f6c7a45b97d974292755852b658.tar.gz", - ], + ), ) android_configure(name = "local_config_android") diff --git a/tensorflow/workspace3.bzl b/tensorflow/workspace3.bzl index adabcc54fc5..b74e2e012b0 100644 --- a/tensorflow/workspace3.bzl +++ b/tensorflow/workspace3.bzl @@ -1,80 +1,73 @@ """TensorFlow workspace initialization. Consult the WORKSPACE on how to use it.""" -load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive") -load("//third_party:repo.bzl", "tf_vendored") +load("//third_party:repo.bzl", "tf_http_archive", "tf_mirror_urls", "tf_vendored") load("//third_party/tf_runtime:workspace.bzl", tf_runtime = "repo") def workspace(): tf_vendored(name = "local_xla", path = "third_party/xla") tf_vendored(name = "local_tsl", path = "third_party/xla/third_party/tsl") - http_archive( + tf_http_archive( name = "io_bazel_rules_closure", sha256 = "5b00383d08dd71f28503736db0500b6fb4dda47489ff5fc6bed42557c07c6ba9", strip_prefix = "rules_closure-308b05b2419edb5c8ee0471b67a40403df940149", - urls = [ - "https://storage.googleapis.com/mirror.tensorflow.org/github.com/bazelbuild/rules_closure/archive/308b05b2419edb5c8ee0471b67a40403df940149.tar.gz", + urls = tf_mirror_urls( "https://github.com/bazelbuild/rules_closure/archive/308b05b2419edb5c8ee0471b67a40403df940149.tar.gz", # 2019-06-13 - ], + ), ) tf_runtime() # https://github.com/bazelbuild/bazel-skylib/releases - http_archive( + tf_http_archive( name = "bazel_skylib", sha256 = "bc283cdfcd526a52c3201279cda4bc298652efa898b10b4db0837dc51652756f", - urls = [ - "https://storage.googleapis.com/mirror.tensorflow.org/github.com/bazelbuild/bazel-skylib/releases/download/1.7.1/bazel-skylib-1.7.1.tar.gz", + urls = tf_mirror_urls( "https://github.com/bazelbuild/bazel-skylib/releases/download/1.7.1/bazel-skylib-1.7.1.tar.gz", - ], + ), ) - http_archive( + tf_http_archive( name = "rules_license", - urls = [ - "https://mirror.bazel.build/github.com/bazelbuild/rules_license/releases/download/0.0.7/rules_license-0.0.7.tar.gz", + urls = tf_mirror_urls( "https://github.com/bazelbuild/rules_license/releases/download/0.0.7/rules_license-0.0.7.tar.gz", - ], + ), sha256 = "4531deccb913639c30e5c7512a054d5d875698daeb75d8cf90f284375fe7c360", ) - http_archive( + tf_http_archive( name = "rules_pkg", - urls = [ - "https://mirror.bazel.build/github.com/bazelbuild/rules_pkg/releases/download/0.7.1/rules_pkg-0.7.1.tar.gz", + urls = tf_mirror_urls( "https://github.com/bazelbuild/rules_pkg/releases/download/0.7.1/rules_pkg-0.7.1.tar.gz", - ], + ), sha256 = "451e08a4d78988c06fa3f9306ec813b836b1d076d0f055595444ba4ff22b867f", ) - http_archive( + tf_http_archive( name = "bazel_features", sha256 = "4fd9922d464686820ffd8fcefa28ccffa147f7cdc6b6ac0d8b07fde565c65d66", strip_prefix = "bazel_features-1.25.0", - urls = [ - "https://mirror.bazel.build/github.com/bazel-contrib/bazel_features/releases/download/v1.25.0/bazel_features-v1.25.0.tar.gz", + urls = tf_mirror_urls( "https://github.com/bazel-contrib/bazel_features/releases/download/v1.25.0/bazel_features-v1.25.0.tar.gz", - ], + ), ) # Maven dependencies. RULES_JVM_EXTERNAL_TAG = "4.3" - http_archive( + tf_http_archive( name = "rules_jvm_external", strip_prefix = "rules_jvm_external-%s" % RULES_JVM_EXTERNAL_TAG, sha256 = "6274687f6fc5783b589f56a2f1ed60de3ce1f99bc4e8f9edef3de43bdf7c6e74", - url = "https://github.com/bazelbuild/rules_jvm_external/archive/%s.zip" % RULES_JVM_EXTERNAL_TAG, + urls = tf_mirror_urls("https://github.com/bazelbuild/rules_jvm_external/archive/%s.zip" % RULES_JVM_EXTERNAL_TAG), ) # Platforms - http_archive( + tf_http_archive( name = "platforms", sha256 = "29742e87275809b5e598dc2f04d86960cc7a55b3067d97221c9abbc9926bff0f", - urls = [ - "https://mirror.bazel.build/github.com/bazelbuild/platforms/releases/download/0.0.11/platforms-0.0.11.tar.gz", + urls = tf_mirror_urls( "https://github.com/bazelbuild/platforms/releases/download/0.0.11/platforms-0.0.11.tar.gz", - ], + ), ) # Alias so it can be loaded without assigning to a different symbol to prevent